stillmade-sdk 0.1.50 → 0.1.51

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.
@@ -6,7 +6,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
6
6
  `).replace(vi,``)}function bi(e,t,n){if(t=yi(t),yi(e)!==t&&n)throw Error(r(425))}function xi(){}var Si=null,Ci=null;function wi(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Ti=typeof setTimeout==`function`?setTimeout:void 0,Ei=typeof clearTimeout==`function`?clearTimeout:void 0,Di=typeof Promise==`function`?Promise:void 0,Oi=typeof queueMicrotask==`function`?queueMicrotask:Di===void 0?Ti:function(e){return Di.resolve(null).then(e).catch(ki)};function ki(e){setTimeout(function(){throw e})}function Ai(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`){if(r===0){e.removeChild(i),fn(t);return}r--}else n!==`$`&&n!==`$?`&&n!==`$!`||r++}n=i}while(n);fn(t)}function ji(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`)break;if(t===`/$`)return null}}return e}function Mi(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`){if(t===0)return e;t--}else n===`/$`&&t++}e=e.previousSibling}return null}var Ni=Math.random().toString(36).slice(2),Pi=`__reactFiber$`+Ni,Fi=`__reactProps$`+Ni,Ii=`__reactContainer$`+Ni,Li=`__reactEvents$`+Ni,Ri=`__reactListeners$`+Ni,zi=`__reactHandles$`+Ni;function Bi(e){var t=e[Pi];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ii]||n[Pi]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Mi(e);e!==null;){if(n=e[Pi])return n;e=Mi(e)}return t}e=n,n=e.parentNode}return null}function Vi(e){return e=e[Pi]||e[Ii],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Hi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(r(33))}function Ui(e){return e[Fi]||null}var H=[],Wi=-1;function Gi(e){return{current:e}}function Ki(e){0>Wi||(e.current=H[Wi],H[Wi]=null,Wi--)}function qi(e,t){Wi++,H[Wi]=e.current,e.current=t}var Ji={},Yi=Gi(Ji),Xi=Gi(!1),Zi=Ji;function Qi(e,t){var n=e.type.contextTypes;if(!n)return Ji;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function $i(e){return e=e.childContextTypes,e!=null}function U(){Ki(Xi),Ki(Yi)}function ea(e,t,n){if(Yi.current!==Ji)throw Error(r(168));qi(Yi,t),qi(Xi,n)}function ta(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,se(e)||`Unknown`,a));return L({},n,i)}function na(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ji,Zi=Yi.current,qi(Yi,e),qi(Xi,Xi.current),!0}function ra(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=ta(e,t,Zi),i.__reactInternalMemoizedMergedChildContext=e,Ki(Xi),Ki(Yi),qi(Yi,e)):Ki(Xi),qi(Xi,n)}var ia=null,aa=!1,oa=!1;function sa(e){ia===null?ia=[e]:ia.push(e)}function ca(e){aa=!0,sa(e)}function la(){if(!oa&&ia!==null){oa=!0;var e=0,t=Vt;try{var n=ia;for(Vt=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}ia=null,aa=!1}catch(t){throw ia!==null&&(ia=ia.slice(e+1)),ft(B,la),t}finally{Vt=t,oa=!1}}return null}var ua=[],da=0,fa=null,pa=0,ma=[],ha=0,ga=null,_a=1,va=``;function ya(e,t){ua[da++]=pa,ua[da++]=fa,fa=e,pa=t}function ba(e,t,n){ma[ha++]=_a,ma[ha++]=va,ma[ha++]=ga,ga=e;var r=_a;e=va;var i=32-Tt(r)-1;r&=~(1<<i),n+=1;var a=32-Tt(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,_a=1<<32-Tt(t)+i|n<<i|r,va=a+e}else _a=1<<a|n<<i|r,va=e}function xa(e){e.return!==null&&(ya(e,1),ba(e,1,0))}function Sa(e){for(;e===fa;)fa=ua[--da],ua[da]=null,pa=ua[--da],ua[da]=null;for(;e===ga;)ga=ma[--ha],ma[ha]=null,va=ma[--ha],ma[ha]=null,_a=ma[--ha],ma[ha]=null}var Ca=null,wa=null,Ta=!1,Ea=null;function Da(e,t){var n=tu(5,null,null,0);n.elementType=`DELETED`,n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Oa(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null&&(e.stateNode=t,Ca=e,wa=ji(t.firstChild),!0);case 6:return t=e.pendingProps===``||t.nodeType!==3?null:t,t!==null&&(e.stateNode=t,Ca=e,wa=null,!0);case 13:return t=t.nodeType===8?t:null,t!==null&&(n=ga===null?null:{id:_a,overflow:va},e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=tu(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Ca=e,wa=null,!0);default:return!1}}function ka(e){return!!(e.mode&1)&&!(e.flags&128)}function Aa(e){if(Ta){var t=wa;if(t){var n=t;if(!Oa(e,t)){if(ka(e))throw Error(r(418));t=ji(n.nextSibling);var i=Ca;t&&Oa(e,t)?Da(i,n):(e.flags=e.flags&-4097|2,Ta=!1,Ca=e)}}else{if(ka(e))throw Error(r(418));e.flags=e.flags&-4097|2,Ta=!1,Ca=e}}}function ja(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Ca=e}function Ma(e){if(e!==Ca)return!1;if(!Ta)return ja(e),Ta=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!==`head`&&t!==`body`&&!wi(e.type,e.memoizedProps)),t&&=wa){if(ka(e))throw Na(),Error(r(418));for(;t;)Da(e,t),t=ji(t.nextSibling)}if(ja(e),e.tag===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(317));a:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`){if(t===0){wa=ji(e.nextSibling);break a}t--}else n!==`$`&&n!==`$!`&&n!==`$?`||t++}e=e.nextSibling}wa=null}}else wa=Ca?ji(e.stateNode.nextSibling):null;return!0}function Na(){for(var e=wa;e;)e=ji(e.nextSibling)}function Pa(){wa=Ca=null,Ta=!1}function Fa(e){Ea===null?Ea=[e]:Ea.push(e)}var Ia=C.ReactCurrentBatchConfig;function La(e,t,n){if(e=n.ref,e!==null&&typeof e!=`function`&&typeof e!=`object`){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(r(309));var i=n.stateNode}if(!i)throw Error(r(147,e));var a=i,o=``+e;return t!==null&&t.ref!==null&&typeof t.ref==`function`&&t.ref._stringRef===o?t.ref:(t=function(e){var t=a.refs;e===null?delete t[o]:t[o]=e},t._stringRef=o,t)}if(typeof e!=`string`)throw Error(r(284));if(!n._owner)throw Error(r(290,e))}return e}function Ra(e,t){throw e=Object.prototype.toString.call(t),Error(r(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e))}function za(e){var t=e._init;return t(e._payload)}function Ba(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function i(e,t){for(e=new Map;t!==null;)t.key===null?e.set(t.index,t):e.set(t.key,t),t=t.sibling;return e}function a(e,t){return e=iu(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=2,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=2),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=cu(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===E?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===F&&za(i)===t.type)?(r=a(t,n.props),r.ref=La(e,t,n),r.return=e,r):(r=au(n.type,n.key,n.props,null,e.mode,r),r.ref=La(e,t,n),r.return=e,r)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=lu(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=ou(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`)return t=cu(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case w:return n=au(t.type,t.key,t.props,null,e.mode,n),n.ref=La(e,null,t),n.return=e,n;case T:return t=lu(t,e.mode,n),t.return=e,t;case F:var r=t._init;return f(e,r(t._payload),n)}if(be(t)||te(t))return t=ou(t,e.mode,n,null),t.return=e,t;Ra(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case w:return n.key===i?l(e,t,n,r):null;case T:return n.key===i?u(e,t,n,r):null;case F:return i=n._init,p(e,t,i(n._payload),r)}if(be(n)||te(n))return i===null?d(e,t,n,r,null):null;Ra(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case w:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case T:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case F:var a=r._init;return m(e,t,n,a(r._payload),i)}if(be(r)||te(r))return e=e.get(n)||null,d(t,e,r,i,null);Ra(t,r)}return null}function h(r,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),Ta&&ya(r,h),l;if(d===null){for(;h<s.length;h++)d=f(r,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Ta&&ya(r,h),l}for(d=i(r,d);h<s.length;h++)g=m(d,r,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(r,e)}),Ta&&ya(r,h),l}function g(a,s,c,l){var u=te(c);if(typeof u!=`function`)throw Error(r(150));if(c=u.call(c),c==null)throw Error(r(151));for(var d=u=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Ta&&ya(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Ta&&ya(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Ta&&ya(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===E&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===E){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===F&&za(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=La(e,l,i),r.return=e,e=r;break a}n(e,l);break}t(e,l),l=l.sibling}i.type===E?(r=ou(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=au(i.type,i.key,i.props,null,e.mode,o),o.ref=La(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}n(e,r);break}t(e,r),r=r.sibling}r=lu(i,e.mode,o),r.return=e,e=r}return s(e);case F:return l=i._init,_(e,r,l(i._payload),o)}if(be(i))return h(e,r,i,o);if(te(i))return g(e,r,i,o);Ra(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=cu(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Va=Ba(!0),Ha=Ba(!1),Ua=Gi(null),Wa=null,Ga=null,Ka=null;function qa(){Ka=Ga=Wa=null}function Ja(e){var t=Ua.current;Ki(Ua),e._currentValue=t}function Ya(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Xa(e,t){Wa=e,Ka=Ga=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Bs=!0),e.firstContext=null)}function Za(e){var t=e._currentValue;if(Ka!==e){if(e={context:e,memoizedValue:t,next:null},Ga===null){if(Wa===null)throw Error(r(308));Ga=e,Wa.dependencies={lanes:0,firstContext:e}}else Ga=Ga.next=e}return t}var Qa=null;function $a(e){Qa===null?Qa=[e]:Qa.push(e)}function eo(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,$a(t)):(n.next=i.next,i.next=n),t.interleaved=n,to(e,r)}function to(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var no=!1;function ro(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function io(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function ao(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function oo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Xc&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,to(e,n)}return i=r.interleaved,i===null?(t.next=t,$a(r)):(t.next=i.next,i.next=t),r.interleaved=t,to(e,n)}function so(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Bt(e,n)}}function co(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function lo(e,t,n,r){var i=e.updateQueue;no=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=L({},d,f);break a;case 2:no=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);il|=o,e.lanes=o,e.memoizedState=d}}function uo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var i=e[t],a=i.callback;if(a!==null){if(i.callback=null,i=n,typeof a!=`function`)throw Error(r(191,a));a.call(i)}}}var fo={},po=Gi(fo),mo=Gi(fo),ho=Gi(fo);function go(e){if(e===fo)throw Error(r(174));return e}function _o(e,t){switch(qi(ho,t),qi(mo,e),qi(po,fo),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ee(null,``);break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Ee(t,e)}Ki(po),qi(po,t)}function vo(){Ki(po),Ki(mo),Ki(ho)}function yo(e){go(ho.current);var t=go(po.current),n=Ee(t,e.type);t!==n&&(qi(mo,e),qi(po,n))}function bo(e){mo.current===e&&(Ki(po),Ki(mo))}var xo=Gi(0);function So(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data===`$?`||n.data===`$!`))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Co=[];function wo(){for(var e=0;e<Co.length;e++)Co[e]._workInProgressVersionPrimary=null;Co.length=0}var To=C.ReactCurrentDispatcher,Eo=C.ReactCurrentBatchConfig,Do=0,Oo=null,ko=null,Ao=null,jo=!1,Mo=!1,No=0,Po=0;function Fo(){throw Error(r(321))}function Io(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!kr(e[n],t[n]))return!1;return!0}function Lo(e,t,n,i,a,o){if(Do=o,Oo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,To.current=e===null||e.memoizedState===null?bs:xs,e=n(i,a),Mo){o=0;do{if(Mo=!1,No=0,25<=o)throw Error(r(301));o+=1,Ao=ko=null,t.updateQueue=null,To.current=Ss,e=n(i,a)}while(Mo)}if(To.current=ys,t=ko!==null&&ko.next!==null,Do=0,Ao=ko=Oo=null,jo=!1,t)throw Error(r(300));return e}function Ro(){var e=No!==0;return No=0,e}function zo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ao===null?Oo.memoizedState=Ao=e:Ao=Ao.next=e,Ao}function Bo(){if(ko===null){var e=Oo.alternate;e=e===null?null:e.memoizedState}else e=ko.next;var t=Ao===null?Oo.memoizedState:Ao.next;if(t!==null)Ao=t,ko=e;else{if(e===null)throw Error(r(310));ko=e,e={memoizedState:ko.memoizedState,baseState:ko.baseState,baseQueue:ko.baseQueue,queue:ko.queue,next:null},Ao===null?Oo.memoizedState=Ao=e:Ao=Ao.next=e}return Ao}function Vo(e,t){return typeof t==`function`?t(e):t}function Ho(e){var t=Bo(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=ko,a=i.baseQueue,o=n.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}i.baseQueue=a=o,n.pending=null}if(a!==null){o=a.next,i=i.baseState;var c=s=null,l=null,u=o;do{var d=u.lane;if((Do&d)===d)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),i=u.hasEagerState?u.eagerState:e(i,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(c=l=f,s=i):l=l.next=f,Oo.lanes|=d,il|=d}u=u.next}while(u!==null&&u!==o);l===null?s=i:l.next=c,kr(i,t.memoizedState)||(Bs=!0),t.memoizedState=i,t.baseState=s,t.baseQueue=l,n.lastRenderedState=i}if(e=n.interleaved,e!==null){a=e;do o=a.lane,Oo.lanes|=o,il|=o,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Uo(e){var t=Bo(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);kr(o,t.memoizedState)||(Bs=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,i]}function Wo(){}function Go(e,t){var n=Oo,i=Bo(),a=t(),o=!kr(i.memoizedState,a);if(o&&(i.memoizedState=a,Bs=!0),i=i.queue,rs(Jo.bind(null,n,i,e),[e]),i.getSnapshot!==t||o||Ao!==null&&Ao.memoizedState.tag&1){if(n.flags|=2048,Qo(9,qo.bind(null,n,i,a,t),void 0,null),Zc===null)throw Error(r(349));Do&30||Ko(n,t,a)}return a}function Ko(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Oo.updateQueue,t===null?(t={lastEffect:null,stores:null},Oo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function qo(e,t,n,r){t.value=n,t.getSnapshot=r,Yo(t)&&Xo(e)}function Jo(e,t,n){return n(function(){Yo(t)&&Xo(e)})}function Yo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!kr(e,n)}catch{return!0}}function Xo(e){var t=to(e,1);t!==null&&Cl(t,e,1,-1)}function Zo(e){var t=zo();return typeof e==`function`&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Vo,lastRenderedState:e},t.queue=e,e=e.dispatch=hs.bind(null,Oo,e),[t.memoizedState,e]}function Qo(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Oo.updateQueue,t===null?(t={lastEffect:null,stores:null},Oo.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function $o(){return Bo().memoizedState}function es(e,t,n,r){var i=zo();Oo.flags|=e,i.memoizedState=Qo(1|t,n,void 0,r===void 0?null:r)}function ts(e,t,n,r){var i=Bo();r=r===void 0?null:r;var a=void 0;if(ko!==null){var o=ko.memoizedState;if(a=o.destroy,r!==null&&Io(r,o.deps)){i.memoizedState=Qo(t,n,a,r);return}}Oo.flags|=e,i.memoizedState=Qo(1|t,n,a,r)}function ns(e,t){return es(8390656,8,e,t)}function rs(e,t){return ts(2048,8,e,t)}function is(e,t){return ts(4,2,e,t)}function as(e,t){return ts(4,4,e,t)}function os(e,t){if(typeof t==`function`)return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ss(e,t,n){return n=n==null?null:n.concat([e]),ts(4,4,os.bind(null,t,e),n)}function cs(){}function ls(e,t){var n=Bo();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Io(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function us(e,t){var n=Bo();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Io(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function ds(e,t,n){return Do&21?(kr(n,t)||(n=It(),Oo.lanes|=n,il|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Bs=!0),e.memoizedState=n)}function fs(e,t){var n=Vt;Vt=n!==0&&4>n?n:4,e(!0);var r=Eo.transition;Eo.transition={};try{e(!1),t()}finally{Vt=n,Eo.transition=r}}function ps(){return Bo().memoizedState}function ms(e,t,n){var r=Sl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},gs(e))_s(t,n);else if(n=eo(e,t,n,r),n!==null){var i=xl();Cl(n,e,r,i),vs(n,t,r)}}function hs(e,t,n){var r=Sl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(gs(e))_s(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,kr(s,o)){var c=t.interleaved;c===null?(i.next=i,$a(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=eo(e,t,i,r),n!==null&&(i=xl(),Cl(n,e,r,i),vs(n,t,r))}}function gs(e){var t=e.alternate;return e===Oo||t!==null&&t===Oo}function _s(e,t){Mo=jo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function vs(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Bt(e,n)}}var ys={readContext:Za,useCallback:Fo,useContext:Fo,useEffect:Fo,useImperativeHandle:Fo,useInsertionEffect:Fo,useLayoutEffect:Fo,useMemo:Fo,useReducer:Fo,useRef:Fo,useState:Fo,useDebugValue:Fo,useDeferredValue:Fo,useTransition:Fo,useMutableSource:Fo,useSyncExternalStore:Fo,useId:Fo,unstable_isNewReconciler:!1},bs={readContext:Za,useCallback:function(e,t){return zo().memoizedState=[e,t===void 0?null:t],e},useContext:Za,useEffect:ns,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),es(4194308,4,os.bind(null,t,e),n)},useLayoutEffect:function(e,t){return es(4194308,4,e,t)},useInsertionEffect:function(e,t){return es(4,2,e,t)},useMemo:function(e,t){var n=zo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=zo();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=ms.bind(null,Oo,e),[r.memoizedState,e]},useRef:function(e){var t=zo();return e={current:e},t.memoizedState=e},useState:Zo,useDebugValue:cs,useDeferredValue:function(e){return zo().memoizedState=e},useTransition:function(){var e=Zo(!1),t=e[0];return e=fs.bind(null,e[1]),zo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=Oo,a=zo();if(Ta){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Zc===null)throw Error(r(349));Do&30||Ko(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ns(Jo.bind(null,i,o,e),[e]),i.flags|=2048,Qo(9,qo.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=zo(),t=Zc.identifierPrefix;if(Ta){var n=va,r=_a;n=(r&~(1<<32-Tt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=No++,0<n&&(t+=`H`+n.toString(32)),t+=`:`}else n=Po++,t=`:`+t+`r`+n.toString(32)+`:`;return e.memoizedState=t},unstable_isNewReconciler:!1},xs={readContext:Za,useCallback:ls,useContext:Za,useEffect:rs,useImperativeHandle:ss,useInsertionEffect:is,useLayoutEffect:as,useMemo:us,useReducer:Ho,useRef:$o,useState:function(){return Ho(Vo)},useDebugValue:cs,useDeferredValue:function(e){return ds(Bo(),ko.memoizedState,e)},useTransition:function(){return[Ho(Vo)[0],Bo().memoizedState]},useMutableSource:Wo,useSyncExternalStore:Go,useId:ps,unstable_isNewReconciler:!1},Ss={readContext:Za,useCallback:ls,useContext:Za,useEffect:rs,useImperativeHandle:ss,useInsertionEffect:is,useLayoutEffect:as,useMemo:us,useReducer:Uo,useRef:$o,useState:function(){return Uo(Vo)},useDebugValue:cs,useDeferredValue:function(e){var t=Bo();return ko===null?t.memoizedState=e:ds(t,ko.memoizedState,e)},useTransition:function(){return[Uo(Vo)[0],Bo().memoizedState]},useMutableSource:Wo,useSyncExternalStore:Go,useId:ps,unstable_isNewReconciler:!1};function Cs(e,t){if(e&&e.defaultProps){for(var n in t=L({},t),e=e.defaultProps,e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function ws(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:L({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ts={isMounted:function(e){return(e=e._reactInternals)?ot(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=xl(),i=Sl(e),a=ao(r,i);a.payload=t,n!=null&&(a.callback=n),t=oo(e,a,i),t!==null&&(Cl(t,e,i,r),so(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=xl(),i=Sl(e),a=ao(r,i);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=oo(e,a,i),t!==null&&(Cl(t,e,i,r),so(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=xl(),r=Sl(e),i=ao(n,r);i.tag=2,t!=null&&(i.callback=t),t=oo(e,i,r),t!==null&&(Cl(t,e,r,n),so(t,e,r))}};function Es(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Ar(n,r)||!Ar(i,a):!0}function Ds(e,t,n){var r=!1,i=Ji,a=t.contextType;return typeof a==`object`&&a?a=Za(a):(i=$i(t)?Zi:Yi.current,r=t.contextTypes,a=(r=r!=null)?Qi(e,i):Ji),t=new t(n,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ts,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=a),t}function Os(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ts.enqueueReplaceState(t,t.state,null)}function ks(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},ro(e);var a=t.contextType;typeof a==`object`&&a?i.context=Za(a):(a=$i(t)?Zi:Yi.current,i.context=Qi(e,a)),i.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a==`function`&&(ws(e,t,a,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps==`function`||typeof i.getSnapshotBeforeUpdate==`function`||typeof i.UNSAFE_componentWillMount!=`function`&&typeof i.componentWillMount!=`function`||(t=i.state,typeof i.componentWillMount==`function`&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount==`function`&&i.UNSAFE_componentWillMount(),t!==i.state&&Ts.enqueueReplaceState(i,i.state,null),lo(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount==`function`&&(e.flags|=4194308)}function As(e,t){try{var n=``,r=t;do n+=ae(r),r=r.return;while(r);var i=n}catch(e){i=`
7
7
  Error generating stack: `+e.message+`
8
8
  `+e.stack}return{value:e,source:t,stack:i,digest:null}}function js(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Ms(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var Ns=typeof WeakMap==`function`?WeakMap:Map;function Ps(e,t,n){n=ao(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){fl||(fl=!0,pl=r),Ms(e,t)},n}function Fs(e,t,n){n=ao(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Ms(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){Ms(e,t),typeof r!=`function`&&(ml===null?ml=new Set([this]):ml.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function Is(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ns;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=Jl.bind(null,e,t,n),t.then(e,e))}function Ls(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null||t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function Rs(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=ao(-1,1),t.tag=2,oo(n,t,1))),n.lanes|=1),e)}var zs=C.ReactCurrentOwner,Bs=!1;function Vs(e,t,n,r){t.child=e===null?Ha(t,null,n,r):Va(t,e.child,n,r)}function Hs(e,t,n,r,i){n=n.render;var a=t.ref;return Xa(t,i),r=Lo(e,t,n,r,a,i),n=Ro(),e!==null&&!Bs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,cc(e,t,i)):(Ta&&n&&xa(t),t.flags|=1,Vs(e,t,r,i),t.child)}function Us(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!nu(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,Ws(e,t,a,r,i)):(e=au(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Ar:n,n(o,r)&&e.ref===t.ref)return cc(e,t,i)}return t.flags|=1,e=iu(a,r),e.ref=t.ref,e.return=t,t.child=e}function Ws(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Ar(a,r)&&e.ref===t.ref){if(Bs=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Bs=!0);else return t.lanes=e.lanes,cc(e,t,i)}}return qs(e,t,n,r,i)}function Gs(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`){if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},qi(tl,el),el|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,qi(tl,el),el|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,qi(tl,el),el|=r}}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),qi(tl,el),el|=r;return Vs(e,t,i,n),t.child}function Ks(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function qs(e,t,n,r,i){var a=$i(n)?Zi:Yi.current;return a=Qi(t,a),Xa(t,i),n=Lo(e,t,n,r,a,i),r=Ro(),e!==null&&!Bs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,cc(e,t,i)):(Ta&&r&&xa(t),t.flags|=1,Vs(e,t,n,i),t.child)}function Js(e,t,n,r,i){if($i(n)){var a=!0;na(t)}else a=!1;if(Xa(t,i),t.stateNode===null)sc(e,t),Ds(t,n,r),ks(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=Za(l):(l=$i(n)?Zi:Yi.current,l=Qi(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&Os(t,o,r,l),no=!1;var f=t.memoizedState;o.state=f,lo(t,r,o,i),c=t.memoizedState,s!==r||f!==c||Xi.current||no?(typeof u==`function`&&(ws(t,n,u,r),c=t.memoizedState),(s=no||Es(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,io(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:Cs(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=Za(c):(c=$i(n)?Zi:Yi.current,c=Qi(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&Os(t,o,r,c),no=!1,f=t.memoizedState,o.state=f,lo(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||Xi.current||no?(typeof p==`function`&&(ws(t,n,p,r),m=t.memoizedState),(l=no||Es(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Ys(e,t,n,r,a,i)}function Ys(e,t,n,r,i,a){Ks(e,t);var o=!!(t.flags&128);if(!r&&!o)return i&&ra(t,n,!1),cc(e,t,a);r=t.stateNode,zs.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Va(t,e.child,null,a),t.child=Va(t,null,s,a)):Vs(e,t,s,a),t.memoizedState=r.state,i&&ra(t,n,!0),t.child}function Xs(e){var t=e.stateNode;t.pendingContext?ea(e,t.pendingContext,t.pendingContext!==t.context):t.context&&ea(e,t.context,!1),_o(e,t.containerInfo)}function Zs(e,t,n,r,i){return Pa(),Fa(i),t.flags|=256,Vs(e,t,n,r),t.child}var Qs={dehydrated:null,treeContext:null,retryLane:0};function $s(e){return{baseLanes:e,cachePool:null,transitions:null}}function ec(e,t,n){var r=t.pendingProps,i=xo.current,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(i&2)),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),qi(xo,i&1),e===null)return Aa(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.lanes=t.mode&1?e.data===`$!`?8:1073741824:1,null):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=su(o,r,0,null),e=ou(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=$s(n),t.memoizedState=Qs,e):tc(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return rc(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=iu(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=ou(a,o,n,null),a.flags|=2):a=iu(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?$s(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=Qs,r}return a=e.child,e=a.sibling,r=iu(a,{mode:`visible`,children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function tc(e,t){return t=su({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function nc(e,t,n,r){return r!==null&&Fa(r),Va(t,e.child,null,n),e=tc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function rc(e,t,n,i,a,o,s){if(n)return t.flags&256?(t.flags&=-257,i=js(Error(r(422))),nc(e,t,s,i)):t.memoizedState===null?(o=i.fallback,a=t.mode,i=su({mode:`visible`,children:i.children},a,0,null),o=ou(o,a,s,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,t.mode&1&&Va(t,e.child,null,s),t.child.memoizedState=$s(s),t.memoizedState=Qs,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return nc(e,t,s,null);if(a.data===`$!`){if(i=a.nextSibling&&a.nextSibling.dataset,i)var c=i.dgst;return i=c,o=Error(r(419)),i=js(o,i,void 0),nc(e,t,s,i)}if(c=(s&e.childLanes)!==0,Bs||c){if(i=Zc,i!==null){switch(s&-s){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(i.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,to(e,a),Cl(i,e,a,-1))}return Ll(),i=js(Error(r(421))),nc(e,t,s,i)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=Xl.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,wa=ji(a.nextSibling),Ca=t,Ta=!0,Ea=null,e!==null&&(ma[ha++]=_a,ma[ha++]=va,ma[ha++]=ga,_a=e.id,va=e.overflow,ga=t),t=tc(t,i.children),t.flags|=4096,t)}function ic(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ya(e.return,t,n)}function ac(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function oc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(Vs(e,t,r.children,n),r=xo.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ic(e,n,t);else if(e.tag===19)ic(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(qi(xo,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&So(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),ac(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&So(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}ac(t,!0,n,null,a);break;case`together`:ac(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function sc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function cc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),il|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=iu(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=iu(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function lc(e,t,n){switch(t.tag){case 3:Xs(t),Pa();break;case 5:yo(t);break;case 1:$i(t.type)&&na(t);break;case 4:_o(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;qi(Ua,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(qi(xo,xo.current&1),e=cc(e,t,n),e===null?null:e.sibling):ec(e,t,n):(qi(xo,xo.current&1),t.flags|=128,null);qi(xo,xo.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return oc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),qi(xo,xo.current),r)break;return null;case 22:case 23:return t.lanes=0,Gs(e,t,n)}return cc(e,t,n)}var uc=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},dc=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,go(po.current);var o=null;switch(n){case`input`:i=me(e,i),r=me(e,r),o=[];break;case`select`:i=L({},i,{value:void 0}),r=L({},r,{value:void 0}),o=[];break;case`textarea`:i=xe(e,i),r=xe(e,r),o=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=xi)}Fe(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null){if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(a.hasOwnProperty(u)?o||=[]:(o||=[]).push(u,null))}for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null)){if(u===`style`){if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(o||=[],o.push(u,n)),n=l}else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(o||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(a.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&si(`scroll`,e),o||c===l||(o=[])):(o||=[]).push(u,l))}}n&&(o||=[]).push(`style`,n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}},fc=function(e,t,n,r){n!==r&&(t.flags|=4)};function pc(e,t){if(!Ta)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function mc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function hc(e,t,n){var i=t.pendingProps;switch(Sa(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mc(t),null;case 1:return $i(t.type)&&U(),mc(t),null;case 3:return i=t.stateNode,vo(),Ki(Xi),Ki(Yi),wo(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(Ma(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ea!==null&&(Dl(Ea),Ea=null))),mc(t),null;case 5:bo(t);var o=go(ho.current);if(n=t.type,e!==null&&t.stateNode!=null)dc(e,t,n,i,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!i){if(t.stateNode===null)throw Error(r(166));return mc(t),null}if(e=go(po.current),Ma(t)){i=t.stateNode,n=t.type;var s=t.memoizedProps;switch(i[Pi]=t,i[Fi]=s,e=!!(t.mode&1),n){case`dialog`:si(`cancel`,i),si(`close`,i);break;case`iframe`:case`object`:case`embed`:si(`load`,i);break;case`video`:case`audio`:for(o=0;o<ri.length;o++)si(ri[o],i);break;case`source`:si(`error`,i);break;case`img`:case`image`:case`link`:si(`error`,i),si(`load`,i);break;case`details`:si(`toggle`,i);break;case`input`:he(i,s),si(`invalid`,i);break;case`select`:i._wrapperState={wasMultiple:!!s.multiple},si(`invalid`,i);break;case`textarea`:Se(i,s),si(`invalid`,i)}for(var c in Fe(n,s),o=null,s)if(s.hasOwnProperty(c)){var l=s[c];c===`children`?typeof l==`string`?i.textContent!==l&&(!0!==s.suppressHydrationWarning&&bi(i.textContent,l,e),o=[`children`,l]):typeof l==`number`&&i.textContent!==``+l&&(!0!==s.suppressHydrationWarning&&bi(i.textContent,l,e),o=[`children`,``+l]):a.hasOwnProperty(c)&&l!=null&&c===`onScroll`&&si(`scroll`,i)}switch(n){case`input`:de(i),ve(i,s,!0);break;case`textarea`:de(i),we(i);break;case`select`:case`option`:break;default:typeof s.onClick==`function`&&(i.onclick=xi)}i=o,t.updateQueue=i,i!==null&&(t.flags|=4)}else{c=o.nodeType===9?o:o.ownerDocument,e===`http://www.w3.org/1999/xhtml`&&(e=Te(n)),e===`http://www.w3.org/1999/xhtml`?n===`script`?(e=c.createElement(`div`),e.innerHTML=`<script><\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Pi]=t,e[Fi]=i,uc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Ie(n,i),n){case`dialog`:si(`cancel`,e),si(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:si(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;o<ri.length;o++)si(ri[o],e);o=i;break;case`source`:si(`error`,e),o=i;break;case`img`:case`image`:case`link`:si(`error`,e),si(`load`,e),o=i;break;case`details`:si(`toggle`,e),o=i;break;case`input`:he(e,i),o=me(e,i),si(`invalid`,e);break;case`option`:o=i;break;case`select`:e._wrapperState={wasMultiple:!!i.multiple},o=L({},i,{value:void 0}),si(`invalid`,e);break;case`textarea`:Se(e,i),o=xe(e,i),si(`invalid`,e);break;default:o=i}for(s in Fe(n,o),l=o,l)if(l.hasOwnProperty(s)){var u=l[s];s===`style`?Ne(e,u):s===`dangerouslySetInnerHTML`?(u=u?u.__html:void 0,u!=null&&Oe(e,u)):s===`children`?typeof u==`string`?(n!==`textarea`||u!==``)&&ke(e,u):typeof u==`number`&&ke(e,``+u):s!==`suppressContentEditableWarning`&&s!==`suppressHydrationWarning`&&s!==`autoFocus`&&(a.hasOwnProperty(s)?u!=null&&s===`onScroll`&&si(`scroll`,e):u!=null&&S(e,s,u,c))}switch(n){case`input`:de(e),ve(e,i,!1);break;case`textarea`:de(e),we(e);break;case`option`:i.value!=null&&e.setAttribute(`value`,``+ce(i.value));break;case`select`:e.multiple=!!i.multiple,s=i.value,s==null?i.defaultValue!=null&&z(e,!!i.multiple,i.defaultValue,!0):z(e,!!i.multiple,s,!1);break;default:typeof o.onClick==`function`&&(e.onclick=xi)}switch(n){case`button`:case`input`:case`select`:case`textarea`:i=!!i.autoFocus;break a;case`img`:i=!0;break a;default:i=!1}}i&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return mc(t),null;case 6:if(e&&t.stateNode!=null)fc(e,t,e.memoizedProps,i);else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(n=go(ho.current),go(po.current),Ma(t)){if(i=t.stateNode,n=t.memoizedProps,i[Pi]=t,(s=i.nodeValue!==n)&&(e=Ca,e!==null))switch(e.tag){case 3:bi(i.nodeValue,n,!!(e.mode&1));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&bi(i.nodeValue,n,!!(e.mode&1))}s&&(t.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[Pi]=t,t.stateNode=i}return mc(t),null;case 13:if(Ki(xo),i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ta&&wa!==null&&t.mode&1&&!(t.flags&128))Na(),Pa(),t.flags|=98560,s=!1;else if(s=Ma(t),i!==null&&i.dehydrated!==null){if(e===null){if(!s)throw Error(r(318));if(s=t.memoizedState,s=s===null?null:s.dehydrated,!s)throw Error(r(317));s[Pi]=t}else Pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;mc(t),s=!1}else Ea!==null&&(Dl(Ea),Ea=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(i=i!==null,i!==(e!==null&&e.memoizedState!==null)&&i&&(t.child.flags|=8192,t.mode&1&&(e===null||xo.current&1?nl===0&&(nl=3):Ll())),t.updateQueue!==null&&(t.flags|=4),mc(t),null);case 4:return vo(),e===null&&ui(t.stateNode.containerInfo),mc(t),null;case 10:return Ja(t.type._context),mc(t),null;case 17:return $i(t.type)&&U(),mc(t),null;case 19:if(Ki(xo),s=t.memoizedState,s===null)return mc(t),null;if(i=!!(t.flags&128),c=s.rendering,c===null){if(i)pc(s,!1);else{if(nl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(c=So(e),c!==null){for(t.flags|=128,pc(s,!1),i=c.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),t.subtreeFlags=0,i=n,n=t.child;n!==null;)s=n,e=i,s.flags&=14680066,c=s.alternate,c===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,e=c.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return qi(xo,xo.current&1|2),t.child}e=e.sibling}s.tail!==null&&gt()>ul&&(t.flags|=128,i=!0,pc(s,!1),t.lanes=4194304)}}else{if(!i){if(e=So(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),pc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!Ta)return mc(t),null}else 2*gt()-s.renderingStartTime>ul&&n!==1073741824&&(t.flags|=128,i=!0,pc(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(mc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=gt(),t.sibling=null,n=xo.current,qi(xo,i?n&1|2:n&1),t);case 22:case 23:return Nl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?el&1073741824&&(mc(t),t.subtreeFlags&6&&(t.flags|=8192)):mc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function gc(e,t){switch(Sa(t),t.tag){case 1:return $i(t.type)&&U(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vo(),Ki(Xi),Ki(Yi),wo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return bo(t),null;case 13:if(Ki(xo),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ki(xo),null;case 4:return vo(),null;case 10:return Ja(t.type._context),null;case 22:case 23:return Nl(),null;case 24:return null;default:return null}}var _c=!1,vc=!1,yc=typeof WeakSet==`function`?WeakSet:Set,bc=null;function xc(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){ql(e,t,n)}else n.current=null}}function Sc(e,t,n){try{n()}catch(n){ql(e,t,n)}}var Cc=!1;function wc(e,t){if(Si=mn,e=Pr(),Fr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Ci={focusedElem:e,selectionRange:n},mn=!1,bc=t;bc!==null;)if(t=bc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,bc=e;else for(;bc!==null;){t=bc;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:Cs(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){ql(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,bc=e;break}bc=t.return}return h=Cc,Cc=!1,h}function Tc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&Sc(t,n,a)}i=i.next}while(i!==r)}}function Ec(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Dc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function Oc(e){var t=e.alternate;t!==null&&(e.alternate=null,Oc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Pi],delete t[Fi],delete t[Li],delete t[Ri],delete t[zi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function kc(e){return e.tag===5||e.tag===3||e.tag===4}function Ac(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||kc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function jc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=xi));else if(r!==4&&(e=e.child,e!==null))for(jc(e,t,n),e=e.sibling;e!==null;)jc(e,t,n),e=e.sibling}function Mc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Mc(e,t,n),e=e.sibling;e!==null;)Mc(e,t,n),e=e.sibling}var Nc=null,Pc=!1;function Fc(e,t,n){for(n=n.child;n!==null;)Ic(e,t,n),n=n.sibling}function Ic(e,t,n){if(Ct&&typeof Ct.onCommitFiberUnmount==`function`)try{Ct.onCommitFiberUnmount(St,n)}catch{}switch(n.tag){case 5:vc||xc(n,t);case 6:var r=Nc,i=Pc;Nc=null,Fc(e,t,n),Nc=r,Pc=i,Nc!==null&&(Pc?(e=Nc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Nc.removeChild(n.stateNode));break;case 18:Nc!==null&&(Pc?(e=Nc,n=n.stateNode,e.nodeType===8?Ai(e.parentNode,n):e.nodeType===1&&Ai(e,n),fn(e)):Ai(Nc,n.stateNode));break;case 4:r=Nc,i=Pc,Nc=n.stateNode.containerInfo,Pc=!0,Fc(e,t,n),Nc=r,Pc=i;break;case 0:case 11:case 14:case 15:if(!vc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&Sc(n,t,o),i=i.next}while(i!==r)}Fc(e,t,n);break;case 1:if(!vc&&(xc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){ql(n,t,e)}Fc(e,t,n);break;case 21:Fc(e,t,n);break;case 22:n.mode&1?(vc=(r=vc)||n.memoizedState!==null,Fc(e,t,n),vc=r):Fc(e,t,n);break;default:Fc(e,t,n)}}function Lc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new yc),t.forEach(function(t){var r=Zl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function Rc(e,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var a=n[i];try{var o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 5:Nc=c.stateNode,Pc=!1;break a;case 3:Nc=c.stateNode.containerInfo,Pc=!0;break a;case 4:Nc=c.stateNode.containerInfo,Pc=!0;break a}c=c.return}if(Nc===null)throw Error(r(160));Ic(o,s,a),Nc=null,Pc=!1;var l=a.alternate;l!==null&&(l.return=null),a.return=null}catch(e){ql(a,t,e)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)zc(t,e),t=t.sibling}function zc(e,t){var n=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Rc(t,e),Bc(e),i&4){try{Tc(3,e,e.return),Ec(3,e)}catch(t){ql(e,e.return,t)}try{Tc(5,e,e.return)}catch(t){ql(e,e.return,t)}}break;case 1:Rc(t,e),Bc(e),i&512&&n!==null&&xc(n,n.return);break;case 5:if(Rc(t,e),Bc(e),i&512&&n!==null&&xc(n,n.return),e.flags&32){var a=e.stateNode;try{ke(a,``)}catch(t){ql(e,e.return,t)}}if(i&4&&(a=e.stateNode,a!=null)){var o=e.memoizedProps,s=n===null?o:n.memoizedProps,c=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{c===`input`&&o.type===`radio`&&o.name!=null&&ge(a,o),Ie(c,s);var u=Ie(c,o);for(s=0;s<l.length;s+=2){var d=l[s],f=l[s+1];d===`style`?Ne(a,f):d===`dangerouslySetInnerHTML`?Oe(a,f):d===`children`?ke(a,f):S(a,d,f,u)}switch(c){case`input`:_e(a,o);break;case`textarea`:Ce(a,o);break;case`select`:var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m==null?p!==!!o.multiple&&(o.defaultValue==null?z(a,!!o.multiple,o.multiple?[]:``,!1):z(a,!!o.multiple,o.defaultValue,!0)):z(a,!!o.multiple,m,!1)}a[Fi]=o}catch(t){ql(e,e.return,t)}}break;case 6:if(Rc(t,e),Bc(e),i&4){if(e.stateNode===null)throw Error(r(162));a=e.stateNode,o=e.memoizedProps;try{a.nodeValue=o}catch(t){ql(e,e.return,t)}}break;case 3:if(Rc(t,e),Bc(e),i&4&&n!==null&&n.memoizedState.isDehydrated)try{fn(t.containerInfo)}catch(t){ql(e,e.return,t)}break;case 4:Rc(t,e),Bc(e);break;case 13:Rc(t,e),Bc(e),a=e.child,a.flags&8192&&(o=a.memoizedState!==null,a.stateNode.isHidden=o,!o||a.alternate!==null&&a.alternate.memoizedState!==null||(ll=gt())),i&4&&Lc(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(vc=(u=vc)||d,Rc(t,e),vc=u):Rc(t,e),Bc(e),i&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(bc=e,d=e.child;d!==null;){for(f=bc=d;bc!==null;){switch(p=bc,m=p.child,p.tag){case 0:case 11:case 14:case 15:Tc(4,p,p.return);break;case 1:xc(p,p.return);var h=p.stateNode;if(typeof h.componentWillUnmount==`function`){i=p,n=p.return;try{t=i,h.props=t.memoizedProps,h.state=t.memoizedState,h.componentWillUnmount()}catch(e){ql(i,n,e)}}break;case 5:xc(p,p.return);break;case 22:if(p.memoizedState!==null){Wc(f);continue}}m===null?Wc(f):(m.return=p,bc=m)}d=d.sibling}a:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{a=f.stateNode,u?(o=a.style,typeof o.setProperty==`function`?o.setProperty(`display`,`none`,`important`):o.display=`none`):(c=f.stateNode,l=f.memoizedProps.style,s=l!=null&&l.hasOwnProperty(`display`)?l.display:null,c.style.display=Me(`display`,s))}catch(t){ql(e,e.return,t)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?``:f.memoizedProps}catch(t){ql(e,e.return,t)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break a;for(;f.sibling===null;){if(f.return===null||f.return===e)break a;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Rc(t,e),Bc(e),i&4&&Lc(e);break;case 21:break;default:Rc(t,e),Bc(e)}}function Bc(e){var t=e.flags;if(t&2){try{a:{for(var n=e.return;n!==null;){if(kc(n)){var i=n;break a}n=n.return}throw Error(r(160))}switch(i.tag){case 5:var a=i.stateNode;i.flags&32&&(ke(a,``),i.flags&=-33),Mc(e,Ac(e),a);break;case 3:case 4:var o=i.stateNode.containerInfo;jc(e,Ac(e),o);break;default:throw Error(r(161))}}catch(t){ql(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Vc(e,t,n){bc=e,Hc(e,t,n)}function Hc(e,t,n){for(var r=!!(e.mode&1);bc!==null;){var i=bc,a=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||_c;if(!o){var s=i.alternate,c=s!==null&&s.memoizedState!==null||vc;s=_c;var l=vc;if(_c=o,(vc=c)&&!l)for(bc=i;bc!==null;)o=bc,c=o.child,o.tag===22&&o.memoizedState!==null||c===null?Gc(i):(c.return=o,bc=c);for(;a!==null;)bc=a,Hc(a,t,n),a=a.sibling;bc=i,_c=s,vc=l}Uc(e,t,n)}else i.subtreeFlags&8772&&a!==null?(a.return=i,bc=a):Uc(e,t,n)}}function Uc(e){for(;bc!==null;){var t=bc;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:vc||Ec(5,t);break;case 1:var i=t.stateNode;if(t.flags&4&&!vc){if(n===null)i.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:Cs(t.type,n.memoizedProps);i.componentDidUpdate(a,n.memoizedState,i.__reactInternalSnapshotBeforeUpdate)}}var o=t.updateQueue;o!==null&&uo(t,o,i);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}uo(t,s,n)}break;case 5:var c=t.stateNode;if(n===null&&t.flags&4){n=c;var l=t.memoizedProps;switch(t.type){case`button`:case`input`:case`select`:case`textarea`:l.autoFocus&&n.focus();break;case`img`:l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&fn(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}vc||t.flags&512&&Dc(t)}catch(e){ql(t,t.return,e)}}if(t===e){bc=null;break}if(n=t.sibling,n!==null){n.return=t.return,bc=n;break}bc=t.return}}function Wc(e){for(;bc!==null;){var t=bc;if(t===e){bc=null;break}var n=t.sibling;if(n!==null){n.return=t.return,bc=n;break}bc=t.return}}function Gc(e){for(;bc!==null;){var t=bc;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Ec(4,t)}catch(e){ql(t,n,e)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount==`function`){var i=t.return;try{r.componentDidMount()}catch(e){ql(t,i,e)}}var a=t.return;try{Dc(t)}catch(e){ql(t,a,e)}break;case 5:var o=t.return;try{Dc(t)}catch(e){ql(t,o,e)}}}catch(e){ql(t,t.return,e)}if(t===e){bc=null;break}var s=t.sibling;if(s!==null){s.return=t.return,bc=s;break}bc=t.return}}var Kc=Math.ceil,qc=C.ReactCurrentDispatcher,Jc=C.ReactCurrentOwner,Yc=C.ReactCurrentBatchConfig,Xc=0,Zc=null,Qc=null,$c=0,el=0,tl=Gi(0),nl=0,rl=null,il=0,al=0,ol=0,sl=null,cl=null,ll=0,ul=1/0,dl=null,fl=!1,pl=null,ml=null,W=!1,hl=null,gl=0,_l=0,vl=null,yl=-1,bl=0;function xl(){return Xc&6?gt():yl===-1?yl=gt():yl}function Sl(e){return e.mode&1?Xc&2&&$c!==0?$c&-$c:Ia.transition===null?(e=Vt,e===0?(e=window.event,e=e===void 0?16:bn(e.type),e):e):(bl===0&&(bl=It()),bl):1}function Cl(e,t,n,i){if(50<_l)throw _l=0,vl=null,Error(r(185));Rt(e,n,i),(!(Xc&2)||e!==Zc)&&(e===Zc&&(!(Xc&2)&&(al|=n),nl===4&&kl(e,$c)),wl(e,i),n===1&&Xc===0&&!(t.mode&1)&&(ul=gt()+500,aa&&la()))}function wl(e,t){var n=e.callbackNode;Pt(e,t);var r=Mt(e,e===Zc?$c:0);if(r===0)n!==null&&pt(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&pt(n),t===1)e.tag===0?ca(Al.bind(null,e)):sa(Al.bind(null,e)),Oi(function(){!(Xc&6)&&la()}),n=null;else{switch(Ht(r)){case 1:n=B;break;case 4:n=vt;break;case 16:n=yt;break;case 536870912:n=xt;break;default:n=yt}n=$l(n,Tl.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Tl(e,t){if(yl=-1,bl=0,Xc&6)throw Error(r(327));var n=e.callbackNode;if(Gl()&&e.callbackNode!==n)return null;var i=Mt(e,e===Zc?$c:0);if(i===0)return null;if(i&30||(i&e.expiredLanes)!==0||t)t=Rl(e,i);else{t=i;var a=Xc;Xc|=2;var o=Il();(Zc!==e||$c!==t)&&(dl=null,ul=gt()+500,Pl(e,t));do try{Bl();break}catch(t){Fl(e,t)}while(1);qa(),qc.current=o,Xc=a,Qc===null?(Zc=null,$c=0,t=nl):t=0}if(t!==0){if(t===2&&(a=Ft(e),a!==0&&(i=a,t=El(e,a))),t===1)throw n=rl,Pl(e,0),kl(e,i),wl(e,gt()),n;if(t===6)kl(e,i);else{if(a=e.current.alternate,!(i&30)&&!Ol(a)&&(t=Rl(e,i),t===2&&(o=Ft(e),o!==0&&(i=o,t=El(e,o))),t===1))throw n=rl,Pl(e,0),kl(e,i),wl(e,gt()),n;switch(e.finishedWork=a,e.finishedLanes=i,t){case 0:case 1:throw Error(r(345));case 2:Ul(e,cl,dl);break;case 3:if(kl(e,i),(i&130023424)===i&&(t=ll+500-gt(),10<t)){if(Mt(e,0)!==0)break;if(a=e.suspendedLanes,(a&i)!==i){xl(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Ti(Ul.bind(null,e,cl,dl),t);break}Ul(e,cl,dl);break;case 4:if(kl(e,i),(i&4194240)===i)break;for(t=e.eventTimes,a=-1;0<i;){var s=31-Tt(i);o=1<<s,s=t[s],s>a&&(a=s),i&=~o}if(i=a,i=gt()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Kc(i/1960))-i,10<i){e.timeoutHandle=Ti(Ul.bind(null,e,cl,dl),i);break}Ul(e,cl,dl);break;case 5:Ul(e,cl,dl);break;default:throw Error(r(329))}}}return wl(e,gt()),e.callbackNode===n?Tl.bind(null,e):null}function El(e,t){var n=sl;return e.current.memoizedState.isDehydrated&&(Pl(e,t).flags|=256),e=Rl(e,t),e!==2&&(t=cl,cl=n,t!==null&&Dl(t)),e}function Dl(e){cl===null?cl=e:cl.push.apply(cl,e)}function Ol(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!kr(a(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function kl(e,t){for(t&=~ol,t&=~al,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Tt(t),r=1<<n;e[n]=-1,t&=~r}}function Al(e){if(Xc&6)throw Error(r(327));Gl();var t=Mt(e,0);if(!(t&1))return wl(e,gt()),null;var n=Rl(e,t);if(e.tag!==0&&n===2){var i=Ft(e);i!==0&&(t=i,n=El(e,i))}if(n===1)throw n=rl,Pl(e,0),kl(e,t),wl(e,gt()),n;if(n===6)throw Error(r(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Ul(e,cl,dl),wl(e,gt()),null}function jl(e,t){var n=Xc;Xc|=1;try{return e(t)}finally{Xc=n,Xc===0&&(ul=gt()+500,aa&&la())}}function Ml(e){hl!==null&&hl.tag===0&&!(Xc&6)&&Gl();var t=Xc;Xc|=1;var n=Yc.transition,r=Vt;try{if(Yc.transition=null,Vt=1,e)return e()}finally{Vt=r,Yc.transition=n,Xc=t,!(Xc&6)&&la()}}function Nl(){el=tl.current,Ki(tl)}function Pl(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Ei(n)),Qc!==null)for(n=Qc.return;n!==null;){var r=n;switch(Sa(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&U();break;case 3:vo(),Ki(Xi),Ki(Yi),wo();break;case 5:bo(r);break;case 4:vo();break;case 13:Ki(xo);break;case 19:Ki(xo);break;case 10:Ja(r.type._context);break;case 22:case 23:Nl()}n=n.return}if(Zc=e,Qc=e=iu(e.current,null),$c=el=t,nl=0,rl=null,ol=al=il=0,cl=sl=null,Qa!==null){for(t=0;t<Qa.length;t++)if(n=Qa[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,a=n.pending;if(a!==null){var o=a.next;a.next=i,r.next=o}n.pending=r}Qa=null}return e}function Fl(e,t){do{var n=Qc;try{if(qa(),To.current=ys,jo){for(var i=Oo.memoizedState;i!==null;){var a=i.queue;a!==null&&(a.pending=null),i=i.next}jo=!1}if(Do=0,Ao=ko=Oo=null,Mo=!1,No=0,Jc.current=null,n===null||n.return===null){nl=1,rl=t,Qc=null;break}a:{var o=e,s=n.return,c=n,l=t;if(t=$c,c.flags|=32768,typeof l==`object`&&l&&typeof l.then==`function`){var u=l,d=c,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=Ls(s);if(m!==null){m.flags&=-257,Rs(m,s,c,o,t),m.mode&1&&Is(o,u,t),t=m,l=u;var h=t.updateQueue;if(h===null){var g=new Set;g.add(l),t.updateQueue=g}else h.add(l);break a}if(!(t&1)){Is(o,u,t),Ll();break a}l=Error(r(426))}else if(Ta&&c.mode&1){var _=Ls(s);if(_!==null){!(_.flags&65536)&&(_.flags|=256),Rs(_,s,c,o,t),Fa(As(l,c));break a}}o=l=As(l,c),nl!==4&&(nl=2),sl===null?sl=[o]:sl.push(o),o=s;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var v=Ps(o,l,t);co(o,v);break a;case 1:c=l;var y=o.type,b=o.stateNode;if(!(o.flags&128)&&(typeof y.getDerivedStateFromError==`function`||b!==null&&typeof b.componentDidCatch==`function`&&(ml===null||!ml.has(b)))){o.flags|=65536,t&=-t,o.lanes|=t;var x=Fs(o,c,t);co(o,x);break a}}o=o.return}while(o!==null)}Hl(n)}catch(e){t=e,Qc===n&&n!==null&&(Qc=n=n.return);continue}break}while(1)}function Il(){var e=qc.current;return qc.current=ys,e===null?ys:e}function Ll(){(nl===0||nl===3||nl===2)&&(nl=4),Zc===null||!(il&268435455)&&!(al&268435455)||kl(Zc,$c)}function Rl(e,t){var n=Xc;Xc|=2;var i=Il();(Zc!==e||$c!==t)&&(dl=null,Pl(e,t));do try{zl();break}catch(t){Fl(e,t)}while(1);if(qa(),Xc=n,qc.current=i,Qc!==null)throw Error(r(261));return Zc=null,$c=0,nl}function zl(){for(;Qc!==null;)Vl(Qc)}function Bl(){for(;Qc!==null&&!mt();)Vl(Qc)}function Vl(e){var t=Ql(e.alternate,e,el);e.memoizedProps=e.pendingProps,t===null?Hl(e):Qc=t,Jc.current=null}function Hl(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=gc(n,t),n!==null){n.flags&=32767,Qc=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{nl=6,Qc=null;return}}else if(n=hc(n,t,el),n!==null){Qc=n;return}if(t=t.sibling,t!==null){Qc=t;return}Qc=t=e}while(t!==null);nl===0&&(nl=5)}function Ul(e,t,n){var r=Vt,i=Yc.transition;try{Yc.transition=null,Vt=1,Wl(e,t,n,r)}finally{Yc.transition=i,Vt=r}return null}function Wl(e,t,n,i){do Gl();while(hl!==null);if(Xc&6)throw Error(r(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(zt(e,o),e===Zc&&(Qc=Zc=null,$c=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||W||(W=!0,$l(yt,function(){return Gl(),null})),o=!!(n.flags&15990),n.subtreeFlags&15990||o){o=Yc.transition,Yc.transition=null;var s=Vt;Vt=1;var c=Xc;Xc|=4,Jc.current=null,wc(e,n),zc(n,e),Ir(Ci),mn=!!Si,Ci=Si=null,e.current=n,Vc(n,e,a),ht(),Xc=c,Vt=s,Yc.transition=o}else e.current=n;if(W&&(W=!1,hl=e,gl=a),o=e.pendingLanes,o===0&&(ml=null),wt(n.stateNode,i),wl(e,gt()),t!==null)for(i=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],i(a.value,{componentStack:a.stack,digest:a.digest});if(fl)throw fl=!1,e=pl,pl=null,e;return gl&1&&e.tag!==0&&Gl(),o=e.pendingLanes,o&1?e===vl?_l++:(_l=0,vl=e):_l=0,la(),null}function Gl(){if(hl!==null){var e=Ht(gl),t=Yc.transition,n=Vt;try{if(Yc.transition=null,Vt=16>e?16:e,hl===null)var i=!1;else{if(e=hl,hl=null,gl=0,Xc&6)throw Error(r(331));var a=Xc;for(Xc|=4,bc=e.current;bc!==null;){var o=bc,s=o.child;if(bc.flags&16){var c=o.deletions;if(c!==null){for(var l=0;l<c.length;l++){var u=c[l];for(bc=u;bc!==null;){var d=bc;switch(d.tag){case 0:case 11:case 15:Tc(8,d,o)}var f=d.child;if(f!==null)f.return=d,bc=f;else for(;bc!==null;){d=bc;var p=d.sibling,m=d.return;if(Oc(d),d===u){bc=null;break}if(p!==null){p.return=m,bc=p;break}bc=m}}}var h=o.alternate;if(h!==null){var g=h.child;if(g!==null){h.child=null;do{var _=g.sibling;g.sibling=null,g=_}while(g!==null)}}bc=o}}if(o.subtreeFlags&2064&&s!==null)s.return=o,bc=s;else b:for(;bc!==null;){if(o=bc,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Tc(9,o,o.return)}var v=o.sibling;if(v!==null){v.return=o.return,bc=v;break b}bc=o.return}}var y=e.current;for(bc=y;bc!==null;){s=bc;var b=s.child;if(s.subtreeFlags&2064&&b!==null)b.return=s,bc=b;else b:for(s=y;bc!==null;){if(c=bc,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:Ec(9,c)}}catch(e){ql(c,c.return,e)}if(c===s){bc=null;break b}var x=c.sibling;if(x!==null){x.return=c.return,bc=x;break b}bc=c.return}}if(Xc=a,la(),Ct&&typeof Ct.onPostCommitFiberRoot==`function`)try{Ct.onPostCommitFiberRoot(St,e)}catch{}i=!0}return i}finally{Vt=n,Yc.transition=t}}return!1}function Kl(e,t,n){t=As(n,t),t=Ps(e,t,1),e=oo(e,t,1),t=xl(),e!==null&&(Rt(e,1,t),wl(e,t))}function ql(e,t,n){if(e.tag===3)Kl(e,e,n);else for(;t!==null;){if(t.tag===3){Kl(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(ml===null||!ml.has(r))){e=As(n,e),e=Fs(t,e,1),t=oo(t,e,1),e=xl(),t!==null&&(Rt(t,1,e),wl(t,e));break}}t=t.return}}function Jl(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=xl(),e.pingedLanes|=e.suspendedLanes&n,Zc===e&&($c&n)===n&&(nl===4||nl===3&&($c&130023424)===$c&&500>gt()-ll?Pl(e,0):ol|=n),wl(e,t)}function Yl(e,t){t===0&&(e.mode&1?(t=At,At<<=1,!(At&130023424)&&(At=4194304)):t=1);var n=xl();e=to(e,t),e!==null&&(Rt(e,t,n),wl(e,n))}function Xl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Yl(e,n)}function Zl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Yl(e,n)}var Ql=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||Xi.current)Bs=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Bs=!1,lc(e,t,n);Bs=!!(e.flags&131072)}}else Bs=!1,Ta&&t.flags&1048576&&ba(t,pa,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;sc(e,t),e=t.pendingProps;var a=Qi(t,Yi.current);Xa(t,n),a=Lo(null,t,i,e,a,n);var o=Ro();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,$i(i)?(o=!0,na(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,ro(t),a.updater=Ts,t.stateNode=a,a._reactInternals=t,ks(t,i,e,n),t=Ys(null,t,i,!0,o,n)):(t.tag=0,Ta&&o&&xa(t),Vs(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(sc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=ru(i),e=Cs(i,e),a){case 0:t=qs(null,t,i,e,n);break a;case 1:t=Js(null,t,i,e,n);break a;case 11:t=Hs(null,t,i,e,n);break a;case 14:t=Us(null,t,i,Cs(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Cs(i,a),qs(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Cs(i,a),Js(e,t,i,a,n);case 3:a:{if(Xs(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,io(e,t),lo(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated){if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=As(Error(r(423)),t),t=Zs(e,t,i,n,a);break a}if(i!==a){a=As(Error(r(424)),t),t=Zs(e,t,i,n,a);break a}for(wa=ji(t.stateNode.containerInfo.firstChild),Ca=t,Ta=!0,Ea=null,n=Ha(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Pa(),i===a){t=cc(e,t,n);break a}Vs(e,t,i,n)}t=t.child}return t;case 5:return yo(t),e===null&&Aa(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,wi(i,a)?s=null:o!==null&&wi(i,o)&&(t.flags|=32),Ks(e,t),Vs(e,t,s,n),t.child;case 6:return e===null&&Aa(t),null;case 13:return ec(e,t,n);case 4:return _o(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Va(t,null,i,n):Vs(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Cs(i,a),Hs(e,t,i,a,n);case 7:return Vs(e,t,t.pendingProps,n),t.child;case 8:return Vs(e,t,t.pendingProps.children,n),t.child;case 12:return Vs(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,qi(Ua,i._currentValue),i._currentValue=s,o!==null){if(kr(o.value,s)){if(o.children===a.children&&!Xi.current){t=cc(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=ao(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Ya(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Ya(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Vs(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,Xa(t,n),a=Za(a),i=i(a),t.flags|=1,Vs(e,t,i,n),t.child;case 14:return i=t.type,a=Cs(i,t.pendingProps),a=Cs(i.type,a),Us(e,t,i,a,n);case 15:return Ws(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Cs(i,a),sc(e,t),t.tag=1,$i(i)?(e=!0,na(t)):e=!1,Xa(t,n),Ds(t,i,a),ks(t,i,a,n),Ys(null,t,i,!0,e,n);case 19:return oc(e,t,n);case 22:return Gs(e,t,n)}throw Error(r(156,t.tag))};function $l(e,t){return ft(e,t)}function eu(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tu(e,t,n,r){return new eu(e,t,n,r)}function nu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ru(e){if(typeof e==`function`)return+!!nu(e);if(e!=null){if(e=e.$$typeof,e===j)return 11;if(e===P)return 14}return 2}function iu(e,t){var n=e.alternate;return n===null?(n=tu(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function au(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)nu(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return ou(n.children,a,o,t);case D:s=8,a|=8;break;case O:return e=tu(12,n,t,a|2),e.elementType=O,e.lanes=o,e;case M:return e=tu(13,n,t,a),e.elementType=M,e.lanes=o,e;case N:return e=tu(19,n,t,a),e.elementType=N,e.lanes=o,e;case I:return su(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case k:s=10;break a;case A:s=9;break a;case j:s=11;break a;case P:s=14;break a;case F:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=tu(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function ou(e,t,n,r){return e=tu(7,e,r,t),e.lanes=n,e}function su(e,t,n,r){return e=tu(22,e,r,t),e.elementType=I,e.lanes=n,e.stateNode={isHidden:!1},e}function cu(e,t,n){return e=tu(6,e,null,t),e.lanes=n,e}function lu(e,t,n){return t=tu(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function uu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Lt(0),this.expirationTimes=Lt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Lt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function du(e,t,n,r,i,a,o,s,c){return e=new uu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=tu(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ro(a),e}function fu(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:T,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}function pu(e){if(!e)return Ji;e=e._reactInternals;a:{if(ot(e)!==e||e.tag!==1)throw Error(r(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break a;case 1:if($i(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break a}}t=t.return}while(t!==null);throw Error(r(171))}if(e.tag===1){var n=e.type;if($i(n))return ta(e,n,t)}return t}function mu(e,t,n,r,i,a,o,s,c){return e=du(n,r,!0,e,i,a,o,s,c),e.context=pu(null),n=e.current,r=xl(),i=Sl(n),a=ao(r,i),a.callback=t??null,oo(n,a,i),e.current.lanes=i,Rt(e,i,r),wl(e,r),e}function hu(e,t,n,r){var i=t.current,a=xl(),o=Sl(i);return n=pu(n),t.context===null?t.context=n:t.pendingContext=n,t=ao(a,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=oo(i,t,o),e!==null&&(Cl(e,i,o,a),so(e,i,o)),o}function gu(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function _u(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function vu(e,t){_u(e,t),(e=e.alternate)&&_u(e,t)}function yu(){return null}var bu=typeof reportError==`function`?reportError:function(e){console.error(e)};function xu(e){this._internalRoot=e}Su.prototype.render=xu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));hu(e,t,null,null)},Su.prototype.unmount=xu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ml(function(){hu(null,e,null,null)}),t[Ii]=null}};function Su(e){this._internalRoot=e}Su.prototype.unstable_scheduleHydration=function(e){if(e){var t=Kt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<tn.length&&t!==0&&t<tn[n].priority;n++);tn.splice(n,0,e),n===0&&sn(e)}};function Cu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function G(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==` react-mount-point-unstable `))}function wu(){}function Tu(e,t,n,r,i){if(i){if(typeof r==`function`){var a=r;r=function(){var e=gu(o);a.call(e)}}var o=mu(t,r,e,0,null,!1,!1,``,wu);return e._reactRootContainer=o,e[Ii]=o.current,ui(e.nodeType===8?e.parentNode:e),Ml(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r==`function`){var s=r;r=function(){var e=gu(c);s.call(e)}}var c=du(e,0,!1,null,null,!1,!1,``,wu);return e._reactRootContainer=c,e[Ii]=c.current,ui(e.nodeType===8?e.parentNode:e),Ml(function(){hu(t,c,n,r)}),c}function Eu(e,t,n,r,i){var a=n._reactRootContainer;if(a){var o=a;if(typeof i==`function`){var s=i;i=function(){var e=gu(o);s.call(e)}}hu(t,o,e,i)}else o=Tu(n,t,e,i,r);return gu(o)}Ut=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=jt(t.pendingLanes);n!==0&&(Bt(t,n|1),wl(t,gt()),!(Xc&6)&&(ul=gt()+500,la()))}break;case 13:Ml(function(){var t=to(e,1);t!==null&&Cl(t,e,1,xl())}),vu(e,1)}},Wt=function(e){if(e.tag===13){var t=to(e,134217728);t!==null&&Cl(t,e,134217728,xl()),vu(e,134217728)}},Gt=function(e){if(e.tag===13){var t=Sl(e),n=to(e,t);n!==null&&Cl(n,e,t,xl()),vu(e,t)}},Kt=function(){return Vt},qt=function(e,t){var n=Vt;try{return Vt=e,t()}finally{Vt=n}},ze=function(e,t,n){switch(t){case`input`:if(_e(e,n),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name=`+JSON.stringify(``+t)+`][type="radio"]`),t=0;t<n.length;t++){var i=n[t];if(i!==e&&i.form===e.form){var a=Ui(i);if(!a)throw Error(r(90));fe(i),_e(i,a)}}}break;case`textarea`:Ce(e,n);break;case`select`:t=n.value,t!=null&&z(e,!!n.multiple,t,!1)}},Ge=jl,Ke=Ml;var Du={usingClientEntryPoint:!1,Events:[Vi,Hi,Ui,Ue,We,jl]},Ou={findFiberByHostInstance:Bi,bundleType:0,version:`18.3.1`,rendererPackageName:`react-dom`},ku={bundleType:Ou.bundleType,version:Ou.version,rendererPackageName:Ou.rendererPackageName,rendererConfig:Ou.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=ut(e),e===null?null:e.stateNode},findFiberByHostInstance:Ou.findFiberByHostInstance||yu,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:`18.3.1-next-f1338f8080-20240426`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Au=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Au.isDisabled&&Au.supportsFiber)try{St=Au.inject(ku),Ct=Au}catch{}}e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Du,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Cu(t))throw Error(r(200));return fu(e,t,null,n)},e.createRoot=function(e,t){if(!Cu(e))throw Error(r(299));var n=!1,i=``,a=bu;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=du(e,1,!1,null,null,n,!1,i,a),e[Ii]=t.current,ui(e.nodeType===8?e.parentNode:e),new xu(t)},e.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=ut(t),e=e===null?null:e.stateNode,e},e.flushSync=function(e){return Ml(e)},e.hydrate=function(e,t,n){if(!G(t))throw Error(r(200));return Eu(null,e,t,!0,n)},e.hydrateRoot=function(e,t,n){if(!Cu(e))throw Error(r(405));var i=n!=null&&n.hydratedSources||null,a=!1,o=``,s=bu;if(n!=null&&(!0===n.unstable_strictMode&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=mu(t,null,e,1,n??null,a,!1,o,s),e[Ii]=t.current,ui(e),i)for(e=0;e<i.length;e++)n=i[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new Su(t)},e.render=function(e,t,n){if(!G(t))throw Error(r(200));return Eu(null,e,t,!1,n)},e.unmountComponentAtNode=function(e){if(!G(e))throw Error(r(40));return e._reactRootContainer?(Ml(function(){Eu(null,null,e,!1,function(){e._reactRootContainer=null,e[Ii]=null})}),!0):!1},e.unstable_batchedUpdates=jl,e.unstable_renderSubtreeIntoContainer=function(e,t,n,i){if(!G(n))throw Error(r(200));if(e==null||e._reactInternals===void 0)throw Error(r(38));return Eu(e,t,n,!1,i)},e.version=`18.3.1-next-f1338f8080-20240426`})),g=s(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=s((e=>{var t=g();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),v=u(f(),1),y=_();function b(e=void 0){if(!e)return``;let t;try{t=new URL(e)}catch{return``}return t.protocol!==`https:`||t.username||t.password||t.pathname!==`/`||t.search||t.hash?``:t.origin}var x=(e,t)=>`${b(t)}${e}`,S=`The Block’s sandbox did not start: this browser, or an extension in it, blocks the frame Blocks run in. Open StillMade in Chrome, Edge or Safari.`,C=(e=globalThis.navigator?.userAgent||``)=>/\bClaude\/\d/.test(e),w=(e=globalThis.navigator?.userAgent||``)=>C(e)?`The Claude app’s built-in browser blocks the frame Blocks run in. Open this page in Chrome, Edge or Safari.`:S;async function T(){throw Error(`App views run inside StillMade.`)}function E(e,t={}){return B(O.includes(e),`SHARED_WORK_OPERATION`,`Choose a declared shared-work operation.`),mt(t),B(vt(t)&&JSON.stringify(t).length<=131072,`SHARED_WORK_INPUT`,`Shared-work requests require bounded JSON arguments.`),{operation:e,args:structuredClone(t)}}function D(e,t,n,r){let i=0,a=new Map,o=new Set,s=new Set,c=()=>{for(let e of s)URL.revokeObjectURL(e);s.clear()};return addEventListener(`message`,n=>{let r=n.data;if(n.source!==parent||!r||r.channel!==e||r.session!==t||![`shared-work-result`,`shared-work-refresh`].includes(r.op))return;if(r.op===`shared-work-refresh`){c();for(let e of o)try{e()}catch{}return}let i=a.get(r.id);if(i){if(a.delete(r.id),r.error){i.reject(Error(r.error));return}if(i.media){if(!(r.media instanceof Blob)||!r.media.size||r.media.size>67108864||![`image`,`video`,`audio`].includes(r.kind)||!r.media.type.startsWith(r.kind+`/`)||s.size>=2){i.reject(Error(`The shared creative preview is invalid or its limit was reached.`));return}let e=URL.createObjectURL(r.media);s.add(e),i.resolve({url:e,kind:r.kind})}else i.resolve(r.result)}}),addEventListener(`message`,n=>{n.source===parent&&n.data?.channel===e&&n.data?.session===t&&n.data?.op===`dispose`&&c()}),{releaseSharedWorkMedia(e){s.delete(e)&&URL.revokeObjectURL(e)},previewSharedWorkMedia(o){if(!n||typeof o!=`string`||!/^[0-9a-f-]{36}$/i.test(o))return Promise.reject(Error(`Choose a permitted saved creative.`));if(a.size>=4||s.size>=2)return Promise.reject(Error(`Close a previous preview before opening another.`));let c=String(++i);return new Promise((n,i)=>{a.set(c,{resolve:n,reject:i,media:!0}),r({channel:e,session:t,op:`shared-work-media-request`,id:c,contributionId:o},`*`)})},onSharedWorkRefresh(e){if(typeof e!=`function`)throw Error(`Expected a callback.`);return o.add(e),()=>o.delete(e)},sharedWork(o,s={}){if(!n)return Promise.reject(Error(`This Block has no shared-work permission.`));if(![`list`,`accounts`,`grants`,`create`,`bind`,`read`,`update`,`creatives`,`contribute`,`grant`,`revoke`,`unlink`].includes(o)||!s||Array.isArray(s)||typeof s!=`object`||JSON.stringify(s).length>131072)return Promise.reject(Error(`Invalid shared-work request.`));if(a.size>=4)return Promise.reject(Error(`Wait for the current shared-work request.`));let c=String(++i);return new Promise((n,i)=>{a.set(c,{resolve:n,reject:i}),r({channel:e,session:t,op:`shared-work-request`,id:c,operation:o,args:s},`*`)})}}}var O,k=o((()=>{Et(),O=Object.freeze([`list`,`accounts`,`grants`,`create`,`bind`,`read`,`update`,`creatives`,`contribute`,`grant`,`revoke`,`unlink`])}));function A(e){if(typeof e!=`string`||e.length>4194304)return!1;if(/^\/api\/media\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-][A-Za-z0-9._-]*$/.test(e)||/^data:image\/(png|jpeg|webp|gif);base64,[a-z0-9+/=]+$/i.test(e))return!0;try{let t=new URL(e);return[`https:`,`blob:`,`sm-media:`].includes(t.protocol)&&!t.username&&!t.password}catch{return!1}}var j=o((()=>{}));function M(e){if(!F(e,[`schemaVersion`,`format`,`name`,`files`])||e.schemaVersion!==1||![`file`,`zip`].includes(e.format)||!I(e.name)||e.name.includes(`/`)||!Array.isArray(e.files)||!e.files.length||e.files.length>N.files||(e.format===`file`?e.files.length!==1||!ee(e.name):!e.name.endsWith(`.zip`)))return!1;let t=new Set,n=0;return e.files.every(r=>{if(!P(r)||!I(r.path)||t.has(r.path.toLowerCase()))return!1;let i=r.path.toLowerCase();if([...t].some(e=>i.startsWith(e+`/`)||e.startsWith(i+`/`))||(t.add(i),e.format===`file`&&r.path!==e.name))return!1;if(F(r,[`path`,`text`])&&typeof r.text==`string`&&(ee(r.path)||e.format===`zip`&&te(r.path)))return n+=new TextEncoder().encode(r.text).length,n<=N.textBytes;if(e.format!==`zip`||!F(r,[`path`,`source`])||!L(r.path))return!1;let a=r.source;return P(a)&&A(a.url)&&[`image`,`video`,`audio`].includes(a.kind)&&[`assetId`,`versionId`,`url`].every(e=>typeof a[e]==`string`&&a[e].length>0&&a[e].length<=(e===`url`?8192:200))&&(a.role===void 0||typeof a.role==`string`&&a.role.length<=100)})}var N,P,F,I,ee,te,L,R=o((()=>{j(),N=Object.freeze({files:256,textBytes:3e6,pathLength:180}),P=e=>typeof e==`object`&&!!e&&!Array.isArray(e),F=(e,t)=>P(e)&&Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t)),I=e=>typeof e==`string`&&e.length<=N.pathLength&&/^[A-Za-z0-9_-][A-Za-z0-9_./-]*$/.test(e)&&e.split(`/`).every(e=>e&&![`.`,`..`,`__proto__`,`constructor`,`prototype`].includes(e)&&!e.endsWith(`.`)&&!/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(e)),ee=e=>/\.(?:txt|md|json|csv|xml|fcpxml|srt|vtt)$/i.test(e),te=e=>/\.(?:html?|css|[cm]?js|jsx|tsx?|vue|svelte|svg|map|ya?ml|toml|ini|py|[ch]|cc|cpp|hpp|rs|go|java|kt|swift|rb|sh|sql)$/i.test(e),L=e=>/\.(?:png|jpe?g|webp|gif|mp4|webm|mov|mp3|wav|ogg|m4a|flac|bin)$/i.test(e)}));function ne(e,t,n){if(!e)throw new ie(t,n)}function re(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e))}var ie,ae=o((()=>{ie=class extends Error{constructor(e,t,n=[]){super(t),this.name=`BlockError`,this.code=e,this.details=n}}}));function oe(){let e=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),t=/^(string|text|number|integer|boolean|object|json)(\[\])?\??$/,n=new Set([`__proto__`,`prototype`,`constructor`]);function r(i,a=0){return a>40?!1:typeof i==`string`?t.test(i):Array.isArray(i)?i.length===1&&r(i[0],a+1):e(i)&&Object.entries(i).every(([e,t])=>!n.has(e)&&r(t,a+1))}function i(t,r,o=0){return o>40?!1:r==null?!0:Array.isArray(r)?r.length===1&&Array.isArray(t)&&t.every(e=>i(e,r[0],o+1)):typeof r==`string`?r.endsWith(`?`)?t===void 0||i(t,r.slice(0,-1),o+1):r.endsWith(`[]`)?Array.isArray(t)&&t.every(e=>i(e,r.slice(0,-2),o+1)):r===`string`||r===`text`?typeof t==`string`:r===`object`?e(t):r===`json`?a(t,o+1):r===`integer`?Number.isSafeInteger(t):r===`number`?typeof t==`number`&&Number.isFinite(t):r===`boolean`&&typeof t==`boolean`:e(r)&&e(t)&&Object.entries(r).every(([e,r])=>!n.has(e)&&i(Object.hasOwn(t,e)?t[e]:void 0,r,o+1))}function a(t,r){return r>40?!1:t===null||typeof t==`string`||typeof t==`boolean`?!0:typeof t==`number`?Number.isFinite(t):(e(t)||Array.isArray(t))&&Object.entries(t).every(([e,t])=>!n.has(e)&&a(t,r+1))}return{semanticSchemaValid:r,schemaMatches:i,validate:(e,t)=>{try{return r(t)&&a(e,0)&&i(e,t)}catch{return!1}}}}var se,ce,le,ue=o((()=>{({semanticSchemaValid:se,schemaMatches:ce}=oe()),Object.freeze([`upstream`,`project`,`adapter`,`chat`,`default`,`user`,`external`,`view`]),le=Object.freeze([`key`,`semantic`,`accepts`,`schema`,`sources`,`sensitivity`,`freshnessPolicy`,`cardinality`,`batchable`])})),de,fe=o((()=>{de=Object.freeze([Object.freeze({name:`narration_script`,parents:Object.freeze([`script`])}),Object.freeze({name:`sales_script`,parents:Object.freeze([`script`])}),Object.freeze({name:`timed_transcript`,parents:Object.freeze([`transcript`])}),Object.freeze({name:`product_image`,parents:Object.freeze([`image`])}),Object.freeze({name:`reference_image`,parents:Object.freeze([`image`])}),Object.freeze({name:`generated_image`,parents:Object.freeze([`image`,`source_image`])}),Object.freeze({name:`processed_image`,parents:Object.freeze([`image`,`source_image`])}),Object.freeze({name:`visual_description`,parents:Object.freeze([`plain_text`])}),Object.freeze({name:`transcript_text`,parents:Object.freeze([`plain_text`])}),Object.freeze({name:`editor_timeline`,parents:Object.freeze([`timeline`])}),Object.freeze({name:`legacy.timeline.updatededitor`,parents:Object.freeze([`timeline`])}),Object.freeze({name:`narration_audio`,parents:Object.freeze([`source_audio`])}),Object.freeze({name:`generated_video`,parents:Object.freeze([`source_video`])}),Object.freeze({name:`edited_video`,parents:Object.freeze([`source_video`])}),Object.freeze({name:`rendered_video`,parents:Object.freeze([`source_video`])}),Object.freeze({name:`rendered_audio`,parents:Object.freeze([`source_audio`])})]),new Map(de.map(e=>[e.name,e.parents]))})),pe=o((()=>{ue()})),me=o((()=>{Object.freeze(new Set(`sm.ai-decide@1.0.0,sm.ai-write@1.0.0,sm.board-editor.hosted@3.0.0,sm.board-editor.hosted@3.1.0,sm.board-editor@2.0.0,sm.board-editor@2.1.0,sm.board-editor@2.2.0,sm.board-editor@2.2.1,sm.board-editor@2.2.10,sm.board-editor@2.2.11,sm.board-editor@2.2.2,sm.board-editor@2.2.3,sm.board-editor@2.2.4,sm.board-editor@2.2.5,sm.board-editor@2.2.6,sm.board-editor@2.2.7,sm.board-editor@2.2.8,sm.board-editor@2.2.9,sm.board-editor@3.0.0,sm.board-editor@3.1.0,sm.captions@2.0.0,sm.character@2.0.0,sm.character@2.0.1,sm.compare@2.0.0,sm.compare@2.0.1,sm.compare@2.0.2,sm.connect-app@1.0.0,sm.contact-fields@1.0.0,sm.edit-assistant@2.0.0,sm.edit-assistant@2.0.1,sm.edit-assistant@2.0.2,sm.editor.hosted@3.0.0,sm.editor.hosted@3.1.0,sm.editor@2.0.0,sm.editor@2.1.0,sm.editor@2.2.0,sm.editor@2.2.1,sm.editor@2.2.10,sm.editor@2.2.11,sm.editor@2.2.12,sm.editor@2.2.2,sm.editor@2.2.3,sm.editor@2.2.4,sm.editor@2.2.5,sm.editor@2.2.6,sm.editor@2.2.7,sm.editor@2.2.8,sm.editor@2.2.9,sm.editor@3.0.0,sm.editor@3.1.0,sm.export-audio@2.0.0,sm.export-timeline@2.0.0,sm.export-video@2.0.0,sm.export-video@2.1.0,sm.final-edit@2.0.0,sm.final-edit@2.0.1,sm.final-edit@2.0.2,sm.generate-image@2.0.0,sm.generate-image@2.1.0,sm.generate-video@2.0.0,sm.generate-video@2.0.1,sm.grade@2.0.0,sm.grade@2.0.1,sm.grade@2.0.2,sm.import-media@2.0.0,sm.import-media@2.0.1,sm.import-media@2.0.2,sm.location@2.0.0,sm.location@2.0.1,sm.meta-creative@1.0.0,sm.motion-graphics@2.0.0,sm.panel-strip.hosted@3.0.0,sm.panel-strip.hosted@3.1.0,sm.panel-strip@2.0.0,sm.panel-strip@2.1.0,sm.panel-strip@2.2.0,sm.panel-strip@2.3.0,sm.panel-strip@2.3.1,sm.panel-strip@2.3.2,sm.panel-strip@2.3.3,sm.panel-strip@2.3.4,sm.panel-strip@2.3.5,sm.panel-strip@2.3.6,sm.panel-strip@2.3.7,sm.panel-strip@2.4.0,sm.panel-strip@2.4.1,sm.panel-strip@2.4.2,sm.panel-strip@3.0.0,sm.panel-strip@3.1.0,sm.photo-editor@1.0.0,sm.photo-notes@1.0.0,sm.photo-notes@1.1.0,sm.pipeline@2.0.0,sm.pipeline@2.1.0,sm.pipeline@2.2.0,sm.pipeline@2.2.1,sm.pipeline@2.2.2,sm.pipeline@2.2.3,sm.pipeline@2.2.4,sm.pipeline@2.2.5,sm.pipeline@2.2.6,sm.rough-cut@2.0.0,sm.rough-cut@2.0.1,sm.rough-cut@2.0.2,sm.score@2.0.0,sm.style@2.0.0,sm.style@2.0.1,sm.transition@2.0.0,sm.transition@2.0.1,sm.transition@2.0.2,sm.video-assets@2.0.0,sm.video-assets@2.1.0,sm.video-assets@2.1.1,sm.video-assets@2.1.2,sm.video-assets@2.1.3,sm.video-assets@2.1.4,sm.voiceover.hosted@3.0.0,sm.voiceover@2.0.0,sm.voiceover@2.1.0,sm.voiceover@2.1.1,sm.voiceover@2.1.2,sm.voiceover@2.1.3,sm.voiceover@2.1.4,sm.voiceover@2.1.5,sm.voiceover@2.1.6,sm.voiceover@3.0.0,sm.when@1.0.0,sm.when@1.1.0,sm.write-summary@1.0.0,stillmade.generate@1.0.0,stillmade.generate@1.1.0,stillmade.generate@1.2.0`.split(`,`)))}));function he(e){return ye(e,[`schemaVersion`,`startMs`,`endMs`])&&e.schemaVersion===2&&typeof e.startMs==`number`&&Number.isFinite(e.startMs)&&e.startMs>=0&&typeof e.endMs==`number`&&Number.isFinite(e.endMs)&&e.endMs>=e.startMs&&e.endMs<=_e}function ge(e){return ye(e,[`schemaVersion`,`decision`])&&e.schemaVersion===2&&[`accepted`,`rejected`,`deferred`].includes(e.decision)}var _e,ve,ye,be=o((()=>{_e=2**53-1,ve=e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),ye=(e,t)=>ve(e)&&Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))})),z=o((()=>{Et()})),xe=o((()=>{Et(),z(),Object.freeze({routes:16,operations:64,keyLength:80,declarationBytes:65536})})),Se,Ce=o((()=>{Se=`(0|[1-9][0-9]{0,5})\\.(0|[1-9][0-9]{0,5})\\.(0|[1-9][0-9]{0,5})`,RegExp(`^`+Se+`$`),RegExp(`^(>=|<=|>|<|=)?`+Se+`$`)}));function we(e){return Te(e)&&Object.keys(e).length===5&&e.schemaVersion===1&&typeof e.title==`string`&&e.title.trim().length>0&&e.title.length<=200&&Ee.includes(e.field)&&Te(e.before)&&e.before.schemaVersion===1&&Te(e.after)&&e.after.schemaVersion===1}var Te,Ee,De=o((()=>{Te=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ee=Object.freeze([`blueprint`,`shotPlan`,`panels`,`board`,`canvas`,`animation`,`editor`])}));function Oe(e){if(!e||typeof e!=`object`||Array.isArray(e)||Object.keys(e).length!==4||!Object.keys(e).every(e=>[`type`,`duration`,`soundOn`,`soundId`].includes(e)))return!1;let t=ke.find(t=>t.type===e.type);return!!t&&Number.isFinite(e.duration)&&e.duration>=.1&&e.duration<=3&&typeof e.soundOn==`boolean`&&(t.sounds.length?t.sounds.includes(e.soundId):e.soundId===``)}var ke,Ae=o((()=>{ke=Object.freeze([{type:`Cut`,sounds:[]},{type:`Fade`,sounds:[]},{type:`Cross dissolve`,sounds:[]},{type:`Shape wipe`,sounds:[`shape_sweep`,`shape_pop`]},{type:`Iris`,sounds:[`shape_sweep`,`shape_pop`]},{type:`Ink splat`,sounds:[`shape_sweep`,`shape_pop`]},{type:`Swirl`,sounds:[`whoosh`,`swirl_wind`]},{type:`Whip left`,sounds:[`whip_crack`,`whip_zip`]},{type:`Whip right`,sounds:[`whip_crack`,`whip_zip`]},{type:`Whip up`,sounds:[`whip_crack`,`whip_zip`]},{type:`Whip down`,sounds:[`whip_crack`,`whip_zip`]},{type:`Whip pan`,sounds:[`whip_crack`,`whip_zip`]},{type:`Slash`,sounds:[`shape_sweep`,`shape_pop`]},{type:`Shred`,sounds:[`shape_sweep`,`shape_pop`]},{type:`Morph`,sounds:[`morph_warp`,`morph_bloom`]},{type:`Dip to black`,sounds:[]},{type:`Dip to white`,sounds:[]},{type:`Push left`,sounds:[`push_slide`,`push_thump`]},{type:`Push right`,sounds:[`push_slide`,`push_thump`]},{type:`Push up`,sounds:[`push_slide`,`push_thump`]},{type:`Push down`,sounds:[`push_slide`,`push_thump`]},{type:`Zoom left`,sounds:[]},{type:`Zoom right`,sounds:[]},{type:`Zoom up`,sounds:[]},{type:`Zoom down`,sounds:[]}].map(e=>Object.freeze({...e,sounds:Object.freeze(e.sounds)})))}));function je(e){if(!Me(e)||e.schemaVersion!==1||!Ne(e.title)||!Ne(e.timelineId)||!Array.isArray(e.commands)||!e.commands.length||e.commands.length>100||Object.keys(e).some(e=>![`schemaVersion`,`title`,`timelineId`,`commands`].includes(e)))return!1;let t=new Set;return e.commands.every(e=>{if(!Me(e)||![`clips`,`audioItems`,`captions`].includes(e.collection)||!Me(e.values)||!Ie(e,[`collection`,`operation`,`before`,`values`]))return!1;let n=e.values,r=e.operation===`caption.add`,i=r?n.id:e.before?.id,a=`${e.collection}:${i}`;return!Ne(i)||t.has(a)?!1:(t.add(a),e.collection===`captions`?r?e.before===null&&He(n)&&Ne(n.trackId)&&ze(n):!Me(e.before)||!ze(e.before)?!1:e.operation===`caption.update`?Ie(n,[`text`,`start`,`end`])&&ze(n):e.operation===`remove`&&Ie(n,[]):!Object.hasOwn(Fe,e.operation)||!Me(e.before)||!Pe(e.before.start,0,86400)||!Pe(e.before.duration,.001,86400)||!Ie(n,Fe[e.operation])?!1:e.operation===`transition`?e.collection===`clips`&&Oe(n):e.operation===`grade`?e.collection===`clips`&&Re(n):e.operation===`split`?Pe(n.at,0,86400)&&Ne(n.newId)&&n.newId!==e.before.id:e.operation===`move`?Pe(n.start,0,86400):e.operation===`trim`?Pe(n.trimStart,0,86400)&&Pe(n.duration,.001,86400):e.operation===`volume`?Pe(n.volume,0,200):e.operation!==`mute`||typeof n.muted==`boolean`)})}var Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue=o((()=>{Ae(),Me=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ne=e=>typeof e==`string`&&e.length>0&&e.length<=200,Pe=(e,t,n)=>Number.isFinite(e)&&e>=t&&e<=n,Fe={move:[`start`],trim:[`trimStart`,`duration`],volume:[`volume`],mute:[`muted`],remove:[],split:[`at`,`newId`],grade:[`lut`,`color`],transition:[`type`,`duration`,`soundOn`,`soundId`]},Ie=(e,t)=>Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t)),Le={brightness:[-100,100],contrast:[-100,100],saturation:[-100,100],temperature:[-100,100],sharpness:[-50,50],vignette:[0,100]},Re=e=>[`None`,`Cold`,`Warm`,`Desaturated`,`High Contrast`,`Filmic`,`Teal and Orange`].includes(e.lut)&&Me(e.color)&&Ie(e.color,Object.keys(Le))&&Object.entries(Le).every(([t,[n,r]])=>Pe(e.color[t],n,r)),ze=e=>typeof e.text==`string`&&e.text.trim().length>0&&e.text.length<=5e3&&Pe(e.start,0,86400)&&Pe(e.end,0,86400)&&e.end-e.start>=.001,Be=[`id`,`trackId`,`text`,`start`,`end`],Ve={font:e=>e===`Hanken Grotesk`,size:e=>Pe(e,8,200),color:e=>typeof e==`string`&&/^#[a-f0-9]{3}(?:[a-f0-9]{3})?$/i.test(e),highlightColor:e=>typeof e==`string`&&/^#[a-f0-9]{3}(?:[a-f0-9]{3})?$/i.test(e),background:e=>e===`none`||typeof e==`string`&&/^#[a-f0-9]{3}(?:[a-f0-9]{3})?$/i.test(e),backgroundOpacity:e=>Pe(e,0,100),backgroundPadding:e=>Pe(e,0,100),backgroundRadius:e=>Pe(e,0,100),position:e=>[`top left`,`top center`,`top right`,`middle left`,`middle center`,`middle right`,`bottom left`,`bottom center`,`bottom right`].includes(e),animation:e=>[`none`,`fade`].includes(e)},He=e=>!Be.every(t=>Object.hasOwn(e,t))||Object.keys(e).some(e=>!Be.includes(e)&&e!==`words`&&!Object.hasOwn(Ve,e))||!Object.entries(Ve).every(([t,n])=>!Object.hasOwn(e,t)||n(e[t]))?!1:!Object.hasOwn(e,`words`)||Array.isArray(e.words)&&e.words.length<=1e3&&e.words.every((t,n)=>Me(t)&&Ie(t,[`text`,`start`,`end`])&&typeof t.text==`string`&&t.text.trim().length>0&&t.text.length<=5e3&&Pe(t.start,e.start,e.end)&&Pe(t.end,t.start,e.end)&&(n===0||t.start>=e.words[n-1].start))})),We,Ge=o((()=>{We=Object.freeze([`screen.capture`,`cursor.track`,`camera.capture`,`microphone.capture`,`clipboard.read`,`clipboard.write`,`media.pick`,`notifications.show`,`power.keep-awake`,`native.tools`,`folder.read`,`folder.write`])})),Ke=o((()=>{Object.freeze({"org.stillmade.PythonAdapter":Object.freeze({id:`org.stillmade.PythonAdapter`,adapterVersion:1,label:`Python connection`,actions:Object.freeze([`adapter.import`,`adapter.inspect`,`adapter.execute`,`adapter.describe`,`adapter.call`]),projectExtensions:Object.freeze([`py`])}),"org.natron.Natron":Object.freeze({id:`org.natron.Natron`,adapterVersion:1,label:`Natron`,actions:Object.freeze([`launch`,`project.import`,`project.open`,`project.render`]),projectExtensions:Object.freeze([`ntp`])})})}));function qe(e){return et(e)&&e.kind===`file`&&nt(e.assetId,512)&&nt(e.versionId,512)&&at.includes(e.mimeType)&&(e.url===void 0||nt(e.url,32768))&&(e.name===void 0||nt(e.name,rt.fileName))&&(e.bytes===void 0||Number.isSafeInteger(e.bytes)&&e.bytes>=0)}function Je(e){return et(e)&&Object.keys(e).every(e=>[`schemaVersion`,`format`,`text`,`title`].includes(e))&&e.schemaVersion===1&&ot.includes(e.format)&&typeof e.text==`string`&&e.text.length<=rt.documentText&&(e.title===void 0||typeof e.title==`string`&&e.title.length<=rt.documentTitle)}function Ye(e){if(!et(e)||!Object.keys(e).every(e=>[`schemaVersion`,`columns`,`rows`].includes(e))||e.schemaVersion!==void 0&&e.schemaVersion!==1)return!1;let{columns:t,rows:n}=e;if(!Array.isArray(t)||!t.length||t.length>rt.tableColumns||!Array.isArray(n)||n.length>rt.tableRows||!t.every(e=>typeof e==`string`&&e.trim().length>0&&e.length<=rt.columnName&&!tt.has(e))||new Set(t).size!==t.length)return!1;let r=new Set(t),i=0;for(let e of n){if(!et(e))return!1;for(let[t,n]of Object.entries(e))if(!r.has(t)||!st(n)||++i>rt.tableCells)return!1}return!0}function Xe(e){if(typeof e!=`string`||!e.length||e.length>rt.url||/[\s\u0000-\u001f\u007f]/.test(e))return!1;let t;try{t=new URL(e)}catch{return!1}return[`http:`,`https:`].includes(t.protocol)&&t.hostname.length>0&&!t.username&&!t.password}function Ze(e){let t=typeof e==`string`?ct.exec(e):null;if(!t)return!1;let[n,r,i,a=0,o=0,s=0,c=0,l=0]=t.slice(1).map(e=>e===void 0?void 0:Number(e)),u=[31,n%4==0&&(n%100!=0||n%400==0)?29:28,31,30,31,30,31,31,30,31,30,31][r-1];return r>=1&&r<=12&&i>=1&&i<=u&&a<=23&&o<=59&&s<=59&&c<=14&&l<=59}function Qe(e){return typeof e==`string`&&/^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/.test(e)}function $e(e){if(!Ye(e))throw Error(`Choose a valid table.`);return[e.columns.map(lt).join(`,`),...e.rows.map(t=>e.columns.map(e=>lt(t[e])).join(`,`))].join(`\r
9
- `)}var et,tt,nt,rt,it,at,ot,st,ct,lt,ut=o((()=>{et=e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),tt=new Set([`__proto__`,`prototype`,`constructor`]),nt=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,rt=Object.freeze({fileName:255,documentText:1e6,documentTitle:300,tableColumns:500,tableRows:1e5,tableCells:5e5,columnName:160,cellText:1e5,url:8192}),it=Object.freeze({pdf:`application/pdf`,txt:`text/plain`,csv:`text/csv`,md:`text/markdown`,json:`application/json`,zip:`application/zip`}),at=Object.freeze([...new Set(Object.values(it))]),ot=Object.freeze([`markdown`,`plain`]),st=e=>e===null||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e)||typeof e==`string`&&e.length<=rt.cellText,ct=/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(?:Z|[+-](\d{2}):(\d{2}))?)?$/,lt=e=>{let t=e==null?``:String(e);return/[",\r\n]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t}})),dt=o((()=>{Object.freeze({origins:8,requestBytes:4194304,responseBytes:8388608,timeoutMs:3e4,redirects:3,headers:32,headerBytes:16384,urlLength:8192,requestsPerMinute:120,originRequestsPerMinute:3e3,keyLength:4096}),Object.freeze([`GET`,`HEAD`,`POST`,`PUT`,`PATCH`,`DELETE`]),Object.freeze([`bearer`,`header`,`query`,`oauth2`]),Object.freeze({sockets:4,messageBytes:1048576,runBytes:268435456,protocols:8})})),ft=o((()=>{Object.freeze([`media.saved`,`schedule`,`webhook`,`project.completed`,`provider`]),Object.freeze({triggers:4,labelLength:120,minEverySeconds:60,maxEverySeconds:31536e3}),Object.freeze([`recipe`,`javascript`,`capability`])})),pt=o((()=>{Object.freeze({features:24,id:48,label:40,does:160,asks:8,ask:80})}));function mt(e,t=0,n={nodes:0}){if(B(t<=40&&++n.nodes<=5e5,`LIMIT`,`Document exceeds complexity limit`),!(e===null||[`string`,`boolean`].includes(typeof e))){if(typeof e==`number`){B(Number.isFinite(e),`SCHEMA`,`Numbers must be finite`);return}B(Array.isArray(e)||vt(e),`SCHEMA`,`Only JSON data is accepted`);for(let[r,i]of Object.entries(e))B(!Tt.has(r),`SCHEMA`,`Forbidden field: ${r}`),mt(i,t+1,n)}}function ht(e){mt(e);let t=e=>Array.isArray(e)?e.map(t):vt(e)?Object.fromEntries(Object.keys(e).sort().map(n=>[n,t(e[n])])):e;return JSON.stringify(t(e))}async function gt(e){let t=new TextEncoder().encode(ht(e)),n=await globalThis.crypto.subtle.digest(`SHA-256`,t);return Array.from(new Uint8Array(n),e=>e.toString(16).padStart(2,`0`)).join(``)}function _t(e,t){if(typeof t==`object`&&t&&t.schema!=null&&!ce(e,t.schema))return!1;let n=typeof t==`string`?t:t.type;if(n===`object`)try{return mt(e),vt(e)}catch{return!1}if(n?.endsWith(`[]`))return Array.isArray(e)&&e.every(e=>_t(e,n.slice(0,-2)));if(n===`text`)return typeof e==`string`&&e.length<=1e6;if(n===`boolean`)return typeof e==`boolean`;if(n===`url`)return Xe(e);if(n===`date`)return Ze(e);if(n===`color`)return Qe(e);if(n===`file`)return qe(e);if(n===`document`)return Je(e);if(n===`table`)try{return mt(e),Ye(e)}catch{return!1}if(n===`number`||n===`integer`)return typeof e==`number`&&Number.isFinite(e)&&(n!==`integer`||Number.isInteger(e))&&(t.min==null||e>=t.min)&&(t.max==null||e<=t.max);if(n===`file-bundle`)try{return mt(e),M(e)}catch{return!1}if(n===`workspace-edit`)try{return mt(e),we(e)}catch{return!1}if(n===`timeline-edit`)try{return mt(e),je(e)}catch{return!1}if(n===`timeline-range`||n===`approval`)return vt(e)&&e.schemaVersion===1?!0:n===`timeline-range`?he(e):ge(e);if(n===`json`)try{return mt(e),!0}catch{return!1}return n===`image`&&vt(e)&&Array.isArray(e.data)?Number.isInteger(e.width)&&Number.isInteger(e.height)&&e.width>0&&e.height>0&&e.width*e.height<=1048576&&e.data.length===e.width*e.height*4&&e.data.every(e=>Number.isInteger(e)&&e>=0&&e<=255):[`image`,`video`,`audio`,`asset`].includes(n)?vt(e)&&typeof e.assetId==`string`&&typeof e.versionId==`string`&&(n===`asset`||e.kind===n):yt.includes(n)&&vt(e)&&e.schemaVersion===1}var B,vt,yt,bt,xt,St,Ct,wt,Tt,Et=o((()=>{k(),R(),ae(),ue(),fe(),pe(),me(),be(),xe(),Ce(),De(),Ue(),Ge(),Ke(),ut(),dt(),ft(),pt(),B=ne,vt=re,Object.freeze([`type`,`required`,`default`,`min`,`max`,`description`,`role`,`primary`,`context`,`imageMode`,...le]),yt=Object.freeze(`text.number.integer.boolean.json.object.image.video.audio.asset.script.transcript.brief.bible.shot-plan.panel-document.board-document.scene-document.timeline.timeline-edit.file-bundle.workspace-edit.timeline-range.research.character.location.style.pipeline.approval.scene.shot.mask.depth.pose.metadata.project-context.file.document.table.url.date.color`.split(`.`)),Object.freeze([`final.render`,`stock.search`,`stock.select`,`stock.auto`,`gif.search`,`gif.save`,`presenter.generate`,`quality.analyze`,`image.generate`,`image.generate.batch`,`media.generate`,`youtube.upload`]),Object.freeze([`text`,`number`,`slider`,`checkbox`,`asset`,`select`,`multiselect`,`file`,`date`,`color`,`url`,`richtext`,`list`,`grid`]),Object.freeze([`gallery`,`before-after`,`table`,`document`,`chart`,`code`,`player`,`download`]),Object.freeze({file:[`file`,`file[]`],date:[`date`],color:[`color`],url:[`url`],richtext:[`document`,`text`],list:[`text[]`,`number[]`,`integer[]`,`url[]`,`date[]`,`color[]`],grid:[`table`]}),Object.freeze({gallery:[`image[]`],"before-after":[`image`],table:[`table`],document:[`document`,`text`],chart:[`table`,`number[]`,`integer[]`],code:[`text`,`json`,`object`],player:[`audio`,`video`,`audio[]`,`video[]`],download:[`file`,`file[]`,`file-bundle`]}),bt=Object.freeze({script:`script`,transcript:`transcript`,shots:`shot[]`,shotPlan:`shot-plan`,scenes:`scene[]`,characters:`character[]`,locations:`location[]`,styles:`style[]`,assets:`asset[]`,files:`file[]`,generations:`metadata[]`,versions:`metadata[]`,timeline:`timeline`,editor:`timeline`,canvas:`pipeline`,blueprint:`bible`,panels:`panel-document`,board:`board-document`,animation:`scene-document`,metadata:`metadata`}),xt=(e,t,n,r)=>Object.freeze({executor:e,mode:t,byok:n,summary:r}),St=Object.freeze({"text.generate":xt(`capability-run`,`sync`,!0,`Exact model, account BYOK or credits, and explicit run review`),"audio.speech":xt(`capability-run`,`sync`,!0,`One short text/script input to measured audio in any StillMade catalog voice (Deepgram, ElevenLabs, OpenAI, Kokoro) with credits, or OpenAI with your key; playback review; accepted project recordings can be explicitly added to Editor audio`),"audio.transcribe":xt(`capability-run`,`sync`,!0,`One owner-scoped stored audio asset to reviewed text and ordered word timings with StillMade transcription on credits, or OpenAI Whisper with your key`),"audio.music":xt(`capability-run`,`sync`,!1,`One prompt to generated music (5–240 seconds) with StillMade credits and playback review`),"audio.sfx":xt(`capability-run`,`sync`,!1,`One prompt to a generated sound effect (0.5–22 seconds) with StillMade credits and playback review`),"image.generate":xt(`capability-run`,`sync`,!0,`One prompt and optional reference images to a stored PNG with any catalog image model and its settings; StillMade credits or account key, and actual image review`),"video.generate":xt(`capability-run`,`async`,!0,`One prompt and optional first/last frames to a measured stored video clip with any catalog video model and its settings; StillMade credits and actual video review`),"image.describe":xt(`capability-run`,`sync`,!0,`One to four owned images to bounded production notes; host-selected model/payment and actual description review`),"media.analyze":xt(`capability-run`,`sync`,!1,`One owned video (optionally one time range), image or up to four images to structured visual evidence: summary, timeline, observations, on-screen text and issues, with StillMade credits; detail "check" gives one to four photos a short answer each at one price per call`),"web.fetch":xt(`capability-run`,`sync`,!1,`One public web page read by the host and answered against the Block's instruction, with StillMade credits; no cookies, keys or private addresses`),"web.research":xt(`capability-run`,`sync`,!1,`One topic searched on the web and summarized with cited sources, with StillMade credits`),"timeline.propose":xt(`capability-run`,`sync`,!0,`Bounded typed context to strict timeline-edit JSON; host-selected model/payment, stale-before checks, preview and Apply`),"workspace.propose":xt(`capability-run`,`sync`,!0,`Bounded typed context to a strict workspace-edit proposal for one permitted workspace; preview and explicit Apply`),"connection.execute":xt(`connection`,`sync`,!1,`One reviewed action on a connected third-party app account through the host connection service; the Block never receives account credentials`)}),Ct=e=>Object.freeze(Object.entries(St).filter(([,t])=>e(t)).map(([e])=>e)),Ct(()=>!0),wt=Ct(e=>e.executor===`capability-run`),Ct(e=>e.executor===`capability-run`&&e.mode===`sync`),Ct(e=>e.byok),[...Object.keys(bt).map(e=>`context.${e}.read`)],Tt=new Set([`__proto__`,`prototype`,`constructor`])}));Et();var Dt=Object.freeze([`tasks`,`preview-task`,`apply-task`]);function Ot(e,t={}){return B(Dt.includes(e),`CONNECTION_TASK`,`Choose a declared task operation.`),mt(t),B(vt(t)&&JSON.stringify(t).length<=32768,`CONNECTION_TASK`,`Use bounded task selection arguments.`),{operation:e,args:structuredClone(t)}}function kt(e,t,n,r){let i=0,a=new Map;return addEventListener(`message`,n=>{let r=n.data;if(n.source!==parent||!r||r.channel!==e||r.session!==t||r.op!==`connected-app-result`)return;let i=a.get(r.id);i&&(a.delete(r.id),r.error?i.reject(Error(r.error)):i.resolve(r.result))}),{connectedApp(o,s={}){if(!n)return Promise.reject(Error(`This Block has no connected-app task contract.`));if(![`tasks`,`preview-task`,`apply-task`].includes(o)||!s||typeof s!=`object`||Array.isArray(s)||JSON.stringify(s).length>32768)return Promise.reject(Error(`Invalid task choice.`));if(a.size>=2)return Promise.reject(Error(`Wait for the current task choice.`));let c=String(++i);return new Promise((n,i)=>{a.set(c,{resolve:n,reject:i}),r({channel:e,session:t,op:`connected-app-request`,id:c,operation:o,args:s},`*`)})}}}function At(e,t,n,r){let i=new Set,a=new Set,o=new Set,s=(e,t)=>{if(typeof t!=`function`)throw TypeError(`Pass a function.`);return e.add(t),()=>{e.delete(t)}},c=e=>{typeof reportError==`function`&&reportError(e)},l=(e,...t)=>{for(let n of[...e])try{n(...t)}catch(e){c(e)}};return{live:Object.freeze({start:(e={})=>r(`live.start`,e),stop:()=>r(`live.stop`,{}),status:()=>r(`live.status`,{}),onFrame:e=>s(i,e),onAudio:e=>s(a,e),onEnd:e=>s(o,e)}),receive:r=>{if(r.op!==`live`)return!1;if(r.type===`frame`)try{l(i,r.bitmap,{index:r.index,timestamp:r.timestamp,width:r.width,height:r.height})}finally{try{r.bitmap?.close?.()}catch{}n({channel:e,session:t,op:`live-ack`},`*`)}else r.type===`audio`?l(a,r.samples,{index:r.index,timestamp:r.timestamp,sampleRate:r.sampleRate}):r.type===`ended`&&l(o,{reason:String(r.reason||`stopped`)});return!0},dispose(){i.clear(),a.clear(),o.clear()}}}function jt(e){let t=0,n=null,r=[],i=0,a=new Map,o=()=>{if(n||!r.length)return;let s=r.shift();n=s,Promise.resolve().then(()=>{if(s.generation!==t)throw Error(`Preview input changed`);return s.edge===void 0?e(s.kind,s.value):e(s.kind,s.value,{edge:s.edge})}).then(e=>{s.kind===`image`&&s.generation===t&&(a.delete(s.serialized),a.set(s.serialized,e),a.size>48&&a.delete(a.keys().next().value)),s.resolve(e)},s.reject).finally(()=>{n===s&&(n=null,i-=s.bytes,o())})};return{request(e,s,c){let l,u,d,f;try{if(![`image`,`media`].includes(e)||!s||Array.isArray(s)||typeof s!=`object`)throw Error(`Expected a bounded preview value`);if(d=c?.edge,d!==void 0&&(e!==`image`||!Number.isInteger(d)||d<64||d>2048))throw Error(`Ask for an image preview edge from 64 to 2048 pixels, as in StillMade.previewImage(photo, {edge: 2048}).`);if(f=JSON.stringify(s),l=d===void 0?f:`${f}@${d}`,u=new TextEncoder().encode(f).length,u>4194304)throw Error(`Expected a bounded preview value`)}catch(e){return Promise.reject(e)}if(e===`image`&&a.has(l))return Promise.resolve(a.get(l));let p=e===`image`&&[n,...r].find(t=>t?.kind===e&&t.serialized===l);if(p)return p.promise;if(r.length+ +!!n>=64||i+u>8388608)return Promise.reject(Error(`Too many queued previews. Wait for a preview to finish.`));let m={kind:e,value:JSON.parse(f),serialized:l,bytes:u,generation:t,edge:d};return m.promise=new Promise((e,t)=>{m.resolve=e,m.reject=t}),i+=u,r.push(m),o(),m.promise},reset(e=`Preview input changed`){t+=1;for(let t of[n,...r])t&&t.reject(Error(e));n=null,r=[],i=0}}}function Mt(){return null}function Nt(){try{return typeof indexedDB<`u`&&indexedDB!==null}catch{return!1}}function Pt(){return Ht||(Ht=new Promise((e,t)=>{let n;try{n=indexedDB.open(It,Lt)}catch(e){t(e);return}n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(`cacheMeta`)||e.createObjectStore(Rt,{keyPath:`key`}),e.objectStoreNames.contains(`blobs`)||e.createObjectStore(zt),e.objectStoreNames.contains(`handles`)||e.createObjectStore(Bt),e.objectStoreNames.contains(`deviceMedia`)||e.createObjectStore(Vt,{keyPath:`id`})},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),Ht=null},e(t)},n.onerror=()=>t(n.error||Error(`indexedDB open failed`)),n.onblocked=()=>t(Error(`indexedDB blocked`))}),Ht.catch(()=>{Ht=null}),Ht)}function Ft(e,t,n){return Pt().then(r=>new Promise((i,a)=>{let o;try{o=r.transaction(e,t)}catch(e){a(e);return}let s;try{s=n(o.objectStore(e))}catch(e){a(e);return}o.oncomplete=()=>i(s?s.result:void 0),o.onerror=()=>a(o.error||Error(`idb tx error`)),o.onabort=()=>a(o.error||Error(`idb tx aborted`))}))}var It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt=o((()=>{It=`aivw_editor`,Lt=2,Rt=`cacheMeta`,zt=`blobs`,Bt=`handles`,Vt=`deviceMedia`,Ht=null,Ut=(e,t)=>Ft(e,`readonly`,e=>e.get(t)),Wt=e=>Ft(e,`readonly`,e=>e.getAll()),Gt=(e,t,n)=>Ft(e,`readwrite`,e=>n===void 0?e.put(t):e.put(t,n)),Kt=(e,t)=>Ft(e,`readwrite`,e=>e.delete(t))}));function Jt(){try{return typeof localStorage>`u`?null:JSON.parse(localStorage.getItem(Yt)||`null`)?.user?.id||null}catch{return null}}var Yt,Xt=o((()=>{Yt=`ai-video-workflow-auth`}));function Zt(){let e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),t=new Uint32Array(64),n=new Uint8Array(64),r=0,i=0,a=(n,r)=>{for(let e=0;e<16;e++)t[e]=n[r+e*4]<<24|n[r+e*4+1]<<16|n[r+e*4+2]<<8|n[r+e*4+3];for(let e=16;e<64;e++){let n=en(t[e-15],7)^en(t[e-15],18)^t[e-15]>>>3,r=en(t[e-2],17)^en(t[e-2],19)^t[e-2]>>>10;t[e]=t[e-16]+n+t[e-7]+r>>>0}let i=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=e[5],u=e[6],d=e[7];for(let e=0;e<64;e++){let n=en(c,6)^en(c,11)^en(c,25),r=c&l^~c&u,f=d+n+r+$t[e]+t[e]>>>0,p=(en(i,2)^en(i,13)^en(i,22))+(i&a^i&o^a&o)>>>0;d=u,u=l,l=c,c=s+f>>>0,s=o,o=a,a=i,i=f+p>>>0}e[0]=e[0]+i>>>0,e[1]=e[1]+a>>>0,e[2]=e[2]+o>>>0,e[3]=e[3]+s>>>0,e[4]=e[4]+c>>>0,e[5]=e[5]+l>>>0,e[6]=e[6]+u>>>0,e[7]=e[7]+d>>>0};return{update(e){let t=e instanceof Uint8Array?e:new Uint8Array(e);i+=t.length;let o=0;if(r){let e=Math.min(64-r,t.length);if(n.set(t.subarray(0,e),r),r+=e,o=e,r<64)return this;a(n,0),r=0}for(;o+64<=t.length;o+=64)a(t,o);return o<t.length&&(n.set(t.subarray(o),0),r=t.length-o),this},digest(){let t=i*8,o=new Uint8Array(r<56?64:128);o.set(n.subarray(0,r)),o[r]=128;let s=new DataView(o.buffer);s.setUint32(o.length-8,Math.floor(t/4294967296)),s.setUint32(o.length-4,t>>>0);for(let e=0;e<o.length;e+=64)a(o,e);return[...e].map(e=>e.toString(16).padStart(8,`0`)).join(``)}}}async function Qt(e,{subtleLimit:t=tn,signal:n}={}){if(e.size<=t&&typeof crypto?.subtle?.digest==`function`){let t=await crypto.subtle.digest(`SHA-256`,await e.arrayBuffer());return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}let r=Zt();for(let t=0;t<e.size;t+=nn)n?.throwIfAborted?.(),r.update(new Uint8Array(await e.slice(t,t+nn).arrayBuffer()));return r.digest()}var $t,en,tn,nn,rn=o((()=>{$t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),en=(e,t)=>e>>>t|e<<32-t,tn=67108864,nn=8388608}));function an(){if(Fn!==void 0)return Fn;try{return Jt()||null}catch{return null}}async function on(){if(Nn!==void 0)return Nn;try{Nn=navigator?.storage?.getDirectory?await(await navigator.storage.getDirectory()).getDirectoryHandle(xn,{create:!0}):null}catch{Nn=null}return Nn}async function sn(){if(!Pn){Pn=!0;try{await navigator?.storage?.persist?.()}catch{}}}async function cn(e,t){let n=await on();if(n){let r=await(await n.getFileHandle(t,{create:!0})).createWritable();return await r.write(e),await r.close(),`opfs`}return await Gt(zt,e,`device:${t}`),`idb`}function ln(){try{window.dispatchEvent(new CustomEvent(Mn,{detail:{needed:jn.size}}))}catch{}}async function un(e){let t=Bn(e);if(typeof t?.getFile!=`function`)throw zn(`DEVICE_MEDIA_MOVED`,`This file is no longer linked on this computer.`);if(typeof t.queryPermission==`function`&&await t.queryPermission({mode:`read`})!==`granted`)throw jn.has(e.id)||(jn.set(e.id,t),ln()),zn(`DEVICE_MEDIA_ACCESS`,`Allow StillMade to open this file on your computer again.`);let n;try{n=await t.getFile()}catch{throw zn(`DEVICE_MEDIA_MOVED`,`This file was moved, renamed or deleted on this computer.`)}if(n.size!==e.bytes||e.lastModified&&n.lastModified!==e.lastModified)throw zn(`DEVICE_MEDIA_CHANGED`,`This file changed on this computer after it was added.`);return n}async function dn(e){if(e.storage===`linked`)return un(e);if(e.storage===`opfs`){let t=await on();if(!t)throw Error(`Device storage is unavailable.`);return(await t.getFileHandle(e.versionId)).getFile()}let t=await Ut(zt,`device:${e.versionId}`);if(!t)throw Error(`This media is not on this device.`);return t}function fn(){return Nt()&&typeof crypto?.subtle?.digest==`function`}async function pn(e,{kind:t,metadata:n={},role:r=`original`,links:i={},assetId:a=crypto.randomUUID(),signal:o,maxBytes:s=Sn,handle:c=null}={}){if(!fn())throw Error(`This browser cannot keep media on the device.`);if(!c&&e.size>s)throw Error(`Files over ${Math.round(s/1024/1024)>=1024?`${Math.round(s/1024/1024/1024*10)/10} GB`:`${Math.round(s/1024/1024)} MB`} stay where they are; use StillMade Desktop for larger media.`);o?.throwIfAborted?.(),await sn();let l=await Ln(e,o);o?.throwIfAborted?.();let u=await Wt(Vt).then(e=>e.find(e=>e.versionId===l&&e.kind===t)).catch(()=>null),d=c?`linked`:[`opfs`,`idb`].includes(u?.storage)?u.storage:await cn(e,l);o?.throwIfAborted?.(),c&&An.set(l,c);let f={id:`${a}:${l}`,assetId:a,versionId:l,kind:t,role:r,name:String(e.name||``).slice(0,240),mimeType:e.type||n.mimeType||``,bytes:e.size,...Vn(n,[`width`,`height`,`duration`]),storage:d,...c?{handle:c,lastModified:e.lastModified}:{},source:`local`,...i,...an()?{owner:an()}:{},cloud:{},createdAt:Date.now()};return await Gt(Vt,f),f}async function mn(e){if(!e?.assetId||!e?.versionId)return null;let t=await Ut(`deviceMedia`,Rn(e)).catch(()=>null)||null;return t&&In(t)?t:null}async function hn(e,t=Hn.get(Tn(e))){if(!t)return null;let n=e=>fetch(t,{credentials:`omit`,redirect:`follow`,referrerPolicy:`no-referrer`,...e?{cache:e}:{}}),r;try{r=await n()}catch(e){if(!(e instanceof TypeError))return null;try{r=await n(`reload`)}catch{return null}}if(!r?.ok)return null;let i=await r.blob();return await Ln(i)===e.versionId?i:null}async function gn(e){let t=await mn(e);if(t)return dn(t);let n=await hn(e).catch(()=>null);if(!n)throw Error(`This media is not on this device.`);return n}async function _n(e){let t=Rn(e);if(On.has(t))return On.get(t);let n=URL.createObjectURL(await gn(e));return On.set(t,n),kn.add(n),n}async function vn(e){let t=En(e);if(!t)return null;try{return await _n(t)}catch{return null}}function yn(e,{role:t,name:n}={}){let r={kind:e.kind,assetId:e.assetId,versionId:e.versionId,url:Tn(e),source:`local`,name:n||e.name,mimeType:e.mimeType,bytes:e.bytes};for(let t of[`width`,`height`,`duration`])e[t]!==void 0&&e[t]!==null&&(r[t]=e[t]);return t&&(r.role=t),r}async function bn(){let e=(await Wt(Vt).catch(()=>[])).filter(e=>e.storage!==`linked`),t=new Set,n=e.reduce((e,n)=>t.has(n.versionId)?e:(t.add(n.versionId),e+(n.bytes||0)),0),r=null;try{r=(await navigator.storage.estimate()).quota||null}catch{}return{files:t.size,bytes:n,quota:r}}var xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un=o((()=>{qt(),Xt(),rn(),xn=`device-media`,Sn=268435456,Cn=`sm-media://device/`,wn=/^sm-media:\/\/device\/([a-f0-9-]{36})\/([a-f0-9]{64})$/,Tn=e=>`${Cn}${e.assetId}/${e.versionId}`,En=e=>{let t=wn.exec(String(e||``));return t?{assetId:t[1],versionId:t[2]}:null},Dn=e=>wn.test(String(e||``)),On=new Map,kn=new Set,An=new Map,jn=new Map,Mn=`stillmade:device-media-access`,Pn=!1,In=e=>{let t=an();return!e?.owner||!t||e.owner===t},Ln=(e,t)=>Qt(e,{signal:t}),Rn=e=>`${e.assetId}:${e.versionId}`,zn=(e,t)=>Object.assign(Error(t),{code:e}),Bn=e=>An.get(e.versionId)||e.handle,Vn=(e,t)=>Object.fromEntries(t.filter(t=>e?.[t]!==void 0&&e[t]!==null).map(t=>[t,e[t]])),Hn=new Map}));Un();var Wn=Object.freeze({bytes:25165824,timeoutMs:15e3}),Gn=Object.freeze({image:[`image/png`,`image/jpeg`,`image/webp`,`image/gif`],video:[`video/mp4`,`video/webm`,`video/ogg`,`video/quicktime`],audio:[`audio/mpeg`,`audio/mp3`,`audio/mp4`,`audio/aac`,`audio/ogg`,`audio/wav`,`audio/x-wav`,`audio/wave`,`audio/webm`,`audio/flac`]});function Kn(e){if(!e||!Gn[e.kind]?.includes(e.blob?.type)||!(e.blob instanceof Blob)||!e.blob.size||!e.local&&e.blob.size>Wn.bytes)throw Error(`The host returned an unsupported or oversized media preview.`);return{kind:e.kind,blob:e.blob,...e.local===!0?{local:!0}:{}}}var qn=/^\/api\/media\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-][A-Za-z0-9._-]*$/;async function Jn(e,{signal:t,check:n=()=>{}}={}){if(n(),Dn(e.url)){let t=En(e.url),r=await mn(t);if(n(),!r)throw Error(`This media is not on this device. Open the project on the device that holds it.`);let i=await gn(t);n();let a=String(r.mimeType||i.type||``).split(`;`)[0].trim().toLowerCase();if(!Gn[e.kind]?.includes(a))throw Error(`Choose a supported audio or video file.`);return Kn({kind:e.kind,blob:i.type===a?i:new Blob([i],{type:a}),local:!0})}let r=n=>fetch(e.url,{signal:t,credentials:`omit`,redirect:qn.test(e.url)?`follow`:`error`,referrerPolicy:`no-referrer`,...n?{cache:n}:{}}),i;try{i=await r()}catch(a){if(a?.name===`AbortError`||!(a instanceof TypeError))throw a;n();try{i=await r(`no-store`)}catch(r){if(r?.name===`AbortError`||!(r instanceof TypeError))throw r;let a=Error(`This media could not reach StillMade. Check your connection and try again.`);if(!qn.test(e.url))throw a;n();try{i=await fetch(e.url.replace(/^\/api\/media\//,`/api/media/bytes/`),{signal:t,credentials:`omit`,redirect:`error`,referrerPolicy:`no-referrer`,cache:`no-store`})}catch(e){throw e?.name===`AbortError`?e:a}if(i.status===413)throw Error(`This media is too large to preview here. Download it to play it.`)}}if(n(),!i.ok)throw Error(`This media could not be loaded. Upload a local copy to preview it.`);let a=(i.headers.get(`content-type`)||``).split(`;`)[0].trim().toLowerCase();if(!Gn[e.kind]?.includes(a))throw Error(`Choose a supported audio or video file.`);if(Number(i.headers.get(`content-length`))>Wn.bytes)throw Error(`Preview media must be under 24 MB.`);if(!i.body?.getReader)throw Error(`Streaming media previews are unavailable in this browser.`);let o=i.body.getReader(),s=[],c=0;try{for(;;){if(n(),t?.aborted)throw new DOMException(`Media preview cancelled`,`AbortError`);let{done:e,value:r}=await o.read();if(n(),e)break;if(c+=r.byteLength,c>Wn.bytes)throw Error(`Preview media must be under 24 MB.`);s.push(r)}return Kn({kind:e.kind,blob:new Blob(s,{type:a})})}finally{await o.cancel().catch(()=>{}),o.releaseLock()}}var Yn=/^\/(sfx\/pops|sounds\/fx)\/[a-z0-9_-]{1,64}\.(wav|mp3)$/i;function Xn(e){if(typeof e!=`string`||e.length>512)return null;let t=/^https?:\/\/[^/]+(\/[^?#]*)$/.exec(e)?.[1]??(e.startsWith(`/`)?e.split(/[?#]/)[0]:null);return t&&Yn.test(t)?t:null}var Zn=e=>!!e&&e.kind===`audio`&&e.assetId===`stillmade-sound`&&typeof e.url==`string`&&Xn(e.url)===e.url&&e.versionId===e.url,Qn=new Set;function $n(e){return Qn.add(e),()=>Qn.delete(e)}function er(e,t,n,r=null,i=[]){let a=new Map,o=[`text`,`search`,`email`,`tel`,`url`],s=new Set(i),c=new Map,l=new Set,u=new Map,d=!1,f={},p=(e,t,n)=>e?e.some(e=>e.value===String(n)):t.tagName!==`SELECT`||[...t.options].some(e=>e.value===String(n)),m=(e,t)=>{if(clearTimeout(t.timer),c.delete(e),d)return;let r;return r=Promise.resolve().then(()=>{if(!d)return t.callback()}).catch(t=>{u.set(e,t),n(t.message)}).finally(()=>l.delete(r)),l.add(r),r},h=(e,t)=>{if(d)throw Error(`This interface has closed; shared edits stopped.`);if(typeof e!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(e))throw Error(`A shared edit key starts with a letter and holds only letters, digits, - and _ (up to 100 characters).`);if(typeof t!=`function`)throw Error(`Give scheduleSharedEdit a function to run.`);if(!c.has(e)&&c.size+l.size>=32||!u.has(e)&&u.size>=32)throw Error(`Too many scheduled shared edits`);u.delete(e);let n=c.get(e),r={callback:t,started:n?.started??Date.now(),timer:null};n&&clearTimeout(n.timer),r.timer=setTimeout(()=>m(e,r),Math.max(0,Math.min(150,500-(Date.now()-r.started)))),c.set(e,r)},g=(i,c)=>{if(!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(i)||a.has(i))throw Error(`Use one control per named shared field`);let l=e.getElementById(c),u=l?.tagName===`FIELDSET`?[...l.querySelectorAll(`input[type="radio"]`)]:null;if(!l||![`INPUT`,`TEXTAREA`,`SELECT`,`FIELDSET`].includes(l.tagName)||u&&!u.length||l.tagName===`INPUT`&&![`text`,`search`,`email`,`tel`,`url`,`number`,`range`,`checkbox`,`color`].includes(l.type))throw Error(`Bind an existing text, number, checkbox or select control, or a fieldset of radio buttons`);if(s.has(i)){let e=l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type),t=l.disabled,n=l.readOnly,r=l.getAttribute(`title`),s=l.getAttribute(`aria-readonly`),c=l.getAttribute(`aria-disabled`);e?(l.readOnly=!0,l.setAttribute(`aria-readonly`,`true`)):(l.disabled=!0,l.setAttribute(`aria-disabled`,`true`)),l.setAttribute(`title`,`Connected input. Change its source in Flow.`);let u={flush:async()=>{},status:()=>({dirty:!1,saving:!1,problem:null,canEdit:!1,composing:!1,interrupted:!1}),setDefault(){},dispose(){l.disabled=t,l.readOnly=n,r===null?l.removeAttribute(`title`):l.setAttribute(`title`,r),s===null?l.removeAttribute(`aria-readonly`):l.setAttribute(`aria-readonly`,s),c===null?l.removeAttribute(`aria-disabled`):l.setAttribute(`aria-disabled`,c),a.delete(i)}};return a.set(i,u),u.dispose}if(r&&(l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type))){let e=r.bind(i,l),t=e.dispose;return e.dispose=()=>{t(),a.delete(i)},a.set(i,e),e.dispose}let d=l.disabled,m={exists:!1},h,g=!1,_=!1,v=null,y=!1,b=!1,x=null,S=null,C=null,w=!1,T=!1,E,D=l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type),O=e=>{S=e,l.setCustomValidity(e.message),n(e.message)},k=()=>u.find(e=>e.checked)?.value??``,A=e=>{let n=u?k():l.type===`checkbox`?l.checked:l.value;if(u)for(let t of u)t.checked=t.value===String(e??``);else l.type===`checkbox`?l.checked=!!e:l.value!==String(e??``)&&(l.value=String(e??``));(u?k():l.type===`checkbox`?l.checked:l.value)!==n&&queueMicrotask(()=>{y||t.announce?.()})},j=()=>u?k():l.type===`checkbox`?l.checked:[`number`,`range`].includes(l.type)?l.valueAsNumber:l.value,M=Object.hasOwn(f,i)&&p(u,l,f[i])?f[i]:j(),N=()=>{if(clearTimeout(v),v=null,_)return x;if(y||w||!g||!b||S)return;let e=h;g=!1,C=null,_=!0;let n=!1;return x=Promise.resolve().then(()=>t.updateShared({[i]:e},{[i]:m})).then(()=>{m={exists:!0,value:e},l.setCustomValidity(``),!S&&g&&Object.is(h,e)&&(g=!1,C=null)},e=>{n=!0,g=!0,O(e)}).finally(()=>{_=!1,x=null,!y&&!n&&g&&h!==e&&P(),!y&&!g&&ee(t.getShared())}),x},P=()=>{clearTimeout(v),v=setTimeout(N,Math.max(0,Math.min(150,500-(Date.now()-(C??Date.now())))))},F=()=>{!y&&D&&b&&!d&&(w=!0,clearTimeout(v),v=null)},I=e=>{if(y||!b||d)return;if(D&&e?.isComposing){F();return}if(w)return;let t=j();if(typeof t==`number`&&!Number.isFinite(t)){O(Error(`Enter a finite number`));return}E!==void 0&&Object.is(t,E)||(E=void 0,(S||!Object.is(t,g||_?h:m.exists?m.value:M))&&((S||C===null)&&(C=Date.now()),h=t,S=null,g=!0,P()))},ee=e=>{y||(b=e.canEdit,l.disabled=d||!b,!b&&w&&(T=!0),!b&&(g||w)&&O(Error(`Editing access changed. Your unsaved draft has been preserved.`)),!(w||g||_||S)&&(m=Object.hasOwn(e.state,i)?{exists:!0,value:e.state[i]}:{exists:!1},A(m.exists?m.value:M)))},te=t.onShared(ee),L=()=>{if(!y&&w){if(w=!1,!b||T){T=!1,h=j(),E=h,g=!0,O(Error(`Editing access changed. Your unsaved draft has been preserved.`));return}I(),g&&!_&&!S?(C=Date.now(),P()):!g&&!_&&!S&&ee(t.getShared())}};l.disabled=d||!t.getShared().canEdit;let R=u?`focusout`:`blur`;l.addEventListener(`input`,I),l.addEventListener(`change`,I),l.addEventListener(R,N),l.addEventListener(`compositionstart`,F),l.addEventListener(`compositionend`,L);let ne=()=>{y=!0,w=!1,clearTimeout(v),te(),l.removeEventListener(`input`,I),l.removeEventListener(`change`,I),l.removeEventListener(R,N),l.removeEventListener(`compositionstart`,F),l.removeEventListener(`compositionend`,L),l.disabled=d,a.delete(i)};return a.set(i,{dispose:ne,flush:N,status(){return{dirty:g,saving:_,problem:S,canEdit:b,composing:w,interrupted:E!==void 0}},setDefault(e){M=e,ee(t.getShared())},setInputDefault(e){p(u,l,e)&&this.setDefault(e)}}),ne},_=new Map,v=new Map,y=new WeakSet,b=[`text`,`search`,`email`,`tel`,`url`,`number`,`range`,`checkbox`,`color`],x=/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/,S=/(?:password|secret|credential|authorization|cookie|token|api[_-]?key|private[_-]?key)/i,C=/^(?:current-password|new-password|one-time-code|cc-)/i,w=null,T=null,E=e=>{let t=_.get(e);if(t!==void 0){_.delete(e),v.delete(t);try{a.get(t)?.dispose()}catch{}a.delete(t)}},D=(t,n)=>{let r=e.getElementById(n);r&&_.has(r)&&E(r),v.has(t)&&E(v.get(t));let i=g(t,n);return r&&y.add(r),i},O=e=>{let t=e.getAttribute(`data-stillmade-share`)||e.getAttribute(`name`)||e.id||(e.tagName===`FIELDSET`?e.querySelector(`input[type="radio"][name]`)?.getAttribute(`name`):``)||``;return x.test(t)?t:null},k=e=>!e.isConnected||e.closest(`[data-stillmade-local]`)?!1:e.tagName===`FIELDSET`?!!e.querySelector(`input[type="radio"]`)&&!e.querySelector(`fieldset`):e.tagName===`INPUT`?b.includes(e.type):e.tagName===`TEXTAREA`||e.tagName===`SELECT`,A=t=>{if(y.has(t)||_.has(t)||!k(t))return;let n=O(t);if(!(!n||a.has(n)||a.size>=100)&&!(!t.hasAttribute(`data-stillmade-share`)&&(S.test(n)||S.test(t.getAttribute(`name`)||``)||S.test(t.id||``)||C.test(t.getAttribute(`autocomplete`)||``)))){if(!t.id){let r=`sm-shared-${n}`,i=1;for(;e.getElementById(r);)r=`sm-shared-${n}-${++i}`;t.id=r}else if(e.getElementById(t.id)!==t)return;try{g(n,t.id),_.set(t,n),v.set(n,t)}catch{a.delete(n)}}},j=()=>{if(T=null,!(d||M))try{for(let e of[..._.keys()])(!e.isConnected||e.closest(`[data-stillmade-local]`))&&E(e);for(let t of e.querySelectorAll(`input,textarea,select,fieldset`))A(t)}catch(e){n(e.message)}},M=!1,N=()=>{if(!M){M=!0,w?.disconnect(),w=null,T&&=(clearTimeout(T),null);for(let e of[..._.keys()])E(e)}},P=()=>{M||d||w||typeof MutationObserver!=`function`||!e.documentElement||(j(),w=new MutationObserver(()=>{!T&&!d&&(T=setTimeout(j,30))}),w.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`name`,`id`,`type`,`data-stillmade-local`,`data-stillmade-share`]}))};e.readyState===`loading`?e.addEventListener?.(`DOMContentLoaded`,P,{once:!0}):typeof setTimeout==`function`&&typeof MutationObserver==`function`&&setTimeout(P,0);let F=()=>{let t=[...e.querySelectorAll(`[data-stillmade-share]`)];if(t.length>100)throw Error(`Use at most 100 shared controls`);for(let n of t){let t=n.getAttribute(`data-stillmade-share`),r=n.id;if(typeof t!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(t)||typeof r!=`string`||!r||r.length>200||e.getElementById(r)!==n)throw Error(`Each data-stillmade-share control needs a unique ID and valid shared field name`);D(t,r)}return t.length},I=()=>{if(d)throw Error(`Block closed before edits could be flushed`);if([...a.values()].some(e=>e.status().composing))throw Error(`Finish composing text before leaving this Block or running an action.`);let e=[...a.values()].find(e=>e.status().interrupted);if(e)throw e.status().problem};return{bindShared:D,bindAnnotated:F,bindAutomatic:P,ownSharing:N,scheduleSharedEdit:h,flushAll:async()=>{if(d)throw Error(`Block closed before edits could be flushed`);for(let e=0;e<32;e++){if(d)throw Error(`Block closed before edits could be flushed`);I();let e=[...l];for(let[t,n]of[...c])e.push(m(t,n));for(let t of a.values())e.push(t.flush());if(await Promise.all(e),d)throw Error(`Block closed before edits could be flushed`);if(u.size)throw u.values().next().value;let t=!1;for(let e of a.values()){let n=e.status();if(n.problem)throw n.problem;if(n.composing)throw Error(`Finish composing text before leaving this Block or running an action.`);if(n.dirty&&!n.canEdit)throw Error(`Editing access changed. Your draft is not saved.`);t||=n.dirty||n.saving}if(!t&&!c.size&&!l.size)return{queued:!0}}throw Error(`Edits are still arriving. Finish editing before leaving this Block.`)},assertNoComposition:I,getBindingStatus:e=>a.get(e)?.status(),setSharedDefaults(e){if(!e||typeof e!=`object`||Array.isArray(e)||Object.keys(e).length>100||JSON.stringify(e).length>65536)throw Error(`Use bounded shared control defaults`);for(let[t,n]of Object.entries(e))a.get(t)?.setDefault(n)},useInputDefaults(e){let t=f;if(f={},e&&typeof e==`object`&&!Array.isArray(e))for(let[t,n]of Object.entries(e))[`string`,`number`,`boolean`].includes(typeof n)&&(f[t]=n);for(let[e,n]of a)if(Object.hasOwn(f,e)&&!(Object.hasOwn(t,e)&&t[e]===f[e]))try{(n.setInputDefault||n.setDefault)?.call(n,f[e])}catch{}},dispose(){d=!0,w?.disconnect(),T&&clearTimeout(T);for(let e of c.values())clearTimeout(e.timer);c.clear();for(let e of[...a.values()])e.dispose()}}}var tr='var StillMadeTextFrame=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let t=()=>new Map,n=e=>{let n=t();return e.forEach((e,t)=>{n.set(t,e)}),n},r=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},i=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},a=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},o=()=>new Set,s=e=>e[e.length-1],c=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},l=Array.from,u=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},d=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},f=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},p=Array.isArray;var m=class{constructor(){this._observers=t()}on(e,t){return r(this._observers,e,o).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,n){return l((this._observers.get(e)||t()).values()).forEach(e=>e(...n))}destroy(){this._observers=t()}};let h=Math.floor,g=Math.abs,_=(e,t)=>e<t?e:t,v=(e,t)=>e>t?e:t;Number.isNaN;let y=e=>e===0?1/e<0:e<0,b=2**53-1,x=-(2**53-1),S=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&h(e)===e);Number.isNaN,Number.parseInt;let C=String.fromCharCode;String.fromCodePoint,C(65535);let w=e=>e.toLowerCase(),T=/^\\s*/g,E=e=>e.replace(T,``),D=/([A-Z])/g,ee=(e,t)=>E(e.replace(D,e=>`${t}${w(e)}`)),O=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},k=typeof TextEncoder<`u`?new TextEncoder:null,A=k?e=>k.encode(e):O,j=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});j&&j.decode(new Uint8Array).length===1&&(j=null);let M=(e,t)=>f(t,()=>e).join(``);var N=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};let te=()=>new N,P=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},F=e=>{let t=new Uint8Array(P(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},ne=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(v(n,t)*2),e.cpos=0)},I=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},re=I,L=(e,t)=>{for(;t>127;)I(e,128|127&t),t=h(t/128);I(e,127&t)},ie=(e,t)=>{let n=y(t);for(n&&(t=-t),I(e,(t>63?128:0)|(n?64:0)|63&t),t=h(t/64);t>0;)I(e,(t>127?128:0)|127&t),t=h(t/128)},ae=new Uint8Array(3e4),oe=ae.length/3,se=k&&k.encodeInto?(e,t)=>{if(t.length<oe){let n=k.encodeInto(t,ae).written||0;L(e,n);for(let t=0;t<n;t++)I(e,ae[t])}else R(e,A(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;L(e,r);for(let t=0;t<r;t++)I(e,n.codePointAt(t))},ce=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=_(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(v(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},R=(e,t)=>{L(e,t.byteLength),ce(e,t)},le=(e,t)=>{ne(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ue=(e,t)=>le(e,4).setFloat32(0,t,!1),de=(e,t)=>le(e,8).setFloat64(0,t,!1),fe=(e,t)=>le(e,8).setBigInt64(0,t,!1),pe=new DataView(new ArrayBuffer(4)),me=e=>(pe.setFloat32(0,e),pe.getFloat32(0)===e),he=(e,t)=>{switch(typeof t){case`string`:I(e,119),se(e,t);break;case`number`:S(t)&&g(t)<=2147483647?(I(e,125),ie(e,t)):me(t)?(I(e,124),ue(e,t)):(I(e,123),de(e,t));break;case`bigint`:I(e,122),fe(e,t);break;case`object`:if(t===null)I(e,126);else if(p(t)){I(e,117),L(e,t.length);for(let n=0;n<t.length;n++)he(e,t[n])}else if(t instanceof Uint8Array)I(e,116),R(e,t);else{I(e,118);let n=Object.keys(t);L(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];se(e,i),he(e,t[i])}}break;case`boolean`:I(e,t?120:121);break;default:I(e,127)}};var ge=class extends N{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&L(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}};let _e=e=>{e.count>0&&(ie(e.encoder,e.count===1?e.s:-e.s),e.count>1&&L(e.encoder,e.count-2))};var ve=class{constructor(){this.encoder=new N,this.s=0,this.count=0}write(e){this.s===e?this.count++:(_e(this),this.count=1,this.s=e)}toUint8Array(){return _e(this),F(this.encoder)}};let ye=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);ie(e.encoder,t),e.count>1&&L(e.encoder,e.count-2)}};var be=class{constructor(){this.encoder=new N,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(ye(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return ye(this),F(this.encoder)}},xe=class{constructor(){this.sarr=[],this.s=``,this.lensE=new ve}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new N;return this.sarr.push(this.s),this.s=``,se(e,this.sarr.join(``)),ce(e,this.lensE.toUint8Array()),F(e)}};let Se=e=>Error(e),Ce=()=>{throw Se(`Method unimplemented`)},we=()=>{throw Se(`Unexpected case`)},Te=Se(`Unexpected end of array`),Ee=Se(`Integer out of Range`);var De=class{constructor(e){this.arr=e,this.pos=0}};let Oe=e=>new De(e),ke=e=>e.pos!==e.arr.length,Ae=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},je=e=>Ae(e,z(e)),Me=e=>e.arr[e.pos++],z=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>b)throw Ee}throw Te},Ne=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>b)throw Ee}throw Te},Pe=j?e=>j.decode(je(e)):e=>{let t=z(e);if(t===0)return``;{let n=String.fromCodePoint(Me(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Me(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Fe=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Ie=[e=>void 0,e=>null,Ne,e=>Fe(e,4).getFloat32(0,!1),e=>Fe(e,8).getFloat64(0,!1),e=>Fe(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Pe,e=>{let t=z(e),n={};for(let r=0;r<t;r++){let t=Pe(e);n[t]=Le(e)}return n},e=>{let t=z(e),n=[];for(let r=0;r<t;r++)n.push(Le(e));return n},je],Le=e=>Ie[127-Me(e)](e);var Re=class extends De{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),this.count=ke(this)?z(this)+1:-1),this.count--,this.s}},ze=class extends De{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ne(this);let e=y(this.s);this.count=1,e&&(this.s=-this.s,this.count=z(this)+2)}return this.count--,this.s}},Be=class extends De{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Ne(this),t=e&1;this.diff=h(e/2),this.count=1,t&&(this.count=z(this)+2)}return this.s+=this.diff,this.count--,this.s}},Ve=class{constructor(e){this.decoder=new ze(e),this.str=Pe(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;let He=crypto.getRandomValues.bind(crypto),Ue=()=>He(new Uint32Array(1))[0],We=()=>`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^Ue()&15>>e/4).toString(16)),Ge=Date.now,Ke=e=>new Promise(e);Promise.all.bind(Promise);let qe=e=>e===void 0?null:e,Je=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Je=localStorage)}catch{}let Ye=Je,Xe=Symbol(`Equality`),Ze=(e,t)=>e===t||!!e?.[Xe]?.(t)||!1,Qe=e=>typeof e==`object`,$e=Object.assign,et=Object.keys,tt=(e,t)=>{for(let n in e)t(e[n],n)},nt=e=>et(e).length,rt=e=>{for(let t in e)return!1;return!0},it=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},at=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ot=(e,t)=>e===t||nt(e)===nt(t)&&it(e,(e,n)=>(e!==void 0||at(t,n))&&Ze(t[n],e)),st=Object.freeze,ct=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&ct(e[t])}return st(e)},lt=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&lt(e,t,n+1)}},ut=e=>e,dt=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Xe]!=null)return e[Xe](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!dt(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(nt(e)!==nt(t))return!1;for(let n in e)if(!at(e,n)||!dt(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!dt(e[n],t[n]))return!1;break;default:return!1}return!0},ft=(e,t)=>t.includes(e),pt=typeof process<`u`&&process.release&&/node|io\\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`;typeof navigator<`u`&&/Mac/.test(navigator.platform);let mt,ht=[],gt=()=>{if(mt===void 0){if(pt){mt=t();let e=process.argv,n=null;for(let t=0;t<e.length;t++){let r=e[t];r[0]===`-`?(n!==null&&mt.set(n,``),n=r):n===null?ht.push(r):(mt.set(n,r),n=null)}n!==null&&mt.set(n,``)}else typeof location==`object`?(mt=t(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);mt.set(`--${ee(t,`-`)}`,n),mt.set(`-${ee(t,`-`)}`,n)}})):mt=t()}return mt},_t=e=>gt().has(e),vt=e=>qe(pt?process.env[e.toUpperCase().replaceAll(`-`,`_`)]:Ye.getItem(e)),yt=e=>_t(`--`+e)||vt(e)!==null,bt=yt(`production`),xt=pt&&ft(process.env.FORCE_COLOR,[`true`,`1`,`2`])||!_t(`--no-colors`)&&!yt(`no-color`)&&(!pt||process.stdout.isTTY)&&(!pt||_t(`--color`)||vt(`COLORTERM`)!==null||(vt(`TERM`)||``).includes(`color`)),St=e=>new Uint8Array(e),Ct=e=>{let t=St(e.byteLength);return t.set(e),t};var wt=class{constructor(e,t){this.left=e,this.right=t}};let Tt=(e,t)=>new wt(e,t),Et=e=>e.next()>=.5,Dt=(e,t,n)=>h(e.next()*(n+1-t)+t),Ot=(e,t,n)=>h(e.next()*(n+1-t)+t),kt=(e,t,n)=>Ot(e,t,n),At=e=>C(kt(e,97,122)),jt=(e,t=0,n=20)=>{let r=kt(e,t,n),i=``;for(let t=0;t<r;t++)i+=At(e);return i},Mt=(e,t)=>t[kt(e,0,t.length-1)],Nt=Symbol(`0schema`);var Pt=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(M(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn\'t match ${n.expected}. ${n.message}`)}return e.join(`\n`)}};let Ft=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Xe]?Ze(e,t):p(e)?u(e,e=>d(t,t=>Ft(e,t))):Qe(e)?it(e,(e,n)=>Ft(e,t[n])):!1;var B=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Ft(t,n)}equals(e){return this.constructor===e.constructor&&dt(this.shape,e.shape)}[Nt](){return!0}[Xe](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Ce()}get nullable(){return pn(this,On)}get optional(){return new Wt(this)}cast(e){return Mn(e,this),e}expect(e){return Mn(e,this),e}},It=class extends B{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}};let V=(e,t=null)=>new It(e,t);V(It);var Lt=class extends B{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}};let H=e=>new Lt(e);V(Lt);var Rt=class extends B{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}};let zt=(...e)=>new Rt(e),Bt=V(Rt),Vt=RegExp.escape||(e=>e.replace(/[().|&,$^[\\]]/g,e=>`\\\\`+e)),Ht=e=>{if(Cn.check(e))return[Vt(e)];if(Bt.check(e))return e.shape.map(e=>e+``);if(Sn.check(e))return[`[+-]?\\\\d+.?\\\\d*`];if(wn.check(e))return[`.*`];if(mn.check(e))return e.shape.map(Ht).flat(1);we()};V(class extends B{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Ht).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn\'t match string template.`),n}});let Ut=Symbol(`optional`);var Wt=class extends B{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Ut](){return!0}};let Gt=V(Wt);var Kt=class extends B{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Kt,V(Kt);var qt=class e extends B{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):it(this.shape,(n,r)=>{let i=this._isPartial&&!at(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}};let Jt=e=>new qt(e),Yt=V(qt),Xt=H(e=>e!=null&&(e.constructor===Object||e.constructor==null));var Zt=class extends B{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&it(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn\'t match schema`:`Value doesn\'t match value`),i&&this.shape.values.check(n,t)})}};let Qt=(e,t)=>new Zt(e,t),$t=V(Zt);var en=class extends B{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&it(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}};let tn=(...e)=>new en(e);V(en);var nn=class extends B{constructor(e){super(),this.shape=e.length===1?e[0]:new fn(e)}check(e,t){let n=p(e)&&u(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}};let rn=(...e)=>new nn(e),an=V(nn),on=H(e=>p(e));var sn=class extends B{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}};let cn=(e,t=null)=>new sn(e,t);V(sn);let ln=cn(B),un=V(class extends B{constructor(e){super(),this.len=e.length-1,this.args=tn(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),dn=H(e=>typeof e==`function`);V(class extends B{constructor(e){super(),this.shape=e}check(e,t){let n=u(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var fn=class extends B{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=d(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}};let pn=(...e)=>e.findIndex(e=>mn.check(e))>=0?pn(...e.map(e=>jn(e)).map(e=>mn.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new fn(e),mn=V(fn),hn=()=>!0,gn=H(hn),_n=V(Lt,e=>e.shape===hn),vn=H(e=>typeof e==`bigint`),yn=H(e=>e===vn),bn=H(e=>typeof e==`symbol`);H(e=>e===bn);let xn=H(e=>typeof e==`number`),Sn=H(e=>e===xn),Cn=H(e=>typeof e==`string`),wn=H(e=>e===Cn),Tn=H(e=>typeof e==`boolean`),En=H(e=>e===Tn),Dn=zt(void 0);V(Rt,e=>e.shape.length===1&&e.shape[0]===void 0),zt(void 0);let On=zt(null),kn=V(Rt,e=>e.shape.length===1&&e.shape[0]===null);V(Uint8Array),V(It,e=>e.shape===Uint8Array);let An=pn(xn,Cn,On,Dn,vn,Tn,bn);(()=>{let e=rn(gn),t=Qt(Cn,gn),n=pn(xn,Cn,On,Tn,e,t);return e.shape=n,t.shape.values=n,n})();let jn=e=>{if(ln.check(e))return e;if(Xt.check(e)){let t={};for(let n in e)t[n]=jn(e[n]);return Jt(t)}if(on.check(e))return pn(...e.map(jn));if(An.check(e))return zt(e);if(dn.check(e))return V(e);we()},Mn=bt?()=>{}:(e,t)=>{let n=new Pt;if(!t.check(e,n))throw Se(`Expected value to be of type ${t.constructor.name}.\\n${n.toString()}`)};var Nn=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:jn(e),h:t}),this}else(e){return this.if(gn,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Se(`Unhandled pattern`)}}};let Pn=(e=>new Nn(e))(gn).if(Sn,(e,t)=>Dt(t,x,b)).if(wn,(e,t)=>jt(t)).if(En,(e,t)=>Et(t)).if(yn,(e,t)=>BigInt(Dt(t,x,b))).if(mn,(e,t)=>Fn(t,Mt(t,e.shape))).if(Yt,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Gt.check(i)){if(Et(t))continue;i=i.shape}n[r]=Pn(i,t)}return n}).if(an,(e,t)=>{let n=[],r=Ot(t,0,42);for(let i=0;i<r;i++)n.push(Fn(t,e.shape));return n}).if(Bt,(e,t)=>Mt(t,e.shape)).if(kn,(e,t)=>null).if(un,(e,t)=>{let n=Fn(t,e.res);return()=>n}).if(_n,(e,t)=>Fn(t,Mt(t,[xn,Cn,On,Dn,vn,Tn,rn(xn),Qt(pn(`a`,`b`,`c`),xn)]))).if($t,(e,t)=>{let n={},r=Dt(t,0,3);for(let i=0;i<r;i++){let r=Fn(t,e.shape.keys);n[r]=Fn(t,e.shape.values)}return n}).done(),Fn=(e,t)=>Pn(jn(t),e),In=typeof document<`u`?document:{};H(e=>e.nodeType===Vn),typeof DOMParser<`u`&&new DOMParser,H(e=>e.nodeType===Rn),H(e=>e.nodeType===zn);let Ln=e=>i(e,(e,t)=>`${t}:${e};`).join(``),Rn=In.ELEMENT_NODE,zn=In.TEXT_NODE;In.CDATA_SECTION_NODE,In.COMMENT_NODE;let Bn=In.DOCUMENT_NODE;In.DOCUMENT_TYPE_NODE;let Vn=In.DOCUMENT_FRAGMENT_NODE;H(e=>e.nodeType===Bn);let Hn=Symbol,Un=Hn(),Wn=Hn(),Gn=Hn(),Kn=Hn(),qn=Hn(),Jn=Hn(),Yn=Hn(),Xn=Hn(),Zn=Hn(),Qn=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};Ge();let $n={[Un]:Tt(`font-weight`,`bold`),[Wn]:Tt(`font-weight`,`normal`),[Gn]:Tt(`color`,`blue`),[qn]:Tt(`color`,`green`),[Kn]:Tt(`color`,`grey`),[Jn]:Tt(`color`,`red`),[Yn]:Tt(`color`,`purple`),[Xn]:Tt(`color`,`orange`),[Zn]:Tt(`color`,`black`)},er=xt?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let n=[],r=[],i=t(),a=[],o=0;for(;o<e.length;o++){let t=e[o],a=$n[t];if(a!==void 0)i.set(a.left,a.right);else{if(t===void 0)break;if(t.constructor===String||t.constructor===Number){let e=Ln(i);o>0||e.length>0?(n.push(`%c`+t),r.push(e)):n.push(t)}else break}}for(o>0&&(a=r,a.unshift(n.join(``)));o<e.length;o++){let t=e[o];t instanceof Symbol||a.push(t)}return a}:Qn,tr=(...e)=>{console.log(...er(e)),rr.forEach(t=>t.print(e))},nr=(...e)=>{console.warn(...er(e)),e.unshift(Xn),rr.forEach(t=>t.print(e))},rr=o(),ir=e=>({[Symbol.iterator](){return this},next:e}),ar=(e,t)=>ir(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),or=(e,t)=>ir(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var sr=class{constructor(e,t){this.clock=e,this.len=t}},cr=class{constructor(){this.clients=new Map}};let lr=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])bi(e,i,o.clock,o.len,n)}}),ur=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=h((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},dr=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&ur(n,t.clock)!==null},fr=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new sr(r.clock,v(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},pr=e=>{let t=new cr;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)c(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return fr(t),t},mr=(e,t,n,i)=>{r(e.clients,t,()=>[]).push(new sr(n,i))},hr=()=>new cr,gr=e=>{let t=hr();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new sr(i,a))}}r.length>0&&t.clients.set(n,r)}),t},_r=(e,t)=>{L(e.restEncoder,t.clients.size),l(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),L(e.restEncoder,t);let r=n.length;L(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},vr=e=>{let t=new cr,n=z(e.restDecoder);for(let i=0;i<n;i++){e.resetDsCurVal();let n=z(e.restDecoder),i=z(e.restDecoder);if(i>0){let a=r(t.clients,n,()=>[]);for(let t=0;t<i;t++)a.push(new sr(e.readDsClock(),e.readDsLen()))}}return t},yr=(e,t,n)=>{let r=new cr,i=z(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=z(e.restDecoder),a=z(e.restDecoder),o=n.clients.get(i)||[],s=W(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&mr(r,i,s,a-s);let e=hi(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Mo(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,Mo(t,c,a-c.id.clock)),c.delete(t))}else mr(r,i,n,a-n)}}if(r.clients.size>0){let e=new kr;return L(e.restEncoder,0),_r(e,r),e.toUint8Array()}return null},br=Ue;var xr=class e extends m{constructor({guid:e=We(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=br(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new fi,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Ke(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Ke(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&K(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(l(this.subdocs).map(e=>e.guid))}transact(e,t=null){return K(this,e,t)}get(e,t=J){let n=r(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),i=n.constructor;if(t!==J&&i!==t){if(i===J){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}throw Error(`Type with the name ${e} has already been defined with a different constructor`)}return n}getArray(e=``){return this.get(e,Sa)}getText(e=``){return this.get(e,Ua)}getMap(e=``){return this.get(e,Ta)}getXmlElement(e=``){return this.get(e,Ja)}getXmlFragment(e=``){return this.get(e,Ka)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,l(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,K(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},Sr=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return z(this.restDecoder)}readDsLen(){return z(this.restDecoder)}},Cr=class extends Sr{readLeftID(){return U(z(this.restDecoder),z(this.restDecoder))}readRightID(){return U(z(this.restDecoder),z(this.restDecoder))}readClient(){return z(this.restDecoder)}readInfo(){return Me(this.restDecoder)}readString(){return Pe(this.restDecoder)}readParentInfo(){return z(this.restDecoder)===1}readTypeRef(){return z(this.restDecoder)}readLen(){return z(this.restDecoder)}readAny(){return Le(this.restDecoder)}readBuf(){return Ct(je(this.restDecoder))}readJSON(){return JSON.parse(Pe(this.restDecoder))}readKey(){return Pe(this.restDecoder)}},wr=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=z(this.restDecoder),this.dsCurrVal}readDsLen(){let e=z(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Tr=class extends wr{constructor(e){super(e),this.keys=[],z(e),this.keyClockDecoder=new Be(je(e)),this.clientDecoder=new ze(je(e)),this.leftClockDecoder=new Be(je(e)),this.rightClockDecoder=new Be(je(e)),this.infoDecoder=new Re(je(e),Me),this.stringDecoder=new Ve(je(e)),this.parentInfoDecoder=new Re(je(e),Me),this.typeRefDecoder=new ze(je(e)),this.lenDecoder=new ze(je(e))}readLeftID(){return new Qr(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Qr(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Le(this.restDecoder)}readBuf(){return je(this.restDecoder)}readJSON(){return Le(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Er=class{constructor(){this.restEncoder=te()}toUint8Array(){return F(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){L(this.restEncoder,e)}writeDsLen(e){L(this.restEncoder,e)}},Dr=class extends Er{writeLeftID(e){L(this.restEncoder,e.client),L(this.restEncoder,e.clock)}writeRightID(e){L(this.restEncoder,e.client),L(this.restEncoder,e.clock)}writeClient(e){L(this.restEncoder,e)}writeInfo(e){re(this.restEncoder,e)}writeString(e){se(this.restEncoder,e)}writeParentInfo(e){L(this.restEncoder,+!!e)}writeTypeRef(e){L(this.restEncoder,e)}writeLen(e){L(this.restEncoder,e)}writeAny(e){he(this.restEncoder,e)}writeBuf(e){R(this.restEncoder,e)}writeJSON(e){se(this.restEncoder,JSON.stringify(e))}writeKey(e){se(this.restEncoder,e)}},Or=class{constructor(){this.restEncoder=te(),this.dsCurrVal=0}toUint8Array(){return F(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,L(this.restEncoder,t)}writeDsLen(e){e===0&&we(),L(this.restEncoder,e-1),this.dsCurrVal+=e}},kr=class extends Or{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new be,this.clientEncoder=new ve,this.leftClockEncoder=new be,this.rightClockEncoder=new be,this.infoEncoder=new ge(re),this.stringEncoder=new xe,this.parentInfoEncoder=new ge(re),this.typeRefEncoder=new ve,this.lenEncoder=new ve}toUint8Array(){let e=te();return L(e,0),R(e,this.keyClockEncoder.toUint8Array()),R(e,this.clientEncoder.toUint8Array()),R(e,this.leftClockEncoder.toUint8Array()),R(e,this.rightClockEncoder.toUint8Array()),R(e,F(this.infoEncoder)),R(e,this.stringEncoder.toUint8Array()),R(e,F(this.parentInfoEncoder)),R(e,this.typeRefEncoder.toUint8Array()),R(e,this.lenEncoder.toUint8Array()),ce(e,F(this.restEncoder)),F(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){he(this.restEncoder,e)}writeBuf(e){R(this.restEncoder,e)}writeJSON(e){he(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}};let Ar=(e,t,n,r)=>{r=v(r,t[0].id.clock);let i=hi(t,r);L(e.restEncoder,t.length-i),e.writeClient(n),L(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},jr=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{W(t,n)>e&&r.set(n,e)}),pi(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),L(e.restEncoder,r.size),l(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Ar(e,t.clients.get(n),n,r)})},Mr=(e,n)=>{let r=t(),i=z(e.restDecoder);for(let t=0;t<i;t++){let t=z(e.restDecoder),i=Array(t),a=e.readClient(),o=z(e.restDecoder);r.set(a,{i:0,refs:i});for(let r=0;r<t;r++){let t=e.readInfo();switch(31&t){case 0:{let t=e.readLen();i[r]=new Y(U(a,o),t),o+=t;break}case 10:{let t=z(e.restDecoder);i[r]=new Lo(U(a,o),t),o+=t;break}default:{let s=!(t&192),c=new Z(U(a,o),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,s?e.readParentInfo()?n.get(e.readString()):e.readLeftID():null,s&&(t&32)==32?e.readString():null,Fo(e,t));i[r]=c,o+=c.length}}}}return r},Nr=(e,t,n)=>{let i=[],a=l(n.keys()).sort((e,t)=>e-t);if(a.length===0)return null;let o=()=>{if(a.length===0)return null;let e=n.get(a[a.length-1]);for(;e.refs.length===e.i;)if(a.pop(),a.length>0)e=n.get(a[a.length-1]);else return null;return e},s=o();if(s===null)return null;let c=new fi,u=new Map,d=(e,t)=>{let n=u.get(e);(n==null||n>t)&&u.set(e,t)},f=s.refs[s.i++],p=new Map,m=()=>{for(let e of i){let t=e.id.client,r=n.get(t);r?(r.i--,c.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):c.clients.set(t,[e]),a=a.filter(e=>e!==t)}i.length=0};for(;;){if(f.constructor!==Lo){let a=r(p,f.id.client,()=>W(t,f.id.client))-f.id.clock;if(a<0)i.push(f),d(f.id.client,f.id.clock-1),m();else{let r=f.getMissing(e,t);if(r!==null){i.push(f);let e=n.get(r)||{refs:[],i:0};if(e.refs.length===e.i)d(r,W(t,r)),m();else{f=e.refs[e.i++];continue}}else(a===0||a<f.length)&&(f.integrate(e,a),p.set(f.id.client,f.id.clock+f.length))}}if(i.length>0)f=i.pop();else if(s!==null&&s.i<s.refs.length)f=s.refs[s.i++];else{if(s=o(),s===null)break;f=s.refs[s.i++]}}if(c.clients.size>0){let e=new kr;return jr(e,c,new Map),L(e.restEncoder,0),{missing:u,update:e.toUint8Array()}}return null},Pr=(e,t)=>jr(e,t.doc.store,t.beforeState),Fr=(e,t,n,r=new Tr(e))=>K(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Mr(r,n),o=Nr(e,i,a),s=i.pendingStructs;if(s){for(let[e,n]of s.missing)if(n<W(i,e)){t=!0;break}if(o){for(let[e,t]of o.missing){let n=s.missing.get(e);(n==null||n>t)&&s.missing.set(e,t)}s.update=zi([s.update,o.update])}}else i.pendingStructs=o;let c=yr(r,e,i);if(i.pendingDs){let t=new Tr(Oe(i.pendingDs));z(t.restDecoder);let n=yr(t,e,i);i.pendingDs=c&&n?zi([c,n]):c||n}else i.pendingDs=c;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Ir(e.doc,t)}},n,!1),Ir=(e,t,n,r=Tr)=>{let i=Oe(t);Fr(i,e,n,new r(i))},Lr=(e,t,n)=>Ir(e,t,n,Cr),Rr=(e,t,n=new Map)=>{jr(e,t.store,n),_r(e,gr(t.store))},zr=(e,t=new Uint8Array([0]),n=new kr)=>{let r=Hr(t);Rr(n,e,r);let i=[n.toUint8Array()];if(e.store.pendingDs&&i.push(e.store.pendingDs),e.store.pendingStructs&&i.push(Bi(e.store.pendingStructs.update,t)),i.length>1){if(n.constructor===Dr)return Li(i.map((e,t)=>t===0?e:Gi(e)));if(n.constructor===kr)return zi(i)}return i[0]},Br=(e,t)=>zr(e,t,new Dr),Vr=e=>{let t=new Map,n=z(e.restDecoder);for(let r=0;r<n;r++){let n=z(e.restDecoder),r=z(e.restDecoder);t.set(n,r)}return t},Hr=e=>Vr(new Sr(Oe(e))),Ur=(e,t)=>(L(e.restEncoder,t.size),l(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{L(e.restEncoder,t),L(e.restEncoder,n)}),e),Wr=(e,t)=>Ur(e,pi(t.store)),Gr=(e,t=new Or)=>(e instanceof Map?Ur(t,e):Wr(t,e),t.toUint8Array()),Kr=e=>Gr(e,new Er);var qr=class{constructor(){this.l=[]}};let Jr=()=>new qr,Yr=(e,t)=>e.l.push(t),Xr=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn\'t exist.`)},Zr=(e,t,n)=>lt(e.l,[t,n]);var Qr=class{constructor(e,t){this.client=e,this.clock=t}};let $r=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,U=(e,t)=>new Qr(e,t),ei=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw we()},ti=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1};var ni=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ri=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}};let ii=(e,t,n=0)=>new ri(e,t,n),ai=(e,t,n)=>{let r=null,i=null;return e._item===null?i=ei(e):r=U(e._item.id.client,e._item.id.clock),new ni(r,i,t,n)},oi=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return ai(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return ai(e,U(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return ai(e,r.lastId,n);r=r.right}return ai(e,null,n)},si=(e,t)=>{let n=gi(e,t);return{item:n,diff:t.clock-n.id.clock}},ci=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(W(r,i.client)<=i.clock)return null;let e=n?Ao(r,i):si(r,i),t=e.item;if(!(t instanceof Z))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(W(r,a.client)<=a.clock)return null;let{item:e}=n?Ao(r,a):{item:gi(r,a)};if(e instanceof Z&&e.content instanceof Oo)c=e.content.type;else return null}else throw we();l=s>=0?c._length:0}return ii(c,l,e.assoc)};var li=class{constructor(e,t){this.ds=e,this.sv=t}};((e,t)=>new li(e,t))(hr(),new Map);let ui=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!dr(t.ds,e.id),di=(e,t)=>{let n=r(e.meta,di,o),i=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<W(i,n)&&G(e,U(n,t))}),lr(e,t.ds,e=>{}),n.add(t))};var fi=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}};let pi=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},W=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},mi=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw we()}n.push(t)},hi=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=h(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=h((n+r)/2)}throw we()},gi=(e,t)=>{let n=e.clients.get(t.client);return n[hi(n,t.clock)]},_i=(e,t,n)=>{let r=hi(t,n),i=t[r];return i.id.clock<n&&i instanceof Z?(t.splice(r+1,0,Mo(e,i,n-i.id.clock)),r+1):r},G=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[_i(e,n,t.clock)]},vi=(e,t,n)=>{let r=t.clients.get(n.client),i=hi(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==Y&&r.splice(i+1,0,Mo(e,a,n.clock-a.id.clock+1)),a},yi=(e,t,n)=>{let r=e.clients.get(t.id.client);r[hi(r,t.id.clock)]=n},bi=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=_i(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&_i(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)};var xi=class{constructor(e,t,n){this.doc=e,this.deleteSet=new cr,this.beforeState=pi(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}};let Si=(e,t)=>t.deleteSet.clients.size===0&&!a(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(fr(t.deleteSet),Pr(e,t),_r(e,t.deleteSet),!0),Ci=(e,t,n)=>{let i=t._item;(i===null||i.id.clock<(e.beforeState.get(i.id.client)||0)&&!i.deleted)&&r(e.changed,t,o).add(n)},wi=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Z&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},Ti=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=hi(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof Z&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Ei=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=_(r.length-1,1+hi(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+wi(r,e)}})},Di=(e,t,n)=>{Ti(e,t,n),Ei(e,t)},Oi=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{fr(a),n.afterState=pi(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{Zr(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Ba(n)})}),lt(e,[])}finally{r.gc&&Ti(a,i,r.gcFilter),Ei(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=v(hi(e,r),1);for(let t=e.length-1;t>=n;)t-=1+wi(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=hi(r,n);a+1<r.length&&wi(r,a+1)>1||a>0&&wi(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(tr(Xn,Un,`[yjs] `,Wn,Jn,`Changed the client-id because another client seems to be using it.`),r.clientID=br()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Dr;Si(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new kr;Si(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Oi(e,t+1)}}},K=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new xi(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Oi(i,0)}}return o};var ki=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}};let Ai=(e,t,n)=>{lr(e,n.deletions,n=>{n instanceof Z&&t.scope.some(t=>t===e.doc||ti(t,n))&&jo(n,!1)})},ji=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;K(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;lr(n,o.insertions,e=>{if(e instanceof Z){if(e.redone!==null){let{item:t,diff:i}=Ao(r,e.id);i>0&&(t=G(n,U(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ti(t,e))&&c.push(e)}}),lr(n,o.deletions,e=>{e instanceof Z&&a.some(t=>t===n.doc||ti(t,e))&&!dr(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Po(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o};var Mi=class extends m{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=p(e)?e[0].doc:e instanceof xr?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new cr;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&mr(i,n,r,a)});let a=Ge(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=pr([t.deletions,e.deleteSet]),t.insertions=pr([t.insertions,i])}else r.push(new ki(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),lr(e,e.deleteSet,t=>{t instanceof Z&&this.scope.some(n=>n===e.doc||ti(n,t))&&jo(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.destroy=this.destroy.bind(this),this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,this.destroy)}addToScope(e){let t=new Set(this.scope);e=p(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof J?e.doc!==this.doc:e!==this.doc)&&nr(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Ai(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Ai(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=ji(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=ji(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),this.doc.off(`destroy`,this.destroy),super.destroy()}};function*Ni(e){let t=z(e.restDecoder);for(let n=0;n<t;n++){let t=z(e.restDecoder),n=e.readClient(),r=z(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=z(e.restDecoder);yield new Lo(U(n,r),t),r+=t}else if(31&t){let i=!(t&192),a=new Z(U(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,Fo(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new Y(U(n,r),t),r+=t}}}}var Pi=class{constructor(e,t){this.gen=Ni(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Lo);return this.curr}};let Fi=(e,t=Tr)=>{let n=[],r=new t(Oe(e)),i=new Pi(r,!1);for(let e=i.curr;e!==null;e=i.next())n.push(e);return{structs:n,ds:vr(r)}};var Ii=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}};let Li=e=>zi(e,Cr,Dr),Ri=(e,t)=>{if(e.constructor===Y){let{client:n,clock:r}=e.id;return new Y(U(n,r+t),e.length-t)}if(e.constructor===Lo){let{client:n,clock:r}=e.id;return new Lo(U(n,r+t),e.length-t)}{let n=e,{client:r,clock:i}=n.id;return new Z(U(r,i+t),null,U(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},zi=(e,t=Tr,n=kr)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Oe(e))),i=r.map(e=>new Pi(e,!0)),a=null,o=new n,s=new Ii(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===Lo?1:-1:n}return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)Hi(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock){if(a.struct.constructor===Lo)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Hi(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Lo(U(t,a.struct.id.clock+a.struct.length),e),offset:0}}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===Lo?a.struct.length-=t:n=Ri(n,t)),a.struct.mergeWith(n)||(Hi(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==Lo;n=e.next())Hi(s,a.struct,a.offset),a={struct:n,offset:0}}a!==null&&(Hi(s,a.struct,a.offset),a=null),Ui(s);let c=r.map(e=>vr(e)),l=pr(c);return _r(o,l),o.toUint8Array()},Bi=(e,t,n=Tr,r=kr)=>{let i=Hr(t),a=new r,o=new Ii(a),s=new n(Oe(e)),c=new Pi(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Lo){c.next();continue}if(e.id.clock+e.length>n)for(Hi(o,e,v(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Hi(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}Ui(o);let l=vr(s);return _r(a,l),a.toUint8Array()},Vi=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:F(e.encoder.restEncoder)}),e.encoder.restEncoder=te(),e.written=0)},Hi=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Vi(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),L(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Ui=e=>{Vi(e);let t=e.encoder.restEncoder;L(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];L(t,r.written),ce(t,r.restEncoder)}},Wi=(e,t,n,r)=>{let i=new n(Oe(e)),a=new Pi(i,!1),o=new r,s=new Ii(o);for(let e=a.curr;e!==null;e=a.next())Hi(s,t(e),0);Ui(s);let c=vr(i);return _r(o,c),o.toUint8Array()},Gi=e=>Wi(e,ut,Tr,Dr),Ki=`You must not compute changes after the event-handler fired.`;var qi=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=Ji(this.currentTarget,this.target)}deletes(e){return dr(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Se(Ki);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r)){if(e!==null&&this.deletes(e))i=`delete`,a=s(e.content.getContent());else return}else e!==null&&this.deletes(e)?(i=`update`,a=s(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=s(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Se(Ki);let t=this.target,n=o(),r=o(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}};let Ji=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},q=()=>{nr(`Invalid access: Add Yjs type to a document before reading data.`)},Yi=0;var Xi=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Yi++}};let Zi=e=>{e.timestamp=Yi++},Qi=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Yi++},$i=(e,t,n)=>{if(e.length>=80){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return Qi(r,t,n),r}{let r=new Xi(t,n);return e.push(r),r}},ea=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>g(t-e.index)<g(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,Zi(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&g(n.index-i)<r.parent.length/80?(Qi(n,r,i),n):$i(e._searchMarker,r,i)},ta=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=v(t,i.index+n))}},na=(e,t,n)=>{let i=e,a=t.changedParentTypes;for(;r(a,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Zr(i._eH,n,t)};var J=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Jr(),this._dEH=Jr(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Ce()}clone(){throw Ce()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Yr(this._eH,e)}observeDeep(e){Yr(this._dEH,e)}unobserve(e){Xr(this._eH,e)}unobserveDeep(e){Xr(this._dEH,e)}toJSON(){}};let ra=(e,t,n)=>{e.doc??q(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},ia=e=>{e.doc??q();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},aa=(e,t)=>{let n=0,r=e._start;for(e.doc??q();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},oa=(e,t)=>{let n=[];return aa(e,(r,i)=>{n.push(t(r,i,e))}),n},sa=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},ca=(e,t)=>{e.doc??q();let n=ea(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},la=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new Z(U(o,W(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new go(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new Z(U(o,W(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new no(new Uint8Array(n))),i.integrate(e,0);break;case xr:i=new Z(U(o,W(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new so(n)),i.integrate(e,0);break;default:if(n instanceof J)i=new Z(U(o,W(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Oo(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},ua=()=>Se(`Length exceeded!`),da=(e,t,n,r)=>{if(n>t._length)throw ua();if(n===0)return t._searchMarker&&ta(t._searchMarker,n,r.length),la(e,t,null,r);let i=n,a=ea(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&G(e,U(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&ta(t._searchMarker,i,r.length),la(e,t,o,r)},fa=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return la(e,t,r,n)},pa=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=ea(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&G(e,U(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&G(e,U(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw ua();t._searchMarker&&ta(t._searchMarker,i,-a+r)},ma=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},ha=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new go([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new go([r]);break;case Uint8Array:s=new no(r);break;case xr:s=new so(r);break;default:if(r instanceof J)s=new Oo(r);else throw Error(`Unexpected content type`)}new Z(U(o,W(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},ga=(e,t)=>{e.doc??q();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},_a=e=>{let t={};return e.doc??q(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},va=(e,t)=>{e.doc??q();let n=e._map.get(t);return n!==void 0&&!n.deleted},ya=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&ui(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},ba=e=>(e.doc??q(),ar(e._map.entries(),e=>!e[1].deleted));var xa=class extends qi{},Sa=class e extends J{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof J?e.clone():e)),t}get length(){return this.doc??q(),this._length}_callObserver(e,t){super._callObserver(e,t),na(this,e,new xa(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):K(this.doc,n=>{da(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):K(this.doc,t=>{fa(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):K(this.doc,n=>{pa(n,this,e,t)})}get(e){return ca(this,e)}toArray(){return ia(this)}slice(e=0,t=this.length){return ra(this,e,t)}toJSON(){return this.map(e=>e instanceof J?e.toJSON():e)}map(e){return oa(this,e)}forEach(e){aa(this,e)}[Symbol.iterator](){return sa(this)}_write(e){e.writeTypeRef(xo)}};let Ca=e=>new Sa;var wa=class extends qi{constructor(e,t,n){super(e,t),this.keysChanged=n}},Ta=class e extends J{constructor(e){super(),this._prelimContent=null,this._prelimContent=e===void 0?new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof J?e.clone():e)}),t}_callObserver(e,t){na(this,e,new wa(this,e,t))}toJSON(){this.doc??q();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof J?r.toJSON():r}}),e}get size(){return[...ba(this)].length}keys(){return or(ba(this),e=>e[0])}values(){return or(ba(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return or(ba(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??q(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):K(this.doc,t=>{ma(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):K(this.doc,n=>{ha(n,this,e,t)}),t}get(e){return ga(this,e)}has(e){return va(this,e)}clear(){this.doc===null?this._prelimContent.clear():K(this.doc,e=>{this.forEach(function(t,n,r){ma(e,r,n)})})}_write(e){e.writeTypeRef(So)}};let Ea=e=>new Ta,Da=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&ot(e,t);var Oa=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&we(),this.right.content.constructor){case X:this.right.deleted||Ma(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length)}this.left=this.right,this.right=this.right.right}};let ka=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case X:t.right.deleted||Ma(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&G(e,U(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length)}t.left=t.right,t.right=t.right.right}return t},Aa=(e,t,n,r)=>{let i=new Map,a=r?ea(t,n):null;if(a){let t=new Oa(a.p.left,a.p,a.index,i);return ka(e,t,n-a.index)}{let r=new Oa(null,t._start,0,i);return ka(e,r,n)}},ja=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===X&&Da(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new Z(U(a,W(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new X(o,r));l.integrate(e,0),n.right=l,n.forward()})},Ma=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Na=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===X&&Da(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Pa=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!Da(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Z(U(a,W(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new X(s,c)),n.right.integrate(e,0),n.forward()}}return o},Fa=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Na(n,i);let s=Pa(e,t,n,i),c=r.constructor===String?new vo(r):r instanceof J?new Oo(r):new lo(r),{left:l,right:u,index:d}=n;t._searchMarker&&ta(t._searchMarker,n.index,c.getLength()),u=new Z(U(o,W(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),ja(e,t,n,s)},Ia=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Na(n,i);let s=Pa(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===X));){if(!n.right.deleted)switch(n.right.content.constructor){case X:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Da(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&G(e,U(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`\n`;n.right=new Z(U(o,W(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new vo(i)),n.right.integrate(e,0),n.forward()}ja(e,t,n,s)},La=(e,n,r,i,a)=>{let o=n,s=t();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===X){let e=o.content;s.set(e.key,e)}o=o.right}let c=0,l=!1;for(;n!==o;){if(r===n&&(l=!0),!n.deleted){let t=n.content;switch(t.constructor){case X:{let{key:r,value:o}=t,u=i.get(r)??null;(s.get(r)!==t||u===o)&&(n.delete(e),c++,!l&&(a.get(r)??null)===o&&u!==o&&(u===null?a.delete(r):a.set(r,u))),!l&&!n.deleted&&Ma(a,t);break}}}n=n.right}return c},Ra=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===X){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},za=e=>{let r=0;return K(e.doc,i=>{let a=e._start,o=e._start,s=t(),c=n(s);for(;o;){if(o.deleted===!1)switch(o.content.constructor){case X:Ma(c,o.content);break;default:r+=La(i,a,o,s,c),s=n(c),a=o}o=o.right}}),r},Ba=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&bi(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===X&&e.constructor!==Y&&t.add(e.parent)})}K(n,n=>{lr(e,e.deleteSet,e=>{if(e instanceof Y||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===X?t.add(r):Ra(n,e)});for(let e of t)za(e)})},Va=(e,t,r)=>{let i=r,a=n(t.currentAttributes),o=t.right;for(;r>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Oo:case lo:case vo:r<t.right.length&&G(e,U(t.right.id.client,t.right.id.clock+r)),r-=t.right.length,t.right.delete(e)}t.forward()}o&&La(e,o,t.right,a,t.currentAttributes);let s=(t.left||t.right).parent;return s._searchMarker&&ta(s._searchMarker,t.index,-i+r),t};var Ha=class extends qi{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];K(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},rt(o)||(e.attributes=$e({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Oo:case lo:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case vo:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case X:{let{key:t,value:s}=i.content;if(this.adds(i)){if(!this.deletes(i)){let c=n.get(t)??null;Da(c,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Da(s,r.get(t)??null)?delete o[t]:o[t]=s)}}else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;Da(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Da(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Ma(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},Ua=class e extends J{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??q(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new Ha(this,e,t);na(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??q();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===vo&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):K(this.doc,n=>{let r=new Oa(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`\n`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Fa(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&Va(n,r,a.delete):Ia(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??q();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(ui(s,e)||t!==void 0&&ui(s,t))switch(s.content.constructor){case vo:{let r=i.get(`ychange`);e!==void 0&&!ui(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!ui(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case Oo:case lo:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case X:ui(s,e)&&(c(),Ma(i,s.content))}s=s.right}c()};return e||t?K(a,n=>{e&&di(n,e),t&&di(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):K(r,r=>{let i=Aa(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Fa(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):K(r,r=>{let i=Aa(r,this,e,!n);Fa(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):K(n,n=>{Va(n,Aa(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):K(r,r=>{let i=Aa(r,this,e,!1);i.right!==null&&Ia(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):K(this.doc,t=>{ma(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):K(this.doc,n=>{ha(n,this,e,t)})}getAttribute(e){return ga(this,e)}getAttributes(){return _a(this)}_write(e){e.writeTypeRef(Co)}};let Wa=e=>new Ua;var Ga=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??q()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Ja||t.constructor===Ka)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},Ka=class e extends J{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof J?e.clone():e)),t}get length(){return this.doc??q(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Ga(this,e)}querySelector(e){e=e.toUpperCase();let t=new Ga(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),l(new Ga(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){na(this,e,new Xa(this,t,e))}toString(){return oa(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),aa(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):K(this.doc,n=>{da(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)K(this.doc,n=>{let r=e&&e instanceof J?e._item:e;la(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw Se(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):K(this.doc,n=>{pa(n,this,e,t)})}toArray(){return ia(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ca(this,e)}slice(e=0,t=this.length){return ra(this,e,t)}forEach(e){aa(this,e)}_write(e){e.writeTypeRef(To)}};let qa=e=>new Ka;var Ja=class e extends Ka{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName),n=this.getAttributes();return tt(n,(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof J?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):K(this.doc,t=>{ma(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):K(this.doc,n=>{ha(n,this,e,t)})}getAttribute(e){return ga(this,e)}hasAttribute(e){return va(this,e)}getAttributes(e){return e?ya(this,e):_a(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return aa(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(wo),e.writeKey(this.nodeName)}};let Ya=e=>new Ja(e.readKey());var Xa=class extends qi{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},Za=class e extends Ta{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Eo),e.writeKey(this.hookName)}};let Qa=e=>new Za(e.readKey());var $a=class e extends Ua{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Do)}};let eo=e=>new $a;var to=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ce()}mergeWith(e){return!1}write(e,t,n){throw Ce()}integrate(e,t){throw Ce()}},Y=class extends to{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),mi(e.doc.store,this)}write(e,t){e.writeInfo(0),e.writeLen(this.length-t)}getMissing(e,t){return null}},no=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw Ce()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}};let ro=e=>new no(e.readBuf());var io=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){mr(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}};let ao=e=>new io(e.readLen()),oo=(e,t)=>new xr({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});var so=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(oo(this.doc.guid,this.opts))}splice(e){throw Ce()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}};let co=e=>new so(oo(e.readString(),e.readAny()));var lo=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw Ce()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}};let uo=e=>new lo(e.readJSON());var X=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw Ce()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}};let fo=e=>new X(e.readKey(),e.readJSON());var po=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}};let mo=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new po(n)},ho=vt(`node_env`)===`development`;var go=class e{constructor(e){this.arr=e,ho&&ct(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}};let _o=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new go(n)};var vo=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}};let yo=e=>new vo(e.readString()),bo=[Ca,Ea,Wa,Ya,qa,Qa,eo],xo=0,So=1,Co=2,wo=3,To=4,Eo=5,Do=6;var Oo=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw Ce()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}};let ko=e=>new Oo(bo[e.readTypeRef()](e)),Ao=(e,t)=>{let n=t,r=0,i;do r>0&&(n=U(n.client,n.clock+r)),i=gi(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Z);return{item:i,diff:r}},jo=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Mo=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Z(U(r,i+n),t,U(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=U(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},No=(e,t)=>d(e,e=>dr(e.deletions,t)),Po=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return G(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Po(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=G(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:G(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:G(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else{if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||dr(r,d.right.id)||No(a.undoStack,d.right.id)||No(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=G(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;d!==null&&d.parent._item!==u&&(d=p._map.get(t.parentSub)||null)}let m=W(s,c),h=U(c,m),g=new Z(h,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=h,jo(g,!0),g.integrate(e,0),g};var Z=class e extends to{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=W(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=W(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Qr&&this.id.client!==this.parent.client&&this.parent.clock>=W(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=vi(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=G(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===Y||this.right&&this.right.constructor===Y)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Qr){let e=gi(n,this.parent);this.parent=e.constructor===Y?null:e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=vi(e,e.doc.store,U(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),$r(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if($r(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(gi(e.doc.store,n.origin)))r.has(gi(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),mi(e.doc.store,this),this.content.integrate(e,this),Ci(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Y(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:U(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&$r(e.origin,this.lastId)&&this.right===e&&$r(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),mr(e.deleteSet,this.id.client,this.id.clock,this.length),Ci(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw we();this.content.gc(e),t?yi(e,this,new Y(this.id,this.length)):this.content=new io(this.length)}write(e,t){let n=t>0?U(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=ei(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===Qr?(e.writeParentInfo(!1),e.writeLeftID(t)):we();i!==null&&e.writeString(i)}this.content.write(e,t)}};let Fo=(e,t)=>Io[t&31](e),Io=[()=>{we()},ao,mo,ro,yo,uo,fo,ko,_o,co,()=>{we()}];var Lo=class extends to{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){we()}write(e,t){e.writeInfo(10),L(e.restEncoder,this.length-t)}getMissing(e,t){return null}};let Ro=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},zo=`__ $YJS$ __`;Ro[zo]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Ro[zo]=!0;let Q=Object.freeze({stateBytes:262144,updateBytes:32768,textLength:32768,clients:128,structs:16384,historyUnits:1048576,undoEntries:100,undoUnits:32768}),Bo=new TextEncoder,Vo=(e,t)=>{throw Object.assign(Error(t),{code:e})},$=(e,t,n)=>{e||Vo(t,n)},Ho=e=>Number.isSafeInteger(e)&&e>=0,Uo=e=>{$(typeof e==`string`,`SHARED_TEXT_INPUT`,`Shared text must be a string`),$(e.length<=Q.textLength,`SHARED_TEXT_LIMIT`,`Shared text exceeds its character limit`);for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=55296&&n<=56319){let n=e.charCodeAt(++t);$(n>=56320&&n<=57343,`SHARED_TEXT_INPUT`,`Shared text contains an incomplete Unicode character`)}else $(n<56320||n>57343,`SHARED_TEXT_INPUT`,`Shared text contains an incomplete Unicode character`)}return e};function Wo(e){$(e instanceof Uint8Array,`SHARED_TEXT_INPUT`,`Expected shared text bytes`);let t=``;for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function Go(e,t=Q.updateBytes){$(typeof e==`string`&&e.length>0&&e.length<=4*Math.ceil(t/3),`SHARED_TEXT_LIMIT`,`Shared text data exceeds its byte limit`),$(e.length%4==0&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e),`SHARED_TEXT_INPUT`,`Expected canonical base64 shared text data`);let n=atob(e);$(n.length<=t,`SHARED_TEXT_LIMIT`,`Shared text data exceeds its byte limit`);let r=Uint8Array.from(n,e=>e.charCodeAt(0));return $(Wo(r)===e,`SHARED_TEXT_INPUT`,`Expected canonical base64 shared text data`),r}function Ko(e){let t;class n extends Cr{constructor(e){super(e),t=e}}let r=Fi(e,n);$(t.pos===e.length,`SHARED_TEXT_STATE`,`Shared text data contains trailing bytes`),$(r.structs.length<=Q.structs&&r.ds.clients.size<=Q.clients,`SHARED_TEXT_LIMIT`,`Shared text history exceeds its limit`);let i=0,a=0,o=new Map;for(let e of r.structs)$(Ho(e.id.client)&&Ho(e.id.clock)&&Ho(e.length)&&e.length>0,`SHARED_TEXT_STATE`,`Invalid shared text history`),$(!o.has(e.id.client)||e.id.clock>=o.get(e.id.client),`SHARED_TEXT_STATE`,`Shared text history overlaps itself`),o.set(e.id.client,e.id.clock+e.length),i+=e.length,$(e.id.clock+e.length<=Q.historyUnits&&i<=Q.historyUnits,`SHARED_TEXT_LIMIT`,`Shared text history needs a new epoch`),e instanceof Z?($(e.parentSub===null&&(e.parent===null||typeof e.parent!=`string`||e.parent===`text`),`SHARED_TEXT_STATE`,`Shared text accepts only its plaintext field`),$(e.content instanceof vo||e.content instanceof io,`SHARED_TEXT_STATE`,`Shared text cannot contain formatting, embedded values or other shared types`),e.content instanceof vo&&Uo(e.content.str)):$(e instanceof Y,`SHARED_TEXT_STATE`,`Unsupported shared text history`);for(let[e,t]of r.ds.clients){$(Ho(e),`SHARED_TEXT_STATE`,`Invalid shared text deletion`),a+=t.length,$(a<=Q.structs,`SHARED_TEXT_LIMIT`,`Shared text deletion history exceeds its limit`);for(let e of t)$(Ho(e.clock)&&Ho(e.len)&&e.len>0&&e.clock+e.len<=Q.historyUnits,`SHARED_TEXT_STATE`,`Invalid shared text deletion`)}return r}function qo(e,t){let n=new Map;for(let e of t.structs){let t=n.get(e.id.client)||[];t.push(e),n.set(e.id.client,t)}let r=(t,r)=>{let i=e=>{if(!e)return;let t=0,n=e.length;for(;t<n;){let i=t+n>>>1;e[i].id.clock<=r?t=i+1:n=i}let i=e[t-1];return i&&r<i.id.clock+i.length?i:void 0};return i(e.store.clients.get(t))||i(n.get(t))},i=(e,t)=>{let n=r(e,t);if(n instanceof Z&&n.content instanceof vo){let e=t-n.id.clock,r=n.content.str;$($o(r,e),`SHARED_TEXT_STATE`,`Shared text update splits a Unicode character`)}};for(let e of t.structs)e instanceof Z&&(e.origin&&i(e.origin.client,e.origin.clock+1),e.rightOrigin&&i(e.rightOrigin.client,e.rightOrigin.clock));for(let[e,n]of t.ds.clients)for(let t of n)i(e,t.clock),i(e,t.clock+t.len)}function Jo(e){let t=e.getText(`text`);$(e.share.size===1&&e.share.get(`text`)===t&&t._map.size===0&&e.getSubdocs().size===0,`SHARED_TEXT_STATE`,`Shared text accepts only its plaintext field`),$(e.store.pendingStructs===null&&e.store.pendingDs===null,`SHARED_TEXT_STATE`,`Shared text update is missing earlier history`),$(e.store.clients.size<=Q.clients,`SHARED_TEXT_LIMIT`,`Shared text history needs a new epoch`);let n=0,r=0;for(let i of e.store.clients.values())for(let e of i)n++,r+=e.length,$(n<=Q.structs&&r<=Q.historyUnits,`SHARED_TEXT_LIMIT`,`Shared text history needs a new epoch`),e instanceof Z?$(e.parent===t&&e.parentSub===null&&(e.content instanceof vo||e.content instanceof io),`SHARED_TEXT_STATE`,`Shared text contains unsupported history`):$(e instanceof Y,`SHARED_TEXT_STATE`,`Unsupported shared text history`);for(let e of t.toDelta())$(typeof e.insert==`string`&&e.attributes===void 0,`SHARED_TEXT_STATE`,`Shared text cannot contain formatting or embedded values`);return Uo(t.toString())}function Yo(e,t,n){let r=Go(t,n);qo(e,Ko(r)),Lr(e,r),Jo(e)}function Xo(e){let t=new xr;t.getText(`text`);try{return Yo(t,e,Q.stateBytes),t}catch(e){throw t.destroy(),e}}function Zo(e){let t=Jo(e),n=Br(e);return $(n.length<=Q.stateBytes,`SHARED_TEXT_LIMIT`,`Shared text history needs a new epoch`),{state:Wo(n),value:t}}function Qo(e){try{return e()}catch(e){if(typeof e?.code==`string`&&e.code.startsWith(`SHARED_TEXT_`))throw e;Vo(`SHARED_TEXT_STATE`,`Invalid shared text data`)}}let $o=(e,t)=>Ho(t)&&t<=e.length&&!(t>0&&t<e.length&&e.charCodeAt(t-1)>=55296&&e.charCodeAt(t-1)<=56319&&e.charCodeAt(t)>=56320&&e.charCodeAt(t)<=57343),es=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function ts({protocol:e,epoch:t,state:n}){$(e===1&&typeof t==`string`&&es.test(t),`SHARED_TEXT_INPUT`,`Expected a versioned shared text epoch`);let r=Qo(()=>Xo(n)),i=r.getText(`text`),a={},o={},s=new WeakMap,c=new Mi(i,{trackedOrigins:new Set([a]),captureTimeout:0}),l=!1,u=null,d=()=>{if($(!l,`SHARED_TEXT_CLOSED`,`Shared text session is closed`),u)throw u},f=e=>{throw u=e,e},p=(e=[])=>{let t=e=>[...e.deletions.clients.values()].reduce((e,t)=>e+t.reduce((e,t)=>e+t.len,0),0),n=[...c.undoStack,...c.redoStack].reduce((e,n)=>e+t(n),0);for(;c.undoStack.length+c.redoStack.length>Q.undoEntries||n>Q.undoUnits;){let r=(c.undoStack.length?c.undoStack:c.redoStack).shift();n-=t(r),e.push(r.deletions)}if(!e.length)return;let i=pr(e);r.transact(e=>{lr(e,i,e=>{e instanceof Z&&(e.keep=!1)});for(let t of[...c.undoStack,...c.redoStack])lr(e,t.deletions,e=>{e instanceof Z&&(e.keep=!0)});Di(i,r.store,()=>!0)},o)},m=e=>{d();let t=c.redoStack.map(e=>e.deletions);try{return r.transact(e,a),p(t),i.toString()}catch(e){return f(e)}},h=e=>{d();let t=c[e](),n;try{n=Uo(i.toString())}catch(n){throw t&&c[e===`undo`?`redo`:`undo`](),n}try{return p(),n}catch(e){return f(e)}};return Object.freeze({getValue(){return $(!l,`SHARED_TEXT_CLOSED`,`Shared text session is closed`),i.toString()},splice(e,t,n=``){d();let r=i.toString();return Uo(n),$(Ho(t)&&$o(r,e)&&$o(r,e+t),`SHARED_TEXT_INPUT`,`Choose complete characters within the shared text`),$(r.length-t+n.length<=Q.textLength&&Bo.encode(n).length+1024<=Q.updateBytes,`SHARED_TEXT_LIMIT`,`Shared text edit exceeds its limit`),!t&&!n?r:m(()=>{t&&i.delete(e,t),n&&i.insert(e,n)})},captureSelection(e,t=e,n=`none`){d();let r=i.toString();$($o(r,e)&&$o(r,t)&&e<=t&&[`none`,`forward`,`backward`].includes(n),`SHARED_TEXT_INPUT`,`Invalid shared text selection`);let a=Object.freeze({});return s.set(a,{start:oi(i,e),end:oi(i,t),direction:n}),a},resolveSelection(e){d(),$(e&&s.has(e),`SHARED_TEXT_INPUT`,`Selection belongs to another shared text session`);let t=s.get(e),n=ci(t.start,r),a=ci(t.end,r);return $(n?.type===i&&a?.type===i,`SHARED_TEXT_STATE`,`Shared text selection is unavailable`),{start:Math.min(n.index,a.index),end:Math.max(n.index,a.index),direction:t.direction}},receive(n){return d(),$(n?.protocol===e&&n.epoch===t,`SHARED_TEXT_STATE`,`Shared text epoch changed; retain the local draft and reopen explicitly`),Qo(()=>{let e=Xo(Wo(Br(r)));try{Yo(e,n.state,Q.stateBytes),Zo(e)}finally{e.destroy()}return Lr(r,Go(n.state,Q.stateBytes),o),i.toString()})},getUpdateSince(n){return d(),$(n?.protocol===e&&n.epoch===t,`SHARED_TEXT_STATE`,`Shared text epoch changed; retain the local draft and reopen explicitly`),Qo(()=>{let i=Xo(n.state);try{Zo(r);let n=Br(r,Kr(i));return $(n.length<=Q.updateBytes,`SHARED_TEXT_LIMIT`,`Shared text batch exceeds its limit`),{protocol:e,epoch:t,update:Wo(n)}}finally{i.destroy()}})},undo(){return h(`undo`)},redo(){return h(`redo`)},canUndo(){return!l&&c.undoStack.length>0},canRedo(){return!l&&c.redoStack.length>0},checkpoint(){return d(),Qo(()=>({protocol:e,epoch:t,...Zo(r)}))},dispose(){l||(l=!0,c.destroy(),r.destroy())}})}function ns(e,t,n,r=null,i=[]){let a=new Map,o=[`text`,`search`,`email`,`tel`,`url`],s=new Set(i),c=new Map,l=new Set,u=new Map,d=!1,f={},p=(e,t,n)=>e?e.some(e=>e.value===String(n)):t.tagName!==`SELECT`||[...t.options].some(e=>e.value===String(n)),m=(e,t)=>{if(clearTimeout(t.timer),c.delete(e),d)return;let r;return r=Promise.resolve().then(()=>{if(!d)return t.callback()}).catch(t=>{u.set(e,t),n(t.message)}).finally(()=>l.delete(r)),l.add(r),r},h=(e,t)=>{if(d)throw Error(`This interface has closed; shared edits stopped.`);if(typeof e!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(e))throw Error(`A shared edit key starts with a letter and holds only letters, digits, - and _ (up to 100 characters).`);if(typeof t!=`function`)throw Error(`Give scheduleSharedEdit a function to run.`);if(!c.has(e)&&c.size+l.size>=32||!u.has(e)&&u.size>=32)throw Error(`Too many scheduled shared edits`);u.delete(e);let n=c.get(e),r={callback:t,started:n?.started??Date.now(),timer:null};n&&clearTimeout(n.timer),r.timer=setTimeout(()=>m(e,r),Math.max(0,Math.min(150,500-(Date.now()-r.started)))),c.set(e,r)},g=(i,c)=>{if(!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(i)||a.has(i))throw Error(`Use one control per named shared field`);let l=e.getElementById(c),u=l?.tagName===`FIELDSET`?[...l.querySelectorAll(`input[type="radio"]`)]:null;if(!l||![`INPUT`,`TEXTAREA`,`SELECT`,`FIELDSET`].includes(l.tagName)||u&&!u.length||l.tagName===`INPUT`&&![`text`,`search`,`email`,`tel`,`url`,`number`,`range`,`checkbox`,`color`].includes(l.type))throw Error(`Bind an existing text, number, checkbox or select control, or a fieldset of radio buttons`);if(s.has(i)){let e=l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type),t=l.disabled,n=l.readOnly,r=l.getAttribute(`title`),s=l.getAttribute(`aria-readonly`),c=l.getAttribute(`aria-disabled`);e?(l.readOnly=!0,l.setAttribute(`aria-readonly`,`true`)):(l.disabled=!0,l.setAttribute(`aria-disabled`,`true`)),l.setAttribute(`title`,`Connected input. Change its source in Flow.`);let u={flush:async()=>{},status:()=>({dirty:!1,saving:!1,problem:null,canEdit:!1,composing:!1,interrupted:!1}),setDefault(){},dispose(){l.disabled=t,l.readOnly=n,r===null?l.removeAttribute(`title`):l.setAttribute(`title`,r),s===null?l.removeAttribute(`aria-readonly`):l.setAttribute(`aria-readonly`,s),c===null?l.removeAttribute(`aria-disabled`):l.setAttribute(`aria-disabled`,c),a.delete(i)}};return a.set(i,u),u.dispose}if(r&&(l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type))){let e=r.bind(i,l),t=e.dispose;return e.dispose=()=>{t(),a.delete(i)},a.set(i,e),e.dispose}let d=l.disabled,m={exists:!1},h,g=!1,_=!1,v=null,y=!1,b=!1,x=null,S=null,C=null,w=!1,T=!1,E,D=l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type),ee=e=>{S=e,l.setCustomValidity(e.message),n(e.message)},O=()=>u.find(e=>e.checked)?.value??``,k=e=>{let n=u?O():l.type===`checkbox`?l.checked:l.value;if(u)for(let t of u)t.checked=t.value===String(e??``);else l.type===`checkbox`?l.checked=!!e:l.value!==String(e??``)&&(l.value=String(e??``));(u?O():l.type===`checkbox`?l.checked:l.value)!==n&&queueMicrotask(()=>{y||t.announce?.()})},A=()=>u?O():l.type===`checkbox`?l.checked:[`number`,`range`].includes(l.type)?l.valueAsNumber:l.value,j=Object.hasOwn(f,i)&&p(u,l,f[i])?f[i]:A(),M=()=>{if(clearTimeout(v),v=null,_)return x;if(y||w||!g||!b||S)return;let e=h;g=!1,C=null,_=!0;let n=!1;return x=Promise.resolve().then(()=>t.updateShared({[i]:e},{[i]:m})).then(()=>{m={exists:!0,value:e},l.setCustomValidity(``),!S&&g&&Object.is(h,e)&&(g=!1,C=null)},e=>{n=!0,g=!0,ee(e)}).finally(()=>{_=!1,x=null,!y&&!n&&g&&h!==e&&N(),!y&&!g&&F(t.getShared())}),x},N=()=>{clearTimeout(v),v=setTimeout(M,Math.max(0,Math.min(150,500-(Date.now()-(C??Date.now())))))},te=()=>{!y&&D&&b&&!d&&(w=!0,clearTimeout(v),v=null)},P=e=>{if(y||!b||d)return;if(D&&e?.isComposing){te();return}if(w)return;let t=A();if(typeof t==`number`&&!Number.isFinite(t)){ee(Error(`Enter a finite number`));return}E!==void 0&&Object.is(t,E)||(E=void 0,(S||!Object.is(t,g||_?h:m.exists?m.value:j))&&((S||C===null)&&(C=Date.now()),h=t,S=null,g=!0,N()))},F=e=>{y||(b=e.canEdit,l.disabled=d||!b,!b&&w&&(T=!0),!b&&(g||w)&&ee(Error(`Editing access changed. Your unsaved draft has been preserved.`)),!(w||g||_||S)&&(m=Object.hasOwn(e.state,i)?{exists:!0,value:e.state[i]}:{exists:!1},k(m.exists?m.value:j)))},ne=t.onShared(F),I=()=>{if(!y&&w){if(w=!1,!b||T){T=!1,h=A(),E=h,g=!0,ee(Error(`Editing access changed. Your unsaved draft has been preserved.`));return}P(),g&&!_&&!S?(C=Date.now(),N()):!g&&!_&&!S&&F(t.getShared())}};l.disabled=d||!t.getShared().canEdit;let re=u?`focusout`:`blur`;l.addEventListener(`input`,P),l.addEventListener(`change`,P),l.addEventListener(re,M),l.addEventListener(`compositionstart`,te),l.addEventListener(`compositionend`,I);let L=()=>{y=!0,w=!1,clearTimeout(v),ne(),l.removeEventListener(`input`,P),l.removeEventListener(`change`,P),l.removeEventListener(re,M),l.removeEventListener(`compositionstart`,te),l.removeEventListener(`compositionend`,I),l.disabled=d,a.delete(i)};return a.set(i,{dispose:L,flush:M,status(){return{dirty:g,saving:_,problem:S,canEdit:b,composing:w,interrupted:E!==void 0}},setDefault(e){j=e,F(t.getShared())},setInputDefault(e){p(u,l,e)&&this.setDefault(e)}}),L},_=new Map,v=new Map,y=new WeakSet,b=[`text`,`search`,`email`,`tel`,`url`,`number`,`range`,`checkbox`,`color`],x=/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/,S=/(?:password|secret|credential|authorization|cookie|token|api[_-]?key|private[_-]?key)/i,C=/^(?:current-password|new-password|one-time-code|cc-)/i,w=null,T=null,E=e=>{let t=_.get(e);if(t!==void 0){_.delete(e),v.delete(t);try{a.get(t)?.dispose()}catch{}a.delete(t)}},D=(t,n)=>{let r=e.getElementById(n);r&&_.has(r)&&E(r),v.has(t)&&E(v.get(t));let i=g(t,n);return r&&y.add(r),i},ee=e=>{let t=e.getAttribute(`data-stillmade-share`)||e.getAttribute(`name`)||e.id||(e.tagName===`FIELDSET`?e.querySelector(`input[type="radio"][name]`)?.getAttribute(`name`):``)||``;return x.test(t)?t:null},O=e=>!e.isConnected||e.closest(`[data-stillmade-local]`)?!1:e.tagName===`FIELDSET`?!!e.querySelector(`input[type="radio"]`)&&!e.querySelector(`fieldset`):e.tagName===`INPUT`?b.includes(e.type):e.tagName===`TEXTAREA`||e.tagName===`SELECT`,k=t=>{if(y.has(t)||_.has(t)||!O(t))return;let n=ee(t);if(!(!n||a.has(n)||a.size>=100)&&!(!t.hasAttribute(`data-stillmade-share`)&&(S.test(n)||S.test(t.getAttribute(`name`)||``)||S.test(t.id||``)||C.test(t.getAttribute(`autocomplete`)||``)))){if(!t.id){let r=`sm-shared-${n}`,i=1;for(;e.getElementById(r);)r=`sm-shared-${n}-${++i}`;t.id=r}else if(e.getElementById(t.id)!==t)return;try{g(n,t.id),_.set(t,n),v.set(n,t)}catch{a.delete(n)}}},A=()=>{if(T=null,!(d||j))try{for(let e of[..._.keys()])(!e.isConnected||e.closest(`[data-stillmade-local]`))&&E(e);for(let t of e.querySelectorAll(`input,textarea,select,fieldset`))k(t)}catch(e){n(e.message)}},j=!1,M=()=>{if(!j){j=!0,w?.disconnect(),w=null,T&&=(clearTimeout(T),null);for(let e of[..._.keys()])E(e)}},N=()=>{j||d||w||typeof MutationObserver!=`function`||!e.documentElement||(A(),w=new MutationObserver(()=>{!T&&!d&&(T=setTimeout(A,30))}),w.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`name`,`id`,`type`,`data-stillmade-local`,`data-stillmade-share`]}))};e.readyState===`loading`?e.addEventListener?.(`DOMContentLoaded`,N,{once:!0}):typeof setTimeout==`function`&&typeof MutationObserver==`function`&&setTimeout(N,0);let te=()=>{let t=[...e.querySelectorAll(`[data-stillmade-share]`)];if(t.length>100)throw Error(`Use at most 100 shared controls`);for(let n of t){let t=n.getAttribute(`data-stillmade-share`),r=n.id;if(typeof t!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(t)||typeof r!=`string`||!r||r.length>200||e.getElementById(r)!==n)throw Error(`Each data-stillmade-share control needs a unique ID and valid shared field name`);D(t,r)}return t.length},P=()=>{if(d)throw Error(`Block closed before edits could be flushed`);if([...a.values()].some(e=>e.status().composing))throw Error(`Finish composing text before leaving this Block or running an action.`);let e=[...a.values()].find(e=>e.status().interrupted);if(e)throw e.status().problem};return{bindShared:D,bindAnnotated:te,bindAutomatic:N,ownSharing:M,scheduleSharedEdit:h,flushAll:async()=>{if(d)throw Error(`Block closed before edits could be flushed`);for(let e=0;e<32;e++){if(d)throw Error(`Block closed before edits could be flushed`);P();let e=[...l];for(let[t,n]of[...c])e.push(m(t,n));for(let t of a.values())e.push(t.flush());if(await Promise.all(e),d)throw Error(`Block closed before edits could be flushed`);if(u.size)throw u.values().next().value;let t=!1;for(let e of a.values()){let n=e.status();if(n.problem)throw n.problem;if(n.composing)throw Error(`Finish composing text before leaving this Block or running an action.`);if(n.dirty&&!n.canEdit)throw Error(`Editing access changed. Your draft is not saved.`);t||=n.dirty||n.saving}if(!t&&!c.size&&!l.size)return{queued:!0}}throw Error(`Edits are still arriving. Finish editing before leaving this Block.`)},assertNoComposition:P,getBindingStatus:e=>a.get(e)?.status(),setSharedDefaults(e){if(!e||typeof e!=`object`||Array.isArray(e)||Object.keys(e).length>100||JSON.stringify(e).length>65536)throw Error(`Use bounded shared control defaults`);for(let[t,n]of Object.entries(e))a.get(t)?.setDefault(n)},useInputDefaults(e){let t=f;if(f={},e&&typeof e==`object`&&!Array.isArray(e))for(let[t,n]of Object.entries(e))[`string`,`number`,`boolean`].includes(typeof n)&&(f[t]=n);for(let[e,n]of a)if(Object.hasOwn(f,e)&&!(Object.hasOwn(t,e)&&t[e]===f[e]))try{(n.setInputDefault||n.setDefault)?.call(n,f[e])}catch{}},dispose(){d=!0,w?.disconnect(),T&&clearTimeout(T);for(let e of c.values())clearTimeout(e.timer);c.clear();for(let e of[...a.values()])e.dispose()}}}function rs(e,t,n,r,i,a=null){let o=new Map,s=new Map,c=[],l=0,u=!1,d=``,f=()=>{if(u)return;let e=[...o.values()].map(e=>e.status()),t={count:e.length,dirty:e.filter(e=>e.dirty||e.composing||e.interrupted).length,pending:e.filter(e=>e.saving).length,readonly:e.filter(e=>!e.canEdit).length,error:e.find(e=>e.problem)?.problem.message?.slice(0,1e3)||null,retryable:e.some(e=>e.retryable)},n=JSON.stringify(t);n!==d&&(d=n,parent.postMessage({channel:r,session:i,op:`text-recovery-status`,status:t},`*`),a&&a.send({channel:r,session:i,op:`named-text-controls`,token:a.token,snapshot:[...o.values()].map(e=>e.nativeState?.()).filter(Boolean).slice(0,50)},`*`))},p=e=>Object.assign(Error(e?.message||String(e)),e?.code?{code:e.code}:{}),m=()=>{for(;!u&&s.size<4&&c.length;){let e=c.findIndex(e=>e.action!==`read`),t=c.splice(e<0?0:e,1)[0],n=String(++l);t.id=n,s.set(n,t),(a?.send||parent.postMessage.bind(parent))({channel:r,session:i,op:`text-request`,id:n,action:t.action,key:t.key,body:t.body,...t.nativeProof&&a?{nativeText:{token:a.token,callId:t.nativeProof.callId}}:{}},`*`)}},h=(e,t,n={},r=null)=>new Promise((i,a)=>{if(u||s.size+c.length>=128){a(Error(`Shared text is unavailable or busy. Your draft is retained.`));return}let o={action:e,key:t,body:n,nativeProof:r,resolve:i,reject:a,timer:null,id:null};o.timer=setTimeout(()=>{if(o.id)s.delete(o.id);else{let e=c.indexOf(o);e>=0&&c.splice(e,1)}a(Error(`Shared text acknowledgement timed out. Your draft is retained.`)),m()},3e4),c.push(o),m()}),g=e=>{let t=e.data;if(!(e.source!==parent||t?.channel!==r||t.session!==i||u)){if(t.op===`text-result`){let e=s.get(t.id);if(!e)return;s.delete(t.id),clearTimeout(e.timer),t.error?e.reject(p(t.error)):e.resolve(t.result),m()}else if(t.op===`text-refresh`)for(let e of o.values())e.refresh();else if(t.op===`text-retry`)for(let e of o.values())e.retry().catch(()=>{})}};addEventListener(`message`,g);let _=(r,i)=>{if(o.has(r)||o.size>=100)throw Error(`Use at most 100 distinct shared text controls.`);let s=new WeakMap,c=null,l=i.disabled,u=i.readOnly,d=i.value,m=`loading`,g=!1,_=null,v=null,y=null,b=null,x=!1,S=0,C=null,w=null,T=null,E=!1,D=!1,ee=!1,O=!1,k=null,A=null,j=null,M=t.getShared().canEdit===!0,N=i.value,te=()=>!!b&&!O&&!D&&M&&!/^(READ_ONLY|SHARED_TEXT_(SOURCE|EPOCH|CONFLICT|INPUT|LIMIT|STATE|UPDATE|PROTOCOL))$/.test(b.code||``),P=e=>{E||(b=p(e),D&&(O=!0),i.readOnly=!0,(x||O)&&(i.disabled=l),i.setCustomValidity(b.message),n(b.message),f())},F=()=>({start:i.selectionStart??0,end:i.selectionEnd??0,direction:i.selectionDirection||`none`}),ne=e=>{i.value!==e&&(i.value=e,queueMicrotask(()=>{E||t.announce?.()}))},I=t=>{if(N=v.getValue(),ne(N),t&&e.activeElement===i){let e=v.resolveSelection(t);i.setSelectionRange(e.start,e.end,e.direction)}},re=()=>{let e=F();return v.captureSelection(e.start,e.end,e.direction)},L=e=>{if(!E&&e){if(b||O){(!A||e.textRevision>=A.textRevision)&&(A=e);return}if(D){(!A||e.textRevision>=A.textRevision)&&(A=e);return}if(v&&i.value!==N)throw O=!0,x=!0,Error(`This control has an uncommitted draft. Copy it before reopening the Block.`);if(y&&e.epoch!==y.epoch)throw Object.assign(Error(`This shared text was reset. Copy your draft before reloading the Block.`),{code:`SHARED_TEXT_EPOCH`});if(!(y&&e.textRevision<y.textRevision)){if(y&&e.protocol===y.protocol&&e.sourceIdentity===y.sourceIdentity&&e.textRevision===y.textRevision&&e.state===y.state&&e.value===y.value){y=e;return}if(!v)v=ts(e),y=e,I();else{let t=re();v.receive(e),y=e,I(t)}m=`text`,i.disabled=l||!M,i.readOnly=u,i.setCustomValidity(``),f()}}},ie=()=>{m=`legacy`,i.disabled=l,i.readOnly=u,i.value=d,_=ns(e,t,n),_.ownSharing(),_.bindShared(r,i.id),_.setSharedDefaults({[r]:d}),queueMicrotask(()=>{E||t.announce?.()})},ae=async(e=!1)=>E||!g||m===`legacy`||k||b?k:(k=(async()=>{let t=await h(`read`,r);if(E)return;if(t.unsupported){if(e)ie();else throw Error(`Shared text is no longer available. Your draft is retained.`);return}if(t.enabled){L(t.snapshot);return}if(!M){m=`waiting`,N=t.value,ne(t.value),i.disabled=!0;return}j={action:`initialize`,body:{protocol:1,requestId:crypto.randomUUID(),sourceIdentity:t.sourceIdentity}};let n=await h(j.action,r,j.body);j=null,E||L(n.snapshot)})().catch(P).finally(()=>{k=null,f()}),f(),k),oe=()=>{E||b||D||(T===null&&(T=Date.now()),clearTimeout(w),w=setTimeout(()=>{w=null,se().catch(()=>{})},Math.max(0,Math.min(200,600-(Date.now()-T)))))},se=async()=>{if(clearTimeout(w),w=null,_)return _.flushAll();if(k&&await k,b)throw b;if(E)throw Error(`Block closed before text was saved.`);if(!g||m===`loading`)throw Error(`Shared text is still loading. Wait before leaving this Block or running an action.`);if(D)throw Error(`Finish composing text before leaving this Block or running an action.`);if(v&&i.value!==N)throw O=!0,x=!0,P(Error(`This control has an uncommitted draft. Copy it before reopening the Block.`)),b;if(C){await C;return}if(!x)return;if(!M)throw Error(`Editing access changed. Your draft is retained.`);try{j={action:`update`,version:S,nativeProof:c?.version===S?{callId:c.callId}:null,body:{...v.getUpdateSince(y),requestId:crypto.randomUUID()}}}catch(e){throw P(e),e}x=!1,T=null;let e=j;C=h(e.action,r,e.body,e.nativeProof).then(t=>{E||(L(t.snapshot),!b&&!O&&(x=S!==e.version)),j=null}).catch(e=>{throw x=!0,P(e),e}).finally(()=>{C=null,x&&!b&&oe(),f()}),f(),await C},ce=e=>{if(m!==`text`||E||l||u||!M||O)return;if(e?.isComposing){R();return}if(D)return;if(b){i.value!==N&&(O=!0,x=!0,f());return}let t=i.value;if(t!==N)try{let n=0,r=N.length,i=t.length;for(;n<r&&n<i&&N[n]===t[n];)n++;for(n>0&&n<r&&/[\\uDC00-\\uDFFF]/.test(N[n])&&n--;r>n&&i>n&&N[r-1]===t[i-1];)r--,i--;r<N.length&&/[\\uDC00-\\uDFFF]/.test(N[r])&&(r++,i++),v.splice(n,r-n,t.slice(n,i)),N=v.getValue(),S++,c=s.has(e)?{version:S,callId:s.get(e)}:null,x=!0,oe(),f()}catch(e){O=!0,x=!0,P(e)}},R=()=>{m!==`text`||E||!M||l||u||b||(D=!0,clearTimeout(w),w=null,f())},le=()=>{if(D){if(D=!1,b||!M||ee){O=!0,x=!0,b||P(Error(`Editing access changed. Your composed draft is retained.`));return}if(ce(),A){let e=A;A=null;try{L(e)}catch(e){P(e)}}x&&oe(),f()}},ue=e=>{if(!(m!==`text`||D||b||!M||l||u||!(e.metaKey||e.ctrlKey)||e.altKey||![`z`,`y`].includes(e.key.toLowerCase()))){e.preventDefault();try{e.key.toLowerCase()===`y`||e.shiftKey?v.redo():v.undo(),I(),S++,x=!0,oe(),f()}catch(e){P(e)}}},de=()=>{m===`text`&&se().catch(()=>{})},fe=t.onShared(e=>{g=!0,M=e.canEdit===!0,m!==`legacy`&&(i.disabled=l||m!==`text`||!M,!M&&(x||D)&&(ee||=D,O=!0,P(Error(`Editing access changed. Your unsaved draft is retained.`))),o.has(r)&&m===`loading`&&ae(!0),f())});i.disabled=!0,i.addEventListener(`input`,ce),i.addEventListener(`change`,ce),i.addEventListener(`blur`,de),i.addEventListener(`keydown`,ue),i.addEventListener(`compositionstart`,R),i.addEventListener(`compositionend`,le);let pe=()=>{let e=String(i.value),t=i.hidden||i.closest(`[hidden]`)!==null;return{field:r,nodeId:i.id,type:i.tagName.toLowerCase()===`textarea`?`textarea`:i.type,value:e.slice(0,1e4),partial:e.length>1e4,disabled:i.disabled||l||u||t,ready:m===`text`&&!E&&!b&&!O&&!D&&!C&&!k&&!x&&!j&&M,identity:JSON.stringify([r,i.id,i.type,y?.protocol??null,y?.epoch??null,y?.sourceIdentity??null,y?.textRevision??null])}},me={nativeState:pe,async nativeEdit(e,t){let n=pe();if(!a||typeof t!=`string`||!/^\\d{1,9}$/.test(t)||!e||Object.keys(e).sort().join(`,`)!==`field,identity,previous,value`||e.field!==r||e.identity!==n.identity||n.partial||!n.ready||n.disabled||typeof e.previous!=`string`||e.previous!==n.value||typeof e.value!=`string`||e.value.length>1e4||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(r)||/password|credential|authorization|cookie|secret|token|api.?key/i.test(r)||!i.id||![`text`,`textarea`].includes(n.type))throw Error(`The original named text control changed or is unavailable.`);let o=new Event(`input`,{bubbles:!0});if(s.set(o,t),i.value=e.value,i.dispatchEvent(o),s.delete(o),i.value!==e.value||!x||D||O||b)throw Error(`The original text handler changed or refused this edit.`);let c=S;if(await se(),S!==c||i.value!==e.value||x||j||C||b)throw Error(`Original text changed while its acknowledgement was pending. Do not repeat the edit.`);return{value:i.value,identity:pe().identity}},flush:se,getValue:()=>i.value,status:()=>_?_.getBindingStatus(r):{dirty:x||!!j,saving:!!C||!!k,problem:b,canEdit:M,composing:D,interrupted:O,retryable:te()},setDefault(e){d=String(e??``),_&&_.setSharedDefaults({[r]:e})},refresh(){!b&&!E&&ae()},async retry(){if(!(E||C||k||!te())){if(b=null,i.setCustomValidity(``),j){let e=j;C=h(e.action,r,e.body,e.nativeProof).then(t=>{L(t.snapshot),e.action===`update`&&!b&&!O&&(x=S!==e.version),j=null}).catch(e=>{throw P(e),e}).finally(()=>{C=null,f()}),f(),await C}else await ae(m===`loading`);if(b)throw b;if(i.readOnly=u,A){let e=A;A=null;try{L(e)}catch(e){throw P(e),e}}x&&await se(),f()}},dispose(){E=!0,clearTimeout(w),fe(),_?.dispose(),v?.dispose(),o.delete(r),i.removeEventListener(`input`,ce),i.removeEventListener(`change`,ce),i.removeEventListener(`blur`,de),i.removeEventListener(`keydown`,ue),i.removeEventListener(`compositionstart`,R),i.removeEventListener(`compositionend`,le),i.disabled=l,i.readOnly=u,f()}};return o.set(r,me),g&&ae(!0),me},v=setInterval(()=>{for(let e of o.values())e.refresh()},15e3);return{bind:_,inspectNative(){return[...o.values()].map(e=>e.nativeState()).filter(e=>e.nodeId&&[`text`,`textarea`].includes(e.type)&&!/password|credential|authorization|cookie|secret|token|api.?key/i.test(e.field)).slice(0,50)},async dispatchNative(e,t){if(!e||typeof e.field!=`string`||!o.has(e.field))throw Error(`Inspect an existing original named text field.`);return o.get(e.field).nativeEdit(e,t)},getValues:()=>Object.fromEntries([...o].map(([e,t])=>[e,t.getValue()])),dispose(){u=!0,clearInterval(v),removeEventListener(`message`,g);for(let e of[...o.values()])e.dispose();for(let e of[...s.values(),...c])clearTimeout(e.timer),e.reject(Error(`Block closed before text was acknowledged.`));s.clear(),c.length=0}}}return e.installTextFrame=rs,e})({});',nr=`(sharedAPI,onStatus)=>{const documentTools=(()=>{const BlockError=(class extends Error {
9
+ `)}var et,tt,nt,rt,it,at,ot,st,ct,lt,ut=o((()=>{et=e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),tt=new Set([`__proto__`,`prototype`,`constructor`]),nt=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,rt=Object.freeze({fileName:255,documentText:1e6,documentTitle:300,tableColumns:500,tableRows:1e5,tableCells:5e5,columnName:160,cellText:1e5,url:8192}),it=Object.freeze({pdf:`application/pdf`,txt:`text/plain`,csv:`text/csv`,md:`text/markdown`,json:`application/json`,zip:`application/zip`}),at=Object.freeze([...new Set(Object.values(it))]),ot=Object.freeze([`markdown`,`plain`]),st=e=>e===null||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e)||typeof e==`string`&&e.length<=rt.cellText,ct=/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(?:Z|[+-](\d{2}):(\d{2}))?)?$/,lt=e=>{let t=e==null?``:String(e);return/[",\r\n]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t}})),dt=o((()=>{Object.freeze({origins:8,requestBytes:4194304,responseBytes:8388608,timeoutMs:3e4,redirects:3,headers:32,headerBytes:16384,urlLength:8192,requestsPerMinute:120,originRequestsPerMinute:3e3,keyLength:4096}),Object.freeze([`GET`,`HEAD`,`POST`,`PUT`,`PATCH`,`DELETE`]),Object.freeze([`bearer`,`header`,`query`,`oauth2`]),Object.freeze({sockets:4,messageBytes:1048576,runBytes:268435456,protocols:8})})),ft=o((()=>{Object.freeze([`media.saved`,`schedule`,`webhook`,`project.completed`,`provider`]),Object.freeze({triggers:4,labelLength:120,minEverySeconds:60,maxEverySeconds:31536e3}),Object.freeze([`recipe`,`javascript`,`capability`])})),pt=o((()=>{Object.freeze({features:24,id:48,label:40,does:160,asks:8,ask:80})}));function mt(e,t=0,n={nodes:0}){if(B(t<=40&&++n.nodes<=5e5,`LIMIT`,`Document exceeds complexity limit`),!(e===null||[`string`,`boolean`].includes(typeof e))){if(typeof e==`number`){B(Number.isFinite(e),`SCHEMA`,`Numbers must be finite`);return}B(Array.isArray(e)||vt(e),`SCHEMA`,`Only JSON data is accepted`);for(let[r,i]of Object.entries(e))B(!Tt.has(r),`SCHEMA`,`Forbidden field: ${r}`),mt(i,t+1,n)}}function ht(e){mt(e);let t=e=>Array.isArray(e)?e.map(t):vt(e)?Object.fromEntries(Object.keys(e).sort().map(n=>[n,t(e[n])])):e;return JSON.stringify(t(e))}async function gt(e){let t=new TextEncoder().encode(ht(e)),n=await globalThis.crypto.subtle.digest(`SHA-256`,t);return Array.from(new Uint8Array(n),e=>e.toString(16).padStart(2,`0`)).join(``)}function _t(e,t){if(typeof t==`object`&&t&&t.schema!=null&&!ce(e,t.schema))return!1;let n=typeof t==`string`?t:t.type;if(n===`object`)try{return mt(e),vt(e)}catch{return!1}if(n?.endsWith(`[]`))return Array.isArray(e)&&e.every(e=>_t(e,n.slice(0,-2)));if(n===`text`)return typeof e==`string`&&e.length<=1e6;if(n===`boolean`)return typeof e==`boolean`;if(n===`url`)return Xe(e);if(n===`date`)return Ze(e);if(n===`color`)return Qe(e);if(n===`file`)return qe(e);if(n===`document`)return Je(e);if(n===`table`)try{return mt(e),Ye(e)}catch{return!1}if(n===`number`||n===`integer`)return typeof e==`number`&&Number.isFinite(e)&&(n!==`integer`||Number.isInteger(e))&&(t.min==null||e>=t.min)&&(t.max==null||e<=t.max);if(n===`file-bundle`)try{return mt(e),M(e)}catch{return!1}if(n===`workspace-edit`)try{return mt(e),we(e)}catch{return!1}if(n===`timeline-edit`)try{return mt(e),je(e)}catch{return!1}if(n===`timeline-range`||n===`approval`)return vt(e)&&e.schemaVersion===1?!0:n===`timeline-range`?he(e):ge(e);if(n===`json`)try{return mt(e),!0}catch{return!1}return n===`image`&&vt(e)&&Array.isArray(e.data)?Number.isInteger(e.width)&&Number.isInteger(e.height)&&e.width>0&&e.height>0&&e.width*e.height<=1048576&&e.data.length===e.width*e.height*4&&e.data.every(e=>Number.isInteger(e)&&e>=0&&e<=255):[`image`,`video`,`audio`,`asset`].includes(n)?vt(e)&&typeof e.assetId==`string`&&typeof e.versionId==`string`&&(n===`asset`||e.kind===n):yt.includes(n)&&vt(e)&&e.schemaVersion===1}var B,vt,yt,bt,xt,St,Ct,wt,Tt,Et=o((()=>{k(),R(),ae(),ue(),fe(),pe(),me(),be(),xe(),Ce(),De(),Ue(),Ge(),Ke(),ut(),dt(),ft(),pt(),B=ne,vt=re,Object.freeze([`type`,`required`,`default`,`min`,`max`,`description`,`role`,`primary`,`context`,`imageMode`,...le]),yt=Object.freeze(`text.number.integer.boolean.json.object.image.video.audio.asset.script.transcript.brief.bible.shot-plan.panel-document.board-document.scene-document.timeline.timeline-edit.file-bundle.workspace-edit.timeline-range.research.character.location.style.pipeline.approval.scene.shot.mask.depth.pose.metadata.project-context.file.document.table.url.date.color`.split(`.`)),Object.freeze([`final.render`,`stock.search`,`stock.select`,`stock.auto`,`gif.search`,`gif.save`,`presenter.generate`,`quality.analyze`,`image.generate`,`image.generate.batch`,`media.generate`,`youtube.upload`]),Object.freeze([`text`,`number`,`slider`,`checkbox`,`asset`,`select`,`multiselect`,`file`,`date`,`color`,`url`,`richtext`,`list`,`grid`]),Object.freeze([`gallery`,`before-after`,`table`,`document`,`chart`,`code`,`player`,`download`]),Object.freeze({file:[`file`,`file[]`],date:[`date`],color:[`color`],url:[`url`],richtext:[`document`,`text`],list:[`text[]`,`number[]`,`integer[]`,`url[]`,`date[]`,`color[]`],grid:[`table`]}),Object.freeze({gallery:[`image[]`],"before-after":[`image`],table:[`table`],document:[`document`,`text`],chart:[`table`,`number[]`,`integer[]`],code:[`text`,`json`,`object`],player:[`audio`,`video`,`audio[]`,`video[]`],download:[`file`,`file[]`,`file-bundle`]}),bt=Object.freeze({script:`script`,transcript:`transcript`,shots:`shot[]`,shotPlan:`shot-plan`,scenes:`scene[]`,characters:`character[]`,locations:`location[]`,styles:`style[]`,assets:`asset[]`,files:`file[]`,generations:`metadata[]`,versions:`metadata[]`,timeline:`timeline`,editor:`timeline`,canvas:`pipeline`,blueprint:`bible`,panels:`panel-document`,board:`board-document`,animation:`scene-document`,metadata:`metadata`}),xt=(e,t,n,r)=>Object.freeze({executor:e,mode:t,byok:n,summary:r}),St=Object.freeze({"text.generate":xt(`capability-run`,`sync`,!0,`Exact model, account BYOK or credits, and explicit run review`),"audio.speech":xt(`capability-run`,`sync`,!0,`One short text/script input to measured audio in any StillMade catalog voice (Deepgram, ElevenLabs, OpenAI, Kokoro) with credits, or OpenAI with your key; playback review; accepted project recordings can be explicitly added to Editor audio`),"audio.transcribe":xt(`capability-run`,`sync`,!0,`One owner-scoped stored audio asset to reviewed text and ordered word timings with StillMade transcription on credits, or OpenAI Whisper with your key`),"audio.music":xt(`capability-run`,`sync`,!1,`One prompt to generated music (5–240 seconds) with StillMade credits and playback review`),"audio.sfx":xt(`capability-run`,`sync`,!1,`One prompt to a generated sound effect (0.5–22 seconds) with StillMade credits and playback review`),"image.generate":xt(`capability-run`,`sync`,!0,`One prompt and optional reference images to a stored PNG with any catalog image model and its settings; StillMade credits or account key, and actual image review`),"video.generate":xt(`capability-run`,`async`,!0,`One prompt and optional first/last frames to a measured stored video clip with any catalog video model and its settings; StillMade credits and actual video review`),"image.describe":xt(`capability-run`,`sync`,!0,`One to four owned images to bounded production notes; host-selected model/payment and actual description review`),"media.analyze":xt(`capability-run`,`sync`,!1,`One owned video (optionally one time range), image or up to four images to structured visual evidence: summary, timeline, observations, on-screen text and issues, with StillMade credits; detail "check" gives one to four photos a short answer each at one price per call`),"web.fetch":xt(`capability-run`,`sync`,!1,`One public web page read by the host and answered against the Block's instruction, with StillMade credits; no cookies, keys or private addresses`),"web.research":xt(`capability-run`,`sync`,!1,`One topic searched on the web and summarized with cited sources, with StillMade credits`),"timeline.propose":xt(`capability-run`,`sync`,!0,`Bounded typed context to strict timeline-edit JSON; host-selected model/payment, stale-before checks, preview and Apply`),"workspace.propose":xt(`capability-run`,`sync`,!0,`Bounded typed context to a strict workspace-edit proposal for one permitted workspace; preview and explicit Apply`),"connection.execute":xt(`connection`,`sync`,!1,`One reviewed action on a connected third-party app account through the host connection service; the Block never receives account credentials`)}),Ct=e=>Object.freeze(Object.entries(St).filter(([,t])=>e(t)).map(([e])=>e)),Ct(()=>!0),wt=Ct(e=>e.executor===`capability-run`),Ct(e=>e.executor===`capability-run`&&e.mode===`sync`),Ct(e=>e.byok),[...Object.keys(bt).map(e=>`context.${e}.read`)],Tt=new Set([`__proto__`,`prototype`,`constructor`])}));Et();var Dt=Object.freeze([`tasks`,`preview-task`,`apply-task`]);function Ot(e,t={}){return B(Dt.includes(e),`CONNECTION_TASK`,`Choose a declared task operation.`),mt(t),B(vt(t)&&JSON.stringify(t).length<=32768,`CONNECTION_TASK`,`Use bounded task selection arguments.`),{operation:e,args:structuredClone(t)}}function kt(e,t,n,r){let i=0,a=new Map;return addEventListener(`message`,n=>{let r=n.data;if(n.source!==parent||!r||r.channel!==e||r.session!==t||r.op!==`connected-app-result`)return;let i=a.get(r.id);i&&(a.delete(r.id),r.error?i.reject(Error(r.error)):i.resolve(r.result))}),{connectedApp(o,s={}){if(!n)return Promise.reject(Error(`This Block has no connected-app task contract.`));if(![`tasks`,`preview-task`,`apply-task`].includes(o)||!s||typeof s!=`object`||Array.isArray(s)||JSON.stringify(s).length>32768)return Promise.reject(Error(`Invalid task choice.`));if(a.size>=2)return Promise.reject(Error(`Wait for the current task choice.`));let c=String(++i);return new Promise((n,i)=>{a.set(c,{resolve:n,reject:i}),r({channel:e,session:t,op:`connected-app-request`,id:c,operation:o,args:s},`*`)})}}}function At(e,t,n,r){let i=new Set,a=new Set,o=new Set,s=(e,t)=>{if(typeof t!=`function`)throw TypeError(`Pass a function.`);return e.add(t),()=>{e.delete(t)}},c=e=>{typeof reportError==`function`&&reportError(e)},l=(e,...t)=>{for(let n of[...e])try{n(...t)}catch(e){c(e)}};return{live:Object.freeze({start:(e={})=>r(`live.start`,e),stop:()=>r(`live.stop`,{}),status:()=>r(`live.status`,{}),onFrame:e=>s(i,e),onAudio:e=>s(a,e),onEnd:e=>s(o,e)}),receive:r=>{if(r.op!==`live`)return!1;if(r.type===`frame`)try{l(i,r.bitmap,{index:r.index,timestamp:r.timestamp,width:r.width,height:r.height})}finally{try{r.bitmap?.close?.()}catch{}n({channel:e,session:t,op:`live-ack`},`*`)}else r.type===`audio`?l(a,r.samples,{index:r.index,timestamp:r.timestamp,sampleRate:r.sampleRate}):r.type===`ended`&&l(o,{reason:String(r.reason||`stopped`)});return!0},dispose(){i.clear(),a.clear(),o.clear()}}}function jt(e){let t=0,n=null,r=[],i=0,a=new Map,o=()=>{if(n||!r.length)return;let s=r.shift();n=s,Promise.resolve().then(()=>{if(s.generation!==t)throw Error(`Preview input changed`);return s.edge===void 0?e(s.kind,s.value):e(s.kind,s.value,{edge:s.edge})}).then(e=>{s.kind===`image`&&s.generation===t&&(a.delete(s.serialized),a.set(s.serialized,e),a.size>48&&a.delete(a.keys().next().value)),s.resolve(e)},s.reject).finally(()=>{n===s&&(n=null,i-=s.bytes,o())})};return{request(e,s,c){let l,u,d,f;try{if(![`image`,`media`].includes(e)||!s||Array.isArray(s)||typeof s!=`object`)throw Error(`Expected a bounded preview value`);if(d=c?.edge,d!==void 0&&(e!==`image`||!Number.isInteger(d)||d<64||d>2048))throw Error(`Ask for an image preview edge from 64 to 2048 pixels, as in StillMade.previewImage(photo, {edge: 2048}).`);if(f=JSON.stringify(s),l=d===void 0?f:`${f}@${d}`,u=new TextEncoder().encode(f).length,u>4194304)throw Error(`Expected a bounded preview value`)}catch(e){return Promise.reject(e)}if(e===`image`&&a.has(l))return Promise.resolve(a.get(l));let p=e===`image`&&[n,...r].find(t=>t?.kind===e&&t.serialized===l);if(p)return p.promise;if(r.length+ +!!n>=64||i+u>8388608)return Promise.reject(Error(`Too many queued previews. Wait for a preview to finish.`));let m={kind:e,value:JSON.parse(f),serialized:l,bytes:u,generation:t,edge:d};return m.promise=new Promise((e,t)=>{m.resolve=e,m.reject=t}),i+=u,r.push(m),o(),m.promise},reset(e=`Preview input changed`){t+=1;for(let t of[n,...r])t&&t.reject(Error(e));n=null,r=[],i=0}}}function Mt(){return null}function Nt(){try{return typeof indexedDB<`u`&&indexedDB!==null}catch{return!1}}function Pt(){return Ht||(Ht=new Promise((e,t)=>{let n;try{n=indexedDB.open(It,Lt)}catch(e){t(e);return}n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(`cacheMeta`)||e.createObjectStore(Rt,{keyPath:`key`}),e.objectStoreNames.contains(`blobs`)||e.createObjectStore(zt),e.objectStoreNames.contains(`handles`)||e.createObjectStore(Bt),e.objectStoreNames.contains(`deviceMedia`)||e.createObjectStore(Vt,{keyPath:`id`})},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),Ht=null},e(t)},n.onerror=()=>t(n.error||Error(`indexedDB open failed`)),n.onblocked=()=>t(Error(`indexedDB blocked`))}),Ht.catch(()=>{Ht=null}),Ht)}function Ft(e,t,n){return Pt().then(r=>new Promise((i,a)=>{let o;try{o=r.transaction(e,t)}catch(e){a(e);return}let s;try{s=n(o.objectStore(e))}catch(e){a(e);return}o.oncomplete=()=>i(s?s.result:void 0),o.onerror=()=>a(o.error||Error(`idb tx error`)),o.onabort=()=>a(o.error||Error(`idb tx aborted`))}))}var It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt=o((()=>{It=`aivw_editor`,Lt=2,Rt=`cacheMeta`,zt=`blobs`,Bt=`handles`,Vt=`deviceMedia`,Ht=null,Ut=(e,t)=>Ft(e,`readonly`,e=>e.get(t)),Wt=e=>Ft(e,`readonly`,e=>e.getAll()),Gt=(e,t,n)=>Ft(e,`readwrite`,e=>n===void 0?e.put(t):e.put(t,n)),Kt=(e,t)=>Ft(e,`readwrite`,e=>e.delete(t))}));function Jt(){try{return typeof localStorage>`u`?null:JSON.parse(localStorage.getItem(Yt)||`null`)?.user?.id||null}catch{return null}}var Yt,Xt=o((()=>{Yt=`ai-video-workflow-auth`}));function Zt(){let e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),t=new Uint32Array(64),n=new Uint8Array(64),r=0,i=0,a=(n,r)=>{for(let e=0;e<16;e++)t[e]=n[r+e*4]<<24|n[r+e*4+1]<<16|n[r+e*4+2]<<8|n[r+e*4+3];for(let e=16;e<64;e++){let n=en(t[e-15],7)^en(t[e-15],18)^t[e-15]>>>3,r=en(t[e-2],17)^en(t[e-2],19)^t[e-2]>>>10;t[e]=t[e-16]+n+t[e-7]+r>>>0}let i=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=e[5],u=e[6],d=e[7];for(let e=0;e<64;e++){let n=en(c,6)^en(c,11)^en(c,25),r=c&l^~c&u,f=d+n+r+$t[e]+t[e]>>>0,p=(en(i,2)^en(i,13)^en(i,22))+(i&a^i&o^a&o)>>>0;d=u,u=l,l=c,c=s+f>>>0,s=o,o=a,a=i,i=f+p>>>0}e[0]=e[0]+i>>>0,e[1]=e[1]+a>>>0,e[2]=e[2]+o>>>0,e[3]=e[3]+s>>>0,e[4]=e[4]+c>>>0,e[5]=e[5]+l>>>0,e[6]=e[6]+u>>>0,e[7]=e[7]+d>>>0};return{update(e){let t=e instanceof Uint8Array?e:new Uint8Array(e);i+=t.length;let o=0;if(r){let e=Math.min(64-r,t.length);if(n.set(t.subarray(0,e),r),r+=e,o=e,r<64)return this;a(n,0),r=0}for(;o+64<=t.length;o+=64)a(t,o);return o<t.length&&(n.set(t.subarray(o),0),r=t.length-o),this},digest(){let t=i*8,o=new Uint8Array(r<56?64:128);o.set(n.subarray(0,r)),o[r]=128;let s=new DataView(o.buffer);s.setUint32(o.length-8,Math.floor(t/4294967296)),s.setUint32(o.length-4,t>>>0);for(let e=0;e<o.length;e+=64)a(o,e);return[...e].map(e=>e.toString(16).padStart(8,`0`)).join(``)}}}async function Qt(e,{subtleLimit:t=tn,signal:n}={}){if(e.size<=t&&typeof crypto?.subtle?.digest==`function`){let t=await crypto.subtle.digest(`SHA-256`,await e.arrayBuffer());return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}let r=Zt();for(let t=0;t<e.size;t+=nn)n?.throwIfAborted?.(),r.update(new Uint8Array(await e.slice(t,t+nn).arrayBuffer()));return r.digest()}var $t,en,tn,nn,rn=o((()=>{$t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),en=(e,t)=>e>>>t|e<<32-t,tn=67108864,nn=8388608}));function an(){if(Fn!==void 0)return Fn;try{return Jt()||null}catch{return null}}async function on(){if(Nn!==void 0)return Nn;try{Nn=navigator?.storage?.getDirectory?await(await navigator.storage.getDirectory()).getDirectoryHandle(xn,{create:!0}):null}catch{Nn=null}return Nn}async function sn(){if(!Pn){Pn=!0;try{await navigator?.storage?.persist?.()}catch{}}}async function cn(e,t){let n=await on();if(n){let r=await(await n.getFileHandle(t,{create:!0})).createWritable();return await r.write(e),await r.close(),`opfs`}return await Gt(zt,e,`device:${t}`),`idb`}function ln(){try{window.dispatchEvent(new CustomEvent(Mn,{detail:{needed:jn.size}}))}catch{}}async function un(e){let t=Bn(e);if(typeof t?.getFile!=`function`)throw zn(`DEVICE_MEDIA_MOVED`,`This file is no longer linked on this computer.`);if(typeof t.queryPermission==`function`&&await t.queryPermission({mode:`read`})!==`granted`)throw jn.has(e.id)||(jn.set(e.id,t),ln()),zn(`DEVICE_MEDIA_ACCESS`,`Allow StillMade to open this file on your computer again.`);let n;try{n=await t.getFile()}catch{throw zn(`DEVICE_MEDIA_MOVED`,`This file was moved, renamed or deleted on this computer.`)}if(n.size!==e.bytes||e.lastModified&&n.lastModified!==e.lastModified)throw zn(`DEVICE_MEDIA_CHANGED`,`This file changed on this computer after it was added.`);return n}async function dn(e){if(e.storage===`linked`)return un(e);if(e.storage===`opfs`){let t=await on();if(!t)throw Error(`Device storage is unavailable.`);return(await t.getFileHandle(e.versionId)).getFile()}let t=await Ut(zt,`device:${e.versionId}`);if(!t)throw Error(`This media is not on this device.`);return t}function fn(){return Nt()&&typeof crypto?.subtle?.digest==`function`}async function pn(e,{kind:t,metadata:n={},role:r=`original`,links:i={},assetId:a=crypto.randomUUID(),signal:o,maxBytes:s=Sn,handle:c=null}={}){if(!fn())throw Error(`This browser cannot keep media on the device.`);if(!c&&e.size>s)throw Error(`Files over ${Math.round(s/1024/1024)>=1024?`${Math.round(s/1024/1024/1024*10)/10} GB`:`${Math.round(s/1024/1024)} MB`} stay where they are; use StillMade Desktop for larger media.`);o?.throwIfAborted?.(),await sn();let l=await Ln(e,o);o?.throwIfAborted?.();let u=await Wt(Vt).then(e=>e.find(e=>e.versionId===l&&e.kind===t)).catch(()=>null),d=c?`linked`:[`opfs`,`idb`].includes(u?.storage)?u.storage:await cn(e,l);o?.throwIfAborted?.(),c&&An.set(l,c);let f={id:`${a}:${l}`,assetId:a,versionId:l,kind:t,role:r,name:String(e.name||``).slice(0,240),mimeType:e.type||n.mimeType||``,bytes:e.size,...Vn(n,[`width`,`height`,`duration`]),storage:d,...c?{handle:c,lastModified:e.lastModified}:{},source:`local`,...i,...an()?{owner:an()}:{},cloud:{},createdAt:Date.now()};return await Gt(Vt,f),f}async function mn(e){if(!e?.assetId||!e?.versionId)return null;let t=await Ut(`deviceMedia`,Rn(e)).catch(()=>null)||null;return t&&In(t)?t:null}async function hn(e,t=Hn.get(Tn(e))){if(!t)return null;let n=e=>fetch(t,{credentials:`omit`,redirect:`follow`,referrerPolicy:`no-referrer`,...e?{cache:e}:{}}),r;try{r=await n()}catch(e){if(!(e instanceof TypeError))return null;try{r=await n(`reload`)}catch{return null}}if(!r?.ok)return null;let i=await r.blob();return await Ln(i)===e.versionId?i:null}async function gn(e){let t=await mn(e);if(t)return dn(t);let n=await hn(e).catch(()=>null);if(!n)throw Error(`This media is not on this device.`);return n}async function _n(e){let t=Rn(e);if(On.has(t))return On.get(t);let n=URL.createObjectURL(await gn(e));return On.set(t,n),kn.add(n),n}async function vn(e){let t=En(e);if(!t)return null;try{return await _n(t)}catch{return null}}function yn(e,{role:t,name:n}={}){let r={kind:e.kind,assetId:e.assetId,versionId:e.versionId,url:Tn(e),source:`local`,name:n||e.name,mimeType:e.mimeType,bytes:e.bytes};for(let t of[`width`,`height`,`duration`])e[t]!==void 0&&e[t]!==null&&(r[t]=e[t]);return t&&(r.role=t),r}async function bn(){let e=(await Wt(Vt).catch(()=>[])).filter(e=>e.storage!==`linked`),t=new Set,n=e.reduce((e,n)=>t.has(n.versionId)?e:(t.add(n.versionId),e+(n.bytes||0)),0),r=null;try{r=(await navigator.storage.estimate()).quota||null}catch{}return{files:t.size,bytes:n,quota:r}}var xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un=o((()=>{qt(),Xt(),rn(),xn=`device-media`,Sn=268435456,Cn=`sm-media://device/`,wn=/^sm-media:\/\/device\/([a-f0-9-]{36})\/([a-f0-9]{64})$/,Tn=e=>`${Cn}${e.assetId}/${e.versionId}`,En=e=>{let t=wn.exec(String(e||``));return t?{assetId:t[1],versionId:t[2]}:null},Dn=e=>wn.test(String(e||``)),On=new Map,kn=new Set,An=new Map,jn=new Map,Mn=`stillmade:device-media-access`,Pn=!1,In=e=>{let t=an();return!e?.owner||!t||e.owner===t},Ln=(e,t)=>Qt(e,{signal:t}),Rn=e=>`${e.assetId}:${e.versionId}`,zn=(e,t)=>Object.assign(Error(t),{code:e}),Bn=e=>An.get(e.versionId)||e.handle,Vn=(e,t)=>Object.fromEntries(t.filter(t=>e?.[t]!==void 0&&e[t]!==null).map(t=>[t,e[t]])),Hn=new Map}));Un();var Wn=Object.freeze({bytes:25165824,timeoutMs:15e3}),Gn=Object.freeze({image:[`image/png`,`image/jpeg`,`image/webp`,`image/gif`],video:[`video/mp4`,`video/webm`,`video/ogg`,`video/quicktime`],audio:[`audio/mpeg`,`audio/mp3`,`audio/mp4`,`audio/aac`,`audio/ogg`,`audio/wav`,`audio/x-wav`,`audio/wave`,`audio/webm`,`audio/flac`]});function Kn(e){if(!e||!Gn[e.kind]?.includes(e.blob?.type)||!(e.blob instanceof Blob)||!e.blob.size||!e.local&&e.blob.size>Wn.bytes)throw Error(`The host returned an unsupported or oversized media preview.`);return{kind:e.kind,blob:e.blob,...e.local===!0?{local:!0}:{}}}var qn=/^\/api\/media\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-][A-Za-z0-9._-]*$/;async function Jn(e,{signal:t,check:n=()=>{}}={}){if(n(),Dn(e.url)){let t=En(e.url),r=await mn(t);if(n(),!r)throw Error(`This media is not on this device. Open the project on the device that holds it.`);let i=await gn(t);n();let a=String(r.mimeType||i.type||``).split(`;`)[0].trim().toLowerCase();if(!Gn[e.kind]?.includes(a))throw Error(`Choose a supported audio or video file.`);return Kn({kind:e.kind,blob:i.type===a?i:new Blob([i],{type:a}),local:!0})}let r=n=>fetch(e.url,{signal:t,credentials:`omit`,redirect:qn.test(e.url)?`follow`:`error`,referrerPolicy:`no-referrer`,...n?{cache:n}:{}}),i;try{i=await r()}catch(a){if(a?.name===`AbortError`||!(a instanceof TypeError))throw a;n();try{i=await r(`no-store`)}catch(r){if(r?.name===`AbortError`||!(r instanceof TypeError))throw r;let a=Error(`This media could not reach StillMade. Check your connection and try again.`);if(!qn.test(e.url))throw a;n();try{i=await fetch(e.url.replace(/^\/api\/media\//,`/api/media/bytes/`),{signal:t,credentials:`omit`,redirect:`error`,referrerPolicy:`no-referrer`,cache:`no-store`})}catch(e){throw e?.name===`AbortError`?e:a}if(i.status===413)throw Error(`This media is too large to preview here. Download it to play it.`)}}if(n(),!i.ok)throw Error(`This media could not be loaded. Upload a local copy to preview it.`);let a=(i.headers.get(`content-type`)||``).split(`;`)[0].trim().toLowerCase();if(!Gn[e.kind]?.includes(a))throw Error(`Choose a supported audio or video file.`);if(Number(i.headers.get(`content-length`))>Wn.bytes)throw Error(`Preview media must be under 24 MB.`);if(!i.body?.getReader)throw Error(`Streaming media previews are unavailable in this browser.`);let o=i.body.getReader(),s=[],c=0;try{for(;;){if(n(),t?.aborted)throw new DOMException(`Media preview cancelled`,`AbortError`);let{done:e,value:r}=await o.read();if(n(),e)break;if(c+=r.byteLength,c>Wn.bytes)throw Error(`Preview media must be under 24 MB.`);s.push(r)}return Kn({kind:e.kind,blob:new Blob(s,{type:a})})}finally{await o.cancel().catch(()=>{}),o.releaseLock()}}var Yn=/^\/(sfx\/pops|sounds\/fx)\/[a-z0-9_-]{1,64}\.(wav|mp3)$/i;function Xn(e){if(typeof e!=`string`||e.length>512)return null;let t=/^https?:\/\/[^/]+(\/[^?#]*)$/.exec(e)?.[1]??(e.startsWith(`/`)?e.split(/[?#]/)[0]:null);return t&&Yn.test(t)?t:null}var Zn=e=>!!e&&e.kind===`audio`&&e.assetId===`stillmade-sound`&&typeof e.url==`string`&&Xn(e.url)===e.url&&e.versionId===e.url,Qn=new Set;function $n(e){return Qn.add(e),()=>Qn.delete(e)}function er(e,t,n,r=null,i=[]){let a=new Map,o=[`text`,`search`,`email`,`tel`,`url`],s=new Set(i),c=new Map,l=new Set,u=new Map,d=!1,f={},p=(e,t,n)=>e?e.some(e=>e.value===String(n)):t.tagName!==`SELECT`||[...t.options].some(e=>e.value===String(n)),m=(e,t)=>{if(clearTimeout(t.timer),c.delete(e),d)return;let r;return r=Promise.resolve().then(()=>{if(!d)return t.callback()}).catch(t=>{u.set(e,t),n(t.message)}).finally(()=>l.delete(r)),l.add(r),r},h=(e,t)=>{if(d)throw Error(`This interface has closed; shared edits stopped.`);if(typeof e!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(e))throw Error(`A shared edit key starts with a letter and holds only letters, digits, - and _ (up to 100 characters).`);if(typeof t!=`function`)throw Error(`Give scheduleSharedEdit a function to run.`);if(!c.has(e)&&c.size+l.size>=32||!u.has(e)&&u.size>=32)throw Error(`Too many scheduled shared edits`);u.delete(e);let n=c.get(e),r={callback:t,started:n?.started??Date.now(),timer:null};n&&clearTimeout(n.timer),r.timer=setTimeout(()=>m(e,r),Math.max(0,Math.min(150,500-(Date.now()-r.started)))),c.set(e,r)},g=(i,c)=>{if(!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(i)||a.has(i))throw Error(`Use one control per named shared field`);let l=e.getElementById(c),u=l?.tagName===`FIELDSET`?[...l.querySelectorAll(`input[type="radio"]`)]:null;if(!l||![`INPUT`,`TEXTAREA`,`SELECT`,`FIELDSET`].includes(l.tagName)||u&&!u.length||l.tagName===`INPUT`&&![`text`,`search`,`email`,`tel`,`url`,`number`,`range`,`checkbox`,`color`].includes(l.type))throw Error(`Bind an existing text, number, checkbox or select control, or a fieldset of radio buttons`);if(s.has(i)){let e=l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type),t=l.disabled,n=l.readOnly,r=l.getAttribute(`title`),s=l.getAttribute(`aria-readonly`),c=l.getAttribute(`aria-disabled`);e?(l.readOnly=!0,l.setAttribute(`aria-readonly`,`true`)):(l.disabled=!0,l.setAttribute(`aria-disabled`,`true`)),l.setAttribute(`title`,`Connected input. Change its source in Flow.`);let u={flush:async()=>{},status:()=>({dirty:!1,saving:!1,problem:null,canEdit:!1,composing:!1,interrupted:!1}),setDefault(){},dispose(){l.disabled=t,l.readOnly=n,r===null?l.removeAttribute(`title`):l.setAttribute(`title`,r),s===null?l.removeAttribute(`aria-readonly`):l.setAttribute(`aria-readonly`,s),c===null?l.removeAttribute(`aria-disabled`):l.setAttribute(`aria-disabled`,c),a.delete(i)}};return a.set(i,u),u.dispose}if(r&&(l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type))){let e=r.bind(i,l),t=e.dispose;return e.dispose=()=>{t(),a.delete(i)},a.set(i,e),e.dispose}let d=l.disabled,m={exists:!1},h,g=!1,_=!1,v=null,y=!1,b=!1,x=null,S=null,C=null,w=!1,T=!1,E,D=l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type),O=e=>{S=e,l.setCustomValidity(e.message),n(e.message)},k=()=>u.find(e=>e.checked)?.value??``,A=e=>{let n=u?k():l.type===`checkbox`?l.checked:l.value;if(u)for(let t of u)t.checked=t.value===String(e??``);else l.type===`checkbox`?l.checked=!!e:l.value!==String(e??``)&&(l.value=String(e??``));(u?k():l.type===`checkbox`?l.checked:l.value)!==n&&queueMicrotask(()=>{y||t.announce?.()})},j=()=>u?k():l.type===`checkbox`?l.checked:[`number`,`range`].includes(l.type)?l.valueAsNumber:l.value,M=Object.hasOwn(f,i)&&p(u,l,f[i])?f[i]:j(),N=()=>{if(clearTimeout(v),v=null,_)return x;if(y||w||!g||!b||S)return;let e=h;g=!1,C=null,_=!0;let n=!1;return x=Promise.resolve().then(()=>t.updateShared({[i]:e},{[i]:m})).then(()=>{m={exists:!0,value:e},l.setCustomValidity(``),!S&&g&&Object.is(h,e)&&(g=!1,C=null)},e=>{n=!0,g=!0,O(e)}).finally(()=>{_=!1,x=null,!y&&!n&&g&&h!==e&&P(),!y&&!g&&ee(t.getShared())}),x},P=()=>{clearTimeout(v),v=setTimeout(N,Math.max(0,Math.min(150,500-(Date.now()-(C??Date.now())))))},F=()=>{!y&&D&&b&&!d&&(w=!0,clearTimeout(v),v=null)},I=e=>{if(y||!b||d)return;if(D&&e?.isComposing){F();return}if(w)return;let t=j();if(typeof t==`number`&&!Number.isFinite(t)){O(Error(`Enter a finite number`));return}E!==void 0&&Object.is(t,E)||(E=void 0,(S||!Object.is(t,g||_?h:m.exists?m.value:M))&&((S||C===null)&&(C=Date.now()),h=t,S=null,g=!0,P()))},ee=e=>{y||(b=e.canEdit,l.disabled=d||!b,!b&&w&&(T=!0),!b&&(g||w)&&O(Error(`Editing access changed. Your unsaved draft has been preserved.`)),!(w||g||_||S)&&(m=Object.hasOwn(e.state,i)?{exists:!0,value:e.state[i]}:{exists:!1},A(m.exists?m.value:M)))},te=t.onShared(ee),L=()=>{if(!y&&w){if(w=!1,!b||T){T=!1,h=j(),E=h,g=!0,O(Error(`Editing access changed. Your unsaved draft has been preserved.`));return}I(),g&&!_&&!S?(C=Date.now(),P()):!g&&!_&&!S&&ee(t.getShared())}};l.disabled=d||!t.getShared().canEdit;let R=u?`focusout`:`blur`;l.addEventListener(`input`,I),l.addEventListener(`change`,I),l.addEventListener(R,N),l.addEventListener(`compositionstart`,F),l.addEventListener(`compositionend`,L);let ne=()=>{y=!0,w=!1,clearTimeout(v),te(),l.removeEventListener(`input`,I),l.removeEventListener(`change`,I),l.removeEventListener(R,N),l.removeEventListener(`compositionstart`,F),l.removeEventListener(`compositionend`,L),l.disabled=d,a.delete(i)};return a.set(i,{dispose:ne,flush:N,status(){return{dirty:g,saving:_,problem:S,canEdit:b,composing:w,interrupted:E!==void 0}},setDefault(e){M=e,ee(t.getShared())},setInputDefault(e){p(u,l,e)&&this.setDefault(e)}}),ne},_=new Map,v=new Map,y=new WeakSet,b=[`text`,`search`,`email`,`tel`,`url`,`number`,`range`,`checkbox`,`color`],x=/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/,S=/(?:password|secret|credential|authorization|cookie|token|api[_-]?key|private[_-]?key)/i,C=/^(?:current-password|new-password|one-time-code|cc-)/i,w=null,T=null,E=e=>{let t=_.get(e);if(t!==void 0){_.delete(e),v.delete(t);try{a.get(t)?.dispose()}catch{}a.delete(t)}},D=(t,n)=>{let r=e.getElementById(n);r&&_.has(r)&&E(r),v.has(t)&&E(v.get(t));let i=g(t,n);return r&&y.add(r),i},O=e=>{let t=e.getAttribute(`data-stillmade-share`)||e.getAttribute(`name`)||e.id||(e.tagName===`FIELDSET`?e.querySelector(`input[type="radio"][name]`)?.getAttribute(`name`):``)||``;return x.test(t)?t:null},k=e=>!e.isConnected||e.closest(`[data-stillmade-local]`)?!1:e.tagName===`FIELDSET`?!!e.querySelector(`input[type="radio"]`)&&!e.querySelector(`fieldset`):e.tagName===`INPUT`?b.includes(e.type):e.tagName===`TEXTAREA`||e.tagName===`SELECT`,A=t=>{if(y.has(t)||_.has(t)||!k(t))return;let n=O(t);if(!(!n||a.has(n)||a.size>=100)&&!(!t.hasAttribute(`data-stillmade-share`)&&(S.test(n)||S.test(t.getAttribute(`name`)||``)||S.test(t.id||``)||C.test(t.getAttribute(`autocomplete`)||``)))){if(!t.id){let r=`sm-shared-${n}`,i=1;for(;e.getElementById(r);)r=`sm-shared-${n}-${++i}`;t.id=r}else if(e.getElementById(t.id)!==t)return;try{g(n,t.id),_.set(t,n),v.set(n,t)}catch{a.delete(n)}}},j=()=>{if(T=null,!(d||M))try{for(let e of[..._.keys()])(!e.isConnected||e.closest(`[data-stillmade-local]`))&&E(e);for(let t of e.querySelectorAll(`input,textarea,select,fieldset`))A(t)}catch(e){n(e.message)}},M=!1,N=()=>{if(!M){M=!0,w?.disconnect(),w=null,T&&=(clearTimeout(T),null);for(let e of[..._.keys()])E(e)}},P=()=>{M||d||w||typeof MutationObserver!=`function`||!e.documentElement||(j(),w=new MutationObserver(()=>{!T&&!d&&(T=setTimeout(j,30))}),w.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`name`,`id`,`type`,`data-stillmade-local`,`data-stillmade-share`]}))};e.readyState===`loading`?e.addEventListener?.(`DOMContentLoaded`,P,{once:!0}):typeof setTimeout==`function`&&typeof MutationObserver==`function`&&setTimeout(P,0);let F=()=>{let t=[...e.querySelectorAll(`[data-stillmade-share]`)];if(t.length>100)throw Error(`Use at most 100 shared controls`);for(let n of t){let t=n.getAttribute(`data-stillmade-share`),r=n.id;if(typeof t!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(t)||typeof r!=`string`||!r||r.length>200||e.getElementById(r)!==n)throw Error(`Each data-stillmade-share control needs a unique ID and valid shared field name`);D(t,r)}return t.length},I=()=>{if(d)throw Error(`Block closed before edits could be flushed`);if([...a.values()].some(e=>e.status().composing))throw Error(`Finish composing text before leaving this Block or running an action.`);let e=[...a.values()].find(e=>e.status().interrupted);if(e)throw e.status().problem};return{bindShared:D,bindAnnotated:F,bindAutomatic:P,ownSharing:N,scheduleSharedEdit:h,flushAll:async()=>{if(d)throw Error(`Block closed before edits could be flushed`);for(let e=0;e<32;e++){if(d)throw Error(`Block closed before edits could be flushed`);I();let e=[...l];for(let[t,n]of[...c])e.push(m(t,n));for(let t of a.values())e.push(t.flush());if(await Promise.all(e),d)throw Error(`Block closed before edits could be flushed`);if(u.size)throw u.values().next().value;let t=!1;for(let e of a.values()){let n=e.status();if(n.problem)throw n.problem;if(n.composing)throw Error(`Finish composing text before leaving this Block or running an action.`);if(n.dirty&&!n.canEdit)throw Error(`Editing access changed. Your draft is not saved.`);t||=n.dirty||n.saving}if(!t&&!c.size&&!l.size)return{queued:!0}}throw Error(`Edits are still arriving. Finish editing before leaving this Block.`)},assertNoComposition:I,getBindingStatus:e=>a.get(e)?.status(),setSharedDefaults(e){if(!e||typeof e!=`object`||Array.isArray(e)||Object.keys(e).length>100||JSON.stringify(e).length>65536)throw Error(`Use bounded shared control defaults`);for(let[t,n]of Object.entries(e))a.get(t)?.setDefault(n)},useInputDefaults(e){let t=f;if(f={},e&&typeof e==`object`&&!Array.isArray(e))for(let[t,n]of Object.entries(e))[`string`,`number`,`boolean`].includes(typeof n)&&(f[t]=n);for(let[e,n]of a)if(Object.hasOwn(f,e)&&!(Object.hasOwn(t,e)&&t[e]===f[e]))try{(n.setInputDefault||n.setDefault)?.call(n,f[e])}catch{}},dispose(){d=!0,w?.disconnect(),T&&clearTimeout(T);for(let e of c.values())clearTimeout(e.timer);c.clear();for(let e of[...a.values()])e.dispose()}}}var tr='var StillMadeTextFrame=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let t=()=>new Map,n=e=>{let n=t();return e.forEach((e,t)=>{n.set(t,e)}),n},r=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},i=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},a=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},o=()=>new Set,s=e=>e[e.length-1],c=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},l=Array.from,u=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},d=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},f=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},p=Array.isArray;var m=class{constructor(){this._observers=t()}on(e,t){return r(this._observers,e,o).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,n){return l((this._observers.get(e)||t()).values()).forEach(e=>e(...n))}destroy(){this._observers=t()}};let h=Math.floor,g=Math.abs,_=(e,t)=>e<t?e:t,v=(e,t)=>e>t?e:t;Number.isNaN;let y=e=>e===0?1/e<0:e<0,b=2**53-1,x=-(2**53-1),S=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&h(e)===e);Number.isNaN,Number.parseInt;let C=String.fromCharCode;String.fromCodePoint,C(65535);let w=e=>e.toLowerCase(),T=/^\\s*/g,E=e=>e.replace(T,``),D=/([A-Z])/g,ee=(e,t)=>E(e.replace(D,e=>`${t}${w(e)}`)),O=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},k=typeof TextEncoder<`u`?new TextEncoder:null,A=k?e=>k.encode(e):O,j=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});j&&j.decode(new Uint8Array).length===1&&(j=null);let M=(e,t)=>f(t,()=>e).join(``);var N=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};let te=()=>new N,P=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},F=e=>{let t=new Uint8Array(P(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},ne=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(v(n,t)*2),e.cpos=0)},I=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},re=I,L=(e,t)=>{for(;t>127;)I(e,128|127&t),t=h(t/128);I(e,127&t)},ie=(e,t)=>{let n=y(t);for(n&&(t=-t),I(e,(t>63?128:0)|(n?64:0)|63&t),t=h(t/64);t>0;)I(e,(t>127?128:0)|127&t),t=h(t/128)},ae=new Uint8Array(3e4),oe=ae.length/3,se=k&&k.encodeInto?(e,t)=>{if(t.length<oe){let n=k.encodeInto(t,ae).written||0;L(e,n);for(let t=0;t<n;t++)I(e,ae[t])}else R(e,A(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;L(e,r);for(let t=0;t<r;t++)I(e,n.codePointAt(t))},ce=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=_(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(v(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},R=(e,t)=>{L(e,t.byteLength),ce(e,t)},le=(e,t)=>{ne(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ue=(e,t)=>le(e,4).setFloat32(0,t,!1),de=(e,t)=>le(e,8).setFloat64(0,t,!1),fe=(e,t)=>le(e,8).setBigInt64(0,t,!1),pe=new DataView(new ArrayBuffer(4)),me=e=>(pe.setFloat32(0,e),pe.getFloat32(0)===e),he=(e,t)=>{switch(typeof t){case`string`:I(e,119),se(e,t);break;case`number`:S(t)&&g(t)<=2147483647?(I(e,125),ie(e,t)):me(t)?(I(e,124),ue(e,t)):(I(e,123),de(e,t));break;case`bigint`:I(e,122),fe(e,t);break;case`object`:if(t===null)I(e,126);else if(p(t)){I(e,117),L(e,t.length);for(let n=0;n<t.length;n++)he(e,t[n])}else if(t instanceof Uint8Array)I(e,116),R(e,t);else{I(e,118);let n=Object.keys(t);L(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];se(e,i),he(e,t[i])}}break;case`boolean`:I(e,t?120:121);break;default:I(e,127)}};var ge=class extends N{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&L(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}};let _e=e=>{e.count>0&&(ie(e.encoder,e.count===1?e.s:-e.s),e.count>1&&L(e.encoder,e.count-2))};var ve=class{constructor(){this.encoder=new N,this.s=0,this.count=0}write(e){this.s===e?this.count++:(_e(this),this.count=1,this.s=e)}toUint8Array(){return _e(this),F(this.encoder)}};let ye=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);ie(e.encoder,t),e.count>1&&L(e.encoder,e.count-2)}};var be=class{constructor(){this.encoder=new N,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(ye(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return ye(this),F(this.encoder)}},xe=class{constructor(){this.sarr=[],this.s=``,this.lensE=new ve}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new N;return this.sarr.push(this.s),this.s=``,se(e,this.sarr.join(``)),ce(e,this.lensE.toUint8Array()),F(e)}};let Se=e=>Error(e),Ce=()=>{throw Se(`Method unimplemented`)},we=()=>{throw Se(`Unexpected case`)},Te=Se(`Unexpected end of array`),Ee=Se(`Integer out of Range`),De=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw Te;return new Uint8Array(e.buffer,e.byteOffset+t,n)},Oe=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw Te;return new DataView(e.buffer,e.byteOffset+t,n)};var ke=class{constructor(e){this.arr=e,this.pos=0}};let Ae=e=>new ke(e),je=e=>e.pos!==e.arr.length,Me=(e,t)=>{let n=De(e.arr,e.pos,t);return e.pos+=t,n},Ne=e=>Me(e,z(e)),Pe=e=>e.arr[e.pos++],z=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>b)throw Ee}throw Te},Fe=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>b)throw Ee}throw Te},Ie=j?e=>j.decode(Ne(e)):e=>{let t=z(e);if(t===0)return``;{let n=String.fromCodePoint(Pe(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Pe(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Le=(e,t)=>{let n=Oe(e.arr,e.pos,t);return e.pos+=t,n},Re=[e=>void 0,e=>null,Fe,e=>Le(e,4).getFloat32(0,!1),e=>Le(e,8).getFloat64(0,!1),e=>Le(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Ie,e=>{let t=z(e),n={};for(let r=0;r<t;r++){let t=Ie(e);n[t]=ze(e)}return n},e=>{let t=z(e),n=[];for(let r=0;r<t;r++)n.push(ze(e));return n},Ne],ze=e=>Re[127-Pe(e)](e);var Be=class extends ke{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),this.count=je(this)?z(this)+1:-1),this.count--,this.s}},Ve=class extends ke{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Fe(this);let e=y(this.s);this.count=1,e&&(this.s=-this.s,this.count=z(this)+2)}return this.count--,this.s}},He=class extends ke{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Fe(this),t=e&1;this.diff=h(e/2),this.count=1,t&&(this.count=z(this)+2)}return this.s+=this.diff,this.count--,this.s}},Ue=class{constructor(e){this.decoder=new Ve(e),this.str=Ie(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;let We=crypto.getRandomValues.bind(crypto),Ge=()=>We(new Uint32Array(1))[0],Ke=()=>`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^Ge()&15>>e/4).toString(16)),qe=Date.now,Je=e=>new Promise(e);Promise.all.bind(Promise);let Ye=e=>e===void 0?null:e,Xe=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Xe=localStorage)}catch{}let Ze=Xe,Qe=Symbol(`Equality`),$e=(e,t)=>e===t||!!e?.[Qe]?.(t)||!1,et=e=>typeof e==`object`,tt=Object.assign,nt=Object.keys,rt=(e,t)=>{for(let n in e)t(e[n],n)},it=e=>nt(e).length,at=e=>{for(let t in e)return!1;return!0},ot=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},st=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ct=(e,t)=>e===t||it(e)===it(t)&&ot(e,(e,n)=>(e!==void 0||st(t,n))&&$e(t[n],e)),lt=Object.freeze,ut=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&ut(e[t])}return lt(e)},dt=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&dt(e,t,n+1)}},ft=e=>e,pt=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Qe]!=null)return e[Qe](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!pt(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(it(e)!==it(t))return!1;for(let n in e)if(!st(e,n)||!pt(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!pt(e[n],t[n]))return!1;break;default:return!1}return!0},mt=(e,t)=>t.includes(e),ht=typeof process<`u`&&process.release&&/node|io\\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`;typeof navigator<`u`&&/Mac/.test(navigator.platform);let gt,_t=[],vt=()=>{if(gt===void 0){if(ht){gt=t();let e=process.argv,n=null;for(let t=0;t<e.length;t++){let r=e[t];r[0]===`-`?(n!==null&&gt.set(n,``),n=r):n===null?_t.push(r):(gt.set(n,r),n=null)}n!==null&&gt.set(n,``)}else typeof location==`object`?(gt=t(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);gt.set(`--${ee(t,`-`)}`,n),gt.set(`-${ee(t,`-`)}`,n)}})):gt=t()}return gt},yt=e=>vt().has(e),bt=e=>Ye(ht?process.env[e.toUpperCase().replaceAll(`-`,`_`)]:Ze.getItem(e)),xt=e=>yt(`--`+e)||bt(e)!==null,St=xt(`production`),Ct=ht&&mt(process.env.FORCE_COLOR,[`true`,`1`,`2`])||!yt(`--no-colors`)&&!xt(`no-color`)&&(!ht||process.stdout.isTTY)&&(!ht||yt(`--color`)||bt(`COLORTERM`)!==null||(bt(`TERM`)||``).includes(`color`)),wt=e=>new Uint8Array(e),Tt=e=>{let t=wt(e.byteLength);return t.set(e),t};var Et=class{constructor(e,t){this.left=e,this.right=t}};let Dt=(e,t)=>new Et(e,t),Ot=e=>e.next()>=.5,kt=(e,t,n)=>h(e.next()*(n+1-t)+t),At=(e,t,n)=>h(e.next()*(n+1-t)+t),jt=(e,t,n)=>At(e,t,n),Mt=e=>C(jt(e,97,122)),Nt=(e,t=0,n=20)=>{let r=jt(e,t,n),i=``;for(let t=0;t<r;t++)i+=Mt(e);return i},Pt=(e,t)=>t[jt(e,0,t.length-1)],Ft=Symbol(`0schema`);var It=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(M(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn\'t match ${n.expected}. ${n.message}`)}return e.join(`\n`)}};let Lt=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Qe]?$e(e,t):p(e)?u(e,e=>d(t,t=>Lt(e,t))):et(e)?ot(e,(e,n)=>Lt(e,t[n])):!1;var B=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Lt(t,n)}equals(e){return this.constructor===e.constructor&&pt(this.shape,e.shape)}[Ft](){return!0}[Qe](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Ce()}get nullable(){return hn(this,An)}get optional(){return new Kt(this)}cast(e){return Pn(e,this),e}expect(e){return Pn(e,this),e}},Rt=class extends B{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}};let V=(e,t=null)=>new Rt(e,t);V(Rt);var zt=class extends B{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}};let H=e=>new zt(e);V(zt);var Bt=class extends B{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}};let Vt=(...e)=>new Bt(e),Ht=V(Bt),Ut=RegExp.escape||(e=>e.replace(/[().|&,$^[\\]]/g,e=>`\\\\`+e)),Wt=e=>{if(Tn.check(e))return[Ut(e)];if(Ht.check(e))return e.shape.map(e=>e+``);if(wn.check(e))return[`[+-]?\\\\d+.?\\\\d*`];if(En.check(e))return[`.*`];if(gn.check(e))return e.shape.map(Wt).flat(1);we()};V(class extends B{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Wt).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn\'t match string template.`),n}});let Gt=Symbol(`optional`);var Kt=class extends B{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Gt](){return!0}};let qt=V(Kt);var Jt=class extends B{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Jt,V(Jt);var Yt=class e extends B{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):ot(this.shape,(n,r)=>{let i=this._isPartial&&!st(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}};let Xt=e=>new Yt(e),Zt=V(Yt),Qt=H(e=>e!=null&&(e.constructor===Object||e.constructor==null));var $t=class extends B{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&ot(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn\'t match schema`:`Value doesn\'t match value`),i&&this.shape.values.check(n,t)})}};let en=(e,t)=>new $t(e,t),tn=V($t);var nn=class extends B{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&ot(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}};let rn=(...e)=>new nn(e);V(nn);var an=class extends B{constructor(e){super(),this.shape=e.length===1?e[0]:new mn(e)}check(e,t){let n=p(e)&&u(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}};let on=(...e)=>new an(e),sn=V(an),cn=H(e=>p(e));var ln=class extends B{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}};let un=(e,t=null)=>new ln(e,t);V(ln);let dn=un(B),fn=V(class extends B{constructor(e){super(),this.len=e.length-1,this.args=rn(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),pn=H(e=>typeof e==`function`);V(class extends B{constructor(e){super(),this.shape=e}check(e,t){let n=u(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var mn=class extends B{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=d(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}};let hn=(...e)=>e.findIndex(e=>gn.check(e))>=0?hn(...e.map(e=>Nn(e)).map(e=>gn.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new mn(e),gn=V(mn),_n=()=>!0,vn=H(_n),yn=V(zt,e=>e.shape===_n),bn=H(e=>typeof e==`bigint`),xn=H(e=>e===bn),Sn=H(e=>typeof e==`symbol`);H(e=>e===Sn);let Cn=H(e=>typeof e==`number`),wn=H(e=>e===Cn),Tn=H(e=>typeof e==`string`),En=H(e=>e===Tn),Dn=H(e=>typeof e==`boolean`),On=H(e=>e===Dn),kn=Vt(void 0);V(Bt,e=>e.shape.length===1&&e.shape[0]===void 0),Vt(void 0);let An=Vt(null),jn=V(Bt,e=>e.shape.length===1&&e.shape[0]===null);V(Uint8Array),V(Rt,e=>e.shape===Uint8Array);let Mn=hn(Cn,Tn,An,kn,bn,Dn,Sn);(()=>{let e=on(vn),t=en(Tn,vn),n=hn(Cn,Tn,An,Dn,e,t);return e.shape=n,t.shape.values=n,n})();let Nn=e=>{if(dn.check(e))return e;if(Qt.check(e)){let t={};for(let n in e)t[n]=Nn(e[n]);return Xt(t)}if(cn.check(e))return hn(...e.map(Nn));if(Mn.check(e))return Vt(e);if(pn.check(e))return V(e);we()},Pn=St?()=>{}:(e,t)=>{let n=new It;if(!t.check(e,n))throw Se(`Expected value to be of type ${t.constructor.name}.\\n${n.toString()}`)};var Fn=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Nn(e),h:t}),this}else(e){return this.if(vn,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Se(`Unhandled pattern`)}}};let In=(e=>new Fn(e))(vn).if(wn,(e,t)=>kt(t,x,b)).if(En,(e,t)=>Nt(t)).if(On,(e,t)=>Ot(t)).if(xn,(e,t)=>BigInt(kt(t,x,b))).if(gn,(e,t)=>Ln(t,Pt(t,e.shape))).if(Zt,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(qt.check(i)){if(Ot(t))continue;i=i.shape}n[r]=In(i,t)}return n}).if(sn,(e,t)=>{let n=[],r=At(t,0,42);for(let i=0;i<r;i++)n.push(Ln(t,e.shape));return n}).if(Ht,(e,t)=>Pt(t,e.shape)).if(jn,(e,t)=>null).if(fn,(e,t)=>{let n=Ln(t,e.res);return()=>n}).if(yn,(e,t)=>Ln(t,Pt(t,[Cn,Tn,An,kn,bn,Dn,on(Cn),en(hn(`a`,`b`,`c`),Cn)]))).if(tn,(e,t)=>{let n={},r=kt(t,0,3);for(let i=0;i<r;i++){let r=Ln(t,e.shape.keys);n[r]=Ln(t,e.shape.values)}return n}).done(),Ln=(e,t)=>In(Nn(t),e),Rn=typeof document<`u`?document:{};H(e=>e.nodeType===Un),typeof DOMParser<`u`&&new DOMParser,H(e=>e.nodeType===Bn),H(e=>e.nodeType===Vn);let zn=e=>i(e,(e,t)=>`${t}:${e};`).join(``),Bn=Rn.ELEMENT_NODE,Vn=Rn.TEXT_NODE;Rn.CDATA_SECTION_NODE,Rn.COMMENT_NODE;let Hn=Rn.DOCUMENT_NODE;Rn.DOCUMENT_TYPE_NODE;let Un=Rn.DOCUMENT_FRAGMENT_NODE;H(e=>e.nodeType===Hn);let Wn=Symbol,Gn=Wn(),Kn=Wn(),qn=Wn(),Jn=Wn(),Yn=Wn(),Xn=Wn(),Zn=Wn(),Qn=Wn(),$n=Wn(),er=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};qe();let tr={[Gn]:Dt(`font-weight`,`bold`),[Kn]:Dt(`font-weight`,`normal`),[qn]:Dt(`color`,`blue`),[Yn]:Dt(`color`,`green`),[Jn]:Dt(`color`,`grey`),[Xn]:Dt(`color`,`red`),[Zn]:Dt(`color`,`purple`),[Qn]:Dt(`color`,`orange`),[$n]:Dt(`color`,`black`)},nr=Ct?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let n=[],r=[],i=t(),a=[],o=0;for(;o<e.length;o++){let t=e[o],a=tr[t];if(a!==void 0)i.set(a.left,a.right);else{if(t===void 0)break;if(t.constructor===String||t.constructor===Number){let e=zn(i);o>0||e.length>0?(n.push(`%c`+t),r.push(e)):n.push(t)}else break}}for(o>0&&(a=r,a.unshift(n.join(``)));o<e.length;o++){let t=e[o];t instanceof Symbol||a.push(t)}return a}:er,rr=(...e)=>{console.log(...nr(e)),ar.forEach(t=>t.print(e))},ir=(...e)=>{console.warn(...nr(e)),e.unshift(Qn),ar.forEach(t=>t.print(e))},ar=o(),or=e=>({[Symbol.iterator](){return this},next:e}),sr=(e,t)=>or(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),cr=(e,t)=>or(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var lr=class{constructor(e,t){this.clock=e,this.len=t}},ur=class{constructor(){this.clients=new Map}};let dr=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Si(e,i,o.clock,o.len,n)}}),fr=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=h((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},pr=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&fr(n,t.clock)!==null},mr=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new lr(r.clock,v(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},hr=e=>{let t=new ur;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)c(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return mr(t),t},gr=(e,t,n,i)=>{r(e.clients,t,()=>[]).push(new lr(n,i))},_r=()=>new ur,vr=e=>{let t=_r();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new lr(i,a))}}r.length>0&&t.clients.set(n,r)}),t},yr=(e,t)=>{L(e.restEncoder,t.clients.size),l(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),L(e.restEncoder,t);let r=n.length;L(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},br=e=>{let t=new ur,n=z(e.restDecoder);for(let i=0;i<n;i++){e.resetDsCurVal();let n=z(e.restDecoder),i=z(e.restDecoder);if(i>0){let a=r(t.clients,n,()=>[]);for(let t=0;t<i;t++)a.push(new lr(e.readDsClock(),e.readDsLen()))}}return t},xr=(e,t,n)=>{let r=new ur,i=z(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=z(e.restDecoder),a=z(e.restDecoder),o=n.clients.get(i)||[],s=W(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&gr(r,i,s,a-s);let e=_i(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Po(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,Po(t,c,a-c.id.clock)),c.delete(t))}else gr(r,i,n,a-n)}}if(r.clients.size>0){let e=new jr;return L(e.restEncoder,0),yr(e,r),e.toUint8Array()}return null},Sr=Ge;var Cr=class e extends m{constructor({guid:e=Ke(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Sr(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new mi,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Je(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Je(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&K(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(l(this.subdocs).map(e=>e.guid))}transact(e,t=null){return K(this,e,t)}get(e,t=J){let n=r(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),i=n.constructor;if(t!==J&&i!==t){if(i===J){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}throw Error(`Type with the name ${e} has already been defined with a different constructor`)}return n}getArray(e=``){return this.get(e,wa)}getText(e=``){return this.get(e,Ga)}getMap(e=``){return this.get(e,Da)}getXmlElement(e=``){return this.get(e,Xa)}getXmlFragment(e=``){return this.get(e,Ja)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,l(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,K(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},wr=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return z(this.restDecoder)}readDsLen(){return z(this.restDecoder)}},Tr=class extends wr{readLeftID(){return U(z(this.restDecoder),z(this.restDecoder))}readRightID(){return U(z(this.restDecoder),z(this.restDecoder))}readClient(){return z(this.restDecoder)}readInfo(){return Pe(this.restDecoder)}readString(){return Ie(this.restDecoder)}readParentInfo(){return z(this.restDecoder)===1}readTypeRef(){return z(this.restDecoder)}readLen(){return z(this.restDecoder)}readAny(){return ze(this.restDecoder)}readBuf(){return Tt(Ne(this.restDecoder))}readJSON(){return JSON.parse(Ie(this.restDecoder))}readKey(){return Ie(this.restDecoder)}},Er=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=z(this.restDecoder),this.dsCurrVal}readDsLen(){let e=z(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Dr=class extends Er{constructor(e){super(e),this.keys=[],z(e),this.keyClockDecoder=new He(Ne(e)),this.clientDecoder=new Ve(Ne(e)),this.leftClockDecoder=new He(Ne(e)),this.rightClockDecoder=new He(Ne(e)),this.infoDecoder=new Be(Ne(e),Pe),this.stringDecoder=new Ue(Ne(e)),this.parentInfoDecoder=new Be(Ne(e),Pe),this.typeRefDecoder=new Ve(Ne(e)),this.lenDecoder=new Ve(Ne(e))}readLeftID(){return new ei(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ei(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return ze(this.restDecoder)}readBuf(){return Ne(this.restDecoder)}readJSON(){return ze(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Or=class{constructor(){this.restEncoder=te()}toUint8Array(){return F(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){L(this.restEncoder,e)}writeDsLen(e){L(this.restEncoder,e)}},kr=class extends Or{writeLeftID(e){L(this.restEncoder,e.client),L(this.restEncoder,e.clock)}writeRightID(e){L(this.restEncoder,e.client),L(this.restEncoder,e.clock)}writeClient(e){L(this.restEncoder,e)}writeInfo(e){re(this.restEncoder,e)}writeString(e){se(this.restEncoder,e)}writeParentInfo(e){L(this.restEncoder,+!!e)}writeTypeRef(e){L(this.restEncoder,e)}writeLen(e){L(this.restEncoder,e)}writeAny(e){he(this.restEncoder,e)}writeBuf(e){R(this.restEncoder,e)}writeJSON(e){se(this.restEncoder,JSON.stringify(e))}writeKey(e){se(this.restEncoder,e)}},Ar=class{constructor(){this.restEncoder=te(),this.dsCurrVal=0}toUint8Array(){return F(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,L(this.restEncoder,t)}writeDsLen(e){e===0&&we(),L(this.restEncoder,e-1),this.dsCurrVal+=e}},jr=class extends Ar{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new be,this.clientEncoder=new ve,this.leftClockEncoder=new be,this.rightClockEncoder=new be,this.infoEncoder=new ge(re),this.stringEncoder=new xe,this.parentInfoEncoder=new ge(re),this.typeRefEncoder=new ve,this.lenEncoder=new ve}toUint8Array(){let e=te();return L(e,0),R(e,this.keyClockEncoder.toUint8Array()),R(e,this.clientEncoder.toUint8Array()),R(e,this.leftClockEncoder.toUint8Array()),R(e,this.rightClockEncoder.toUint8Array()),R(e,F(this.infoEncoder)),R(e,this.stringEncoder.toUint8Array()),R(e,F(this.parentInfoEncoder)),R(e,this.typeRefEncoder.toUint8Array()),R(e,this.lenEncoder.toUint8Array()),ce(e,F(this.restEncoder)),F(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){he(this.restEncoder,e)}writeBuf(e){R(this.restEncoder,e)}writeJSON(e){he(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}};let Mr=(e,t,n,r)=>{r=v(r,t[0].id.clock);let i=_i(t,r);L(e.restEncoder,t.length-i),e.writeClient(n),L(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},Nr=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{W(t,n)>e&&r.set(n,e)}),hi(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),L(e.restEncoder,r.size),l(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Mr(e,t.clients.get(n),n,r)})},Pr=(e,n)=>{let r=t(),i=z(e.restDecoder);for(let t=0;t<i;t++){let t=z(e.restDecoder),i=Array(t),a=e.readClient(),o=z(e.restDecoder);r.set(a,{i:0,refs:i});for(let r=0;r<t;r++){let t=e.readInfo();switch(31&t){case 0:{let t=e.readLen();i[r]=new Y(U(a,o),t),o+=t;break}case 10:{let t=z(e.restDecoder);i[r]=new zo(U(a,o),t),o+=t;break}default:{let s=!(t&192),c=new Z(U(a,o),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,s?e.readParentInfo()?n.get(e.readString()):e.readLeftID():null,s&&(t&32)==32?e.readString():null,Lo(e,t));i[r]=c,o+=c.length}}}}return r},Fr=(e,t,n)=>{let i=[],a=l(n.keys()).sort((e,t)=>e-t);if(a.length===0)return null;let o=()=>{if(a.length===0)return null;let e=n.get(a[a.length-1]);for(;e.refs.length===e.i;)if(a.pop(),a.length>0)e=n.get(a[a.length-1]);else return null;return e},s=o();if(s===null)return null;let c=new mi,u=new Map,d=(e,t)=>{let n=u.get(e);(n==null||n>t)&&u.set(e,t)},f=s.refs[s.i++],p=new Map,m=()=>{for(let e of i){let t=e.id.client,r=n.get(t);r?(r.i--,c.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):c.clients.set(t,[e]),a=a.filter(e=>e!==t)}i.length=0};for(;;){if(f.constructor!==zo){let a=r(p,f.id.client,()=>W(t,f.id.client))-f.id.clock;if(a<0)i.push(f),d(f.id.client,f.id.clock-1),m();else{let r=f.getMissing(e,t);if(r!==null){i.push(f);let e=n.get(r)||{refs:[],i:0};if(e.refs.length===e.i)d(r,W(t,r)),m();else{f=e.refs[e.i++];continue}}else(a===0||a<f.length)&&(f.integrate(e,a),p.set(f.id.client,f.id.clock+f.length))}}if(i.length>0)f=i.pop();else if(s!==null&&s.i<s.refs.length)f=s.refs[s.i++];else{if(s=o(),s===null)break;f=s.refs[s.i++]}}if(c.clients.size>0){let e=new jr;return Nr(e,c,new Map),L(e.restEncoder,0),{missing:u,update:e.toUint8Array()}}return null},Ir=(e,t)=>Nr(e,t.doc.store,t.beforeState),Lr=(e,t,n,r=new Dr(e))=>K(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Pr(r,n),o=Fr(e,i,a),s=i.pendingStructs;if(s){for(let[e,n]of s.missing)if(n<W(i,e)){t=!0;break}if(o){for(let[e,t]of o.missing){let n=s.missing.get(e);(n==null||n>t)&&s.missing.set(e,t)}s.update=Vi([s.update,o.update])}}else i.pendingStructs=o;let c=xr(r,e,i);if(i.pendingDs){let t=new Dr(Ae(i.pendingDs));z(t.restDecoder);let n=xr(t,e,i);i.pendingDs=c&&n?Vi([c,n]):c||n}else i.pendingDs=c;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Rr(e.doc,t)}},n,!1),Rr=(e,t,n,r=Dr)=>{let i=Ae(t);Lr(i,e,n,new r(i))},zr=(e,t,n)=>Rr(e,t,n,Tr),Br=(e,t,n=new Map)=>{Nr(e,t.store,n),yr(e,vr(t.store))},Vr=(e,t=new Uint8Array([0]),n=new jr)=>{let r=Wr(t);Br(n,e,r);let i=[n.toUint8Array()];if(e.store.pendingDs&&i.push(e.store.pendingDs),e.store.pendingStructs&&i.push(Hi(e.store.pendingStructs.update,t)),i.length>1){if(n.constructor===kr)return zi(i.map((e,t)=>t===0?e:qi(e)));if(n.constructor===jr)return Vi(i)}return i[0]},Hr=(e,t)=>Vr(e,t,new kr),Ur=e=>{let t=new Map,n=z(e.restDecoder);for(let r=0;r<n;r++){let n=z(e.restDecoder),r=z(e.restDecoder);t.set(n,r)}return t},Wr=e=>Ur(new wr(Ae(e))),Gr=(e,t)=>(L(e.restEncoder,t.size),l(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{L(e.restEncoder,t),L(e.restEncoder,n)}),e),Kr=(e,t)=>Gr(e,hi(t.store)),qr=(e,t=new Ar)=>(e instanceof Map?Gr(t,e):Kr(t,e),t.toUint8Array()),Jr=e=>qr(e,new Or);var Yr=class{constructor(){this.l=[]}};let Xr=()=>new Yr,Zr=(e,t)=>e.l.push(t),Qr=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn\'t exist.`)},$r=(e,t,n)=>dt(e.l,[t,n]);var ei=class{constructor(e,t){this.client=e,this.clock=t}};let ti=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,U=(e,t)=>new ei(e,t),ni=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw we()},ri=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1};var ii=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ai=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}};let oi=(e,t,n=0)=>new ai(e,t,n),si=(e,t,n)=>{let r=null,i=null;return e._item===null?i=ni(e):r=U(e._item.id.client,e._item.id.clock),new ii(r,i,t,n)},ci=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return si(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return si(e,U(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return si(e,r.lastId,n);r=r.right}return si(e,null,n)},li=(e,t)=>{let n=vi(e,t);return{item:n,diff:t.clock-n.id.clock}},ui=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(W(r,i.client)<=i.clock)return null;let e=n?Mo(r,i):li(r,i),t=e.item;if(!(t instanceof Z))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(W(r,a.client)<=a.clock)return null;let{item:e}=n?Mo(r,a):{item:vi(r,a)};if(e instanceof Z&&e.content instanceof Ao)c=e.content.type;else return null}else throw we();l=s>=0?c._length:0}return oi(c,l,e.assoc)};var di=class{constructor(e,t){this.ds=e,this.sv=t}};((e,t)=>new di(e,t))(_r(),new Map);let fi=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!pr(t.ds,e.id),pi=(e,t)=>{let n=r(e.meta,pi,o),i=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<W(i,n)&&G(e,U(n,t))}),dr(e,t.ds,e=>{}),n.add(t))};var mi=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}};let hi=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},W=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},gi=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw we()}n.push(t)},_i=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=h(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=h((n+r)/2)}throw we()},vi=(e,t)=>{let n=e.clients.get(t.client);return n[_i(n,t.clock)]},yi=(e,t,n)=>{let r=_i(t,n),i=t[r];return i.id.clock<n&&i instanceof Z?(t.splice(r+1,0,Po(e,i,n-i.id.clock)),r+1):r},G=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[yi(e,n,t.clock)]},bi=(e,t,n)=>{let r=t.clients.get(n.client),i=_i(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==Y&&r.splice(i+1,0,Po(e,a,n.clock-a.id.clock+1)),a},xi=(e,t,n)=>{let r=e.clients.get(t.id.client);r[_i(r,t.id.clock)]=n},Si=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=yi(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&yi(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)};var Ci=class{constructor(e,t,n){this.doc=e,this.deleteSet=new ur,this.beforeState=hi(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}};let wi=(e,t)=>t.deleteSet.clients.size===0&&!a(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(mr(t.deleteSet),Ir(e,t),yr(e,t.deleteSet),!0),Ti=(e,t,n)=>{let i=t._item;(i===null||i.id.clock<(e.beforeState.get(i.id.client)||0)&&!i.deleted)&&r(e.changed,t,o).add(n)},Ei=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Z&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},Di=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=_i(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof Z&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Oi=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=_(r.length-1,1+_i(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+Ei(r,e)}})},ki=(e,t,n)=>{Di(e,t,n),Oi(e,t)},Ai=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{mr(a),n.afterState=hi(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{$r(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Ha(n)})}),dt(e,[])}finally{r.gc&&Di(a,i,r.gcFilter),Oi(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=v(_i(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Ei(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=_i(r,n);a+1<r.length&&Ei(r,a+1)>1||a>0&&Ei(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(rr(Qn,Gn,`[yjs] `,Kn,Xn,`Changed the client-id because another client seems to be using it.`),r.clientID=Sr()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new kr;wi(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new jr;wi(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Ai(e,t+1)}}},K=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Ci(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Ai(i,0)}}return o};var ji=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}};let Mi=(e,t,n)=>{dr(e,n.deletions,n=>{n instanceof Z&&t.scope.some(t=>t===e.doc||ri(t,n))&&No(n,!1)})},Ni=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;K(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;dr(n,o.insertions,e=>{if(e instanceof Z){if(e.redone!==null){let{item:t,diff:i}=Mo(r,e.id);i>0&&(t=G(n,U(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ri(t,e))&&c.push(e)}}),dr(n,o.deletions,e=>{e instanceof Z&&a.some(t=>t===n.doc||ri(t,e))&&!pr(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Io(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o};var Pi=class extends m{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=p(e)?e[0].doc:e instanceof Cr?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new ur;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&gr(i,n,r,a)});let a=qe(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=hr([t.deletions,e.deleteSet]),t.insertions=hr([t.insertions,i])}else r.push(new ji(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),dr(e,e.deleteSet,t=>{t instanceof Z&&this.scope.some(n=>n===e.doc||ri(n,t))&&No(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.destroy=this.destroy.bind(this),this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,this.destroy)}addToScope(e){let t=new Set(this.scope);e=p(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof J?e.doc!==this.doc:e!==this.doc)&&ir(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Mi(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Mi(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Ni(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Ni(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),this.doc.off(`destroy`,this.destroy),super.destroy()}};function*Fi(e){let t=z(e.restDecoder);for(let n=0;n<t;n++){let t=z(e.restDecoder),n=e.readClient(),r=z(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=z(e.restDecoder);yield new zo(U(n,r),t),r+=t}else if(31&t){let i=!(t&192),a=new Z(U(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,Lo(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new Y(U(n,r),t),r+=t}}}}var Ii=class{constructor(e,t){this.gen=Fi(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===zo);return this.curr}};let Li=(e,t=Dr)=>{let n=[],r=new t(Ae(e)),i=new Ii(r,!1);for(let e=i.curr;e!==null;e=i.next())n.push(e);return{structs:n,ds:br(r)}};var Ri=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}};let zi=e=>Vi(e,Tr,kr),Bi=(e,t)=>{if(e.constructor===Y){let{client:n,clock:r}=e.id;return new Y(U(n,r+t),e.length-t)}if(e.constructor===zo){let{client:n,clock:r}=e.id;return new zo(U(n,r+t),e.length-t)}{let n=e,{client:r,clock:i}=n.id;return new Z(U(r,i+t),null,U(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Vi=(e,t=Dr,n=jr)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Ae(e))),i=r.map(e=>new Ii(e,!0)),a=null,o=new n,s=new Ri(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===zo?1:-1:n}return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)Wi(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock){if(a.struct.constructor===zo)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Wi(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new zo(U(t,a.struct.id.clock+a.struct.length),e),offset:0}}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===zo?a.struct.length-=t:n=Bi(n,t)),a.struct.mergeWith(n)||(Wi(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==zo;n=e.next())Wi(s,a.struct,a.offset),a={struct:n,offset:0}}a!==null&&(Wi(s,a.struct,a.offset),a=null),Gi(s);let c=r.map(e=>br(e)),l=hr(c);return yr(o,l),o.toUint8Array()},Hi=(e,t,n=Dr,r=jr)=>{let i=Wr(t),a=new r,o=new Ri(a),s=new n(Ae(e)),c=new Ii(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===zo){c.next();continue}if(e.id.clock+e.length>n)for(Wi(o,e,v(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Wi(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}Gi(o);let l=br(s);return yr(a,l),a.toUint8Array()},Ui=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:F(e.encoder.restEncoder)}),e.encoder.restEncoder=te(),e.written=0)},Wi=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Ui(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),L(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Gi=e=>{Ui(e);let t=e.encoder.restEncoder;L(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];L(t,r.written),ce(t,r.restEncoder)}},Ki=(e,t,n,r)=>{let i=new n(Ae(e)),a=new Ii(i,!1),o=new r,s=new Ri(o);for(let e=a.curr;e!==null;e=a.next())Wi(s,t(e),0);Gi(s);let c=br(i);return yr(o,c),o.toUint8Array()},qi=e=>Ki(e,ft,Dr,kr),Ji=`You must not compute changes after the event-handler fired.`;var Yi=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=Xi(this.currentTarget,this.target)}deletes(e){return pr(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Se(Ji);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r)){if(e!==null&&this.deletes(e))i=`delete`,a=s(e.content.getContent());else return}else e!==null&&this.deletes(e)?(i=`update`,a=s(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=s(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Se(Ji);let t=this.target,n=o(),r=o(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}};let Xi=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},q=()=>{ir(`Invalid access: Add Yjs type to a document before reading data.`)},Zi=0;var Qi=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Zi++}};let $i=e=>{e.timestamp=Zi++},ea=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Zi++},ta=(e,t,n)=>{if(e.length>=80){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return ea(r,t,n),r}{let r=new Qi(t,n);return e.push(r),r}},na=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>g(t-e.index)<g(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,$i(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&g(n.index-i)<r.parent.length/80?(ea(n,r,i),n):ta(e._searchMarker,r,i)},ra=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=v(t,i.index+n))}},ia=(e,t,n)=>{let i=e,a=t.changedParentTypes;for(;r(a,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;$r(i._eH,n,t)};var J=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Xr(),this._dEH=Xr(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Ce()}clone(){throw Ce()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Zr(this._eH,e)}observeDeep(e){Zr(this._dEH,e)}unobserve(e){Qr(this._eH,e)}unobserveDeep(e){Qr(this._dEH,e)}toJSON(){}};let aa=(e,t,n)=>{e.doc??q(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},oa=e=>{e.doc??q();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},sa=(e,t)=>{let n=0,r=e._start;for(e.doc??q();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},ca=(e,t)=>{let n=[];return sa(e,(r,i)=>{n.push(t(r,i,e))}),n},la=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},ua=(e,t)=>{e.doc??q();let n=na(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},da=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new Z(U(o,W(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new vo(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new Z(U(o,W(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new io(new Uint8Array(n))),i.integrate(e,0);break;case Cr:i=new Z(U(o,W(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new lo(n)),i.integrate(e,0);break;default:if(n instanceof J)i=new Z(U(o,W(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ao(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},fa=()=>Se(`Length exceeded!`),pa=(e,t,n,r)=>{if(n>t._length)throw fa();if(n===0)return t._searchMarker&&ra(t._searchMarker,n,r.length),da(e,t,null,r);let i=n,a=na(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&G(e,U(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&ra(t._searchMarker,i,r.length),da(e,t,o,r)},ma=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return da(e,t,r,n)},ha=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=na(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&G(e,U(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&G(e,U(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw fa();t._searchMarker&&ra(t._searchMarker,i,-a+r)},ga=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},_a=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new vo([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new vo([r]);break;case Uint8Array:s=new io(r);break;case Cr:s=new lo(r);break;default:if(r instanceof J)s=new Ao(r);else throw Error(`Unexpected content type`)}new Z(U(o,W(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},va=(e,t)=>{e.doc??q();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},ya=e=>{let t={};return e.doc??q(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},ba=(e,t)=>{e.doc??q();let n=e._map.get(t);return n!==void 0&&!n.deleted},xa=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&fi(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Sa=e=>(e.doc??q(),sr(e._map.entries(),e=>!e[1].deleted));var Ca=class extends Yi{},wa=class e extends J{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof J?e.clone():e)),t}get length(){return this.doc??q(),this._length}_callObserver(e,t){super._callObserver(e,t),ia(this,e,new Ca(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):K(this.doc,n=>{pa(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):K(this.doc,t=>{ma(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):K(this.doc,n=>{ha(n,this,e,t)})}get(e){return ua(this,e)}toArray(){return oa(this)}slice(e=0,t=this.length){return aa(this,e,t)}toJSON(){return this.map(e=>e instanceof J?e.toJSON():e)}map(e){return ca(this,e)}forEach(e){sa(this,e)}[Symbol.iterator](){return la(this)}_write(e){e.writeTypeRef(Co)}};let Ta=e=>new wa;var Ea=class extends Yi{constructor(e,t,n){super(e,t),this.keysChanged=n}},Da=class e extends J{constructor(e){super(),this._prelimContent=null,this._prelimContent=e===void 0?new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof J?e.clone():e)}),t}_callObserver(e,t){ia(this,e,new Ea(this,e,t))}toJSON(){this.doc??q();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof J?r.toJSON():r}}),e}get size(){return[...Sa(this)].length}keys(){return cr(Sa(this),e=>e[0])}values(){return cr(Sa(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return cr(Sa(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??q(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):K(this.doc,t=>{ga(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):K(this.doc,n=>{_a(n,this,e,t)}),t}get(e){return va(this,e)}has(e){return ba(this,e)}clear(){this.doc===null?this._prelimContent.clear():K(this.doc,e=>{this.forEach(function(t,n,r){ga(e,r,n)})})}_write(e){e.writeTypeRef(wo)}};let Oa=e=>new Da,ka=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&ct(e,t);var Aa=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&we(),this.right.content.constructor){case X:this.right.deleted||Pa(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length)}this.left=this.right,this.right=this.right.right}};let ja=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case X:t.right.deleted||Pa(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&G(e,U(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length)}t.left=t.right,t.right=t.right.right}return t},Ma=(e,t,n,r)=>{let i=new Map,a=r?na(t,n):null;if(a){let t=new Aa(a.p.left,a.p,a.index,i);return ja(e,t,n-a.index)}{let r=new Aa(null,t._start,0,i);return ja(e,r,n)}},Na=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===X&&ka(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new Z(U(a,W(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new X(o,r));l.integrate(e,0),n.right=l,n.forward()})},Pa=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Fa=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===X&&ka(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Ia=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!ka(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Z(U(a,W(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new X(s,c)),n.right.integrate(e,0),n.forward()}}return o},La=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Fa(n,i);let s=Ia(e,t,n,i),c=r.constructor===String?new bo(r):r instanceof J?new Ao(r):new fo(r),{left:l,right:u,index:d}=n;t._searchMarker&&ra(t._searchMarker,n.index,c.getLength()),u=new Z(U(o,W(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Na(e,t,n,s)},Ra=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Fa(n,i);let s=Ia(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===X));){if(!n.right.deleted)switch(n.right.content.constructor){case X:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(ka(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&G(e,U(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`\n`;n.right=new Z(U(o,W(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new bo(i)),n.right.integrate(e,0),n.forward()}Na(e,t,n,s)},za=(e,n,r,i,a)=>{let o=n,s=t();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===X){let e=o.content;s.set(e.key,e)}o=o.right}let c=0,l=!1;for(;n!==o;){if(r===n&&(l=!0),!n.deleted){let t=n.content;switch(t.constructor){case X:{let{key:r,value:o}=t,u=i.get(r)??null;(s.get(r)!==t||u===o)&&(n.delete(e),c++,!l&&(a.get(r)??null)===o&&u!==o&&(u===null?a.delete(r):a.set(r,u))),!l&&!n.deleted&&Pa(a,t);break}}}n=n.right}return c},Ba=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===X){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Va=e=>{let r=0;return K(e.doc,i=>{let a=e._start,o=e._start,s=t(),c=n(s);for(;o;){if(o.deleted===!1)switch(o.content.constructor){case X:Pa(c,o.content);break;default:r+=za(i,a,o,s,c),s=n(c),a=o}o=o.right}}),r},Ha=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Si(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===X&&e.constructor!==Y&&t.add(e.parent)})}K(n,n=>{dr(e,e.deleteSet,e=>{if(e instanceof Y||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===X?t.add(r):Ba(n,e)});for(let e of t)Va(e)})},Ua=(e,t,r)=>{let i=r,a=n(t.currentAttributes),o=t.right;for(;r>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Ao:case fo:case bo:r<t.right.length&&G(e,U(t.right.id.client,t.right.id.clock+r)),r-=t.right.length,t.right.delete(e)}t.forward()}o&&za(e,o,t.right,a,t.currentAttributes);let s=(t.left||t.right).parent;return s._searchMarker&&ra(s._searchMarker,t.index,-i+r),t};var Wa=class extends Yi{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];K(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},at(o)||(e.attributes=tt({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Ao:case fo:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case bo:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case X:{let{key:t,value:s}=i.content;if(this.adds(i)){if(!this.deletes(i)){let c=n.get(t)??null;ka(c,s)?s!==null&&i.delete(e):(a===`retain`&&u(),ka(s,r.get(t)??null)?delete o[t]:o[t]=s)}}else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;ka(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(ka(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Pa(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},Ga=class e extends J{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??q(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new Wa(this,e,t);ia(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??q();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===bo&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):K(this.doc,n=>{let r=new Aa(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`\n`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&La(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&Ua(n,r,a.delete):Ra(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??q();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(fi(s,e)||t!==void 0&&fi(s,t))switch(s.content.constructor){case bo:{let r=i.get(`ychange`);e!==void 0&&!fi(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!fi(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case Ao:case fo:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case X:fi(s,e)&&(c(),Pa(i,s.content))}s=s.right}c()};return e||t?K(a,n=>{e&&pi(n,e),t&&pi(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):K(r,r=>{let i=Ma(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),La(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):K(r,r=>{let i=Ma(r,this,e,!n);La(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):K(n,n=>{Ua(n,Ma(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):K(r,r=>{let i=Ma(r,this,e,!1);i.right!==null&&Ra(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):K(this.doc,t=>{ga(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):K(this.doc,n=>{_a(n,this,e,t)})}getAttribute(e){return va(this,e)}getAttributes(){return ya(this)}_write(e){e.writeTypeRef(To)}};let Ka=e=>new Ga;var qa=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??q()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Xa||t.constructor===Ja)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},Ja=class e extends J{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof J?e.clone():e)),t}get length(){return this.doc??q(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new qa(this,e)}querySelector(e){e=e.toUpperCase();let t=new qa(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),l(new qa(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){ia(this,e,new Qa(this,t,e))}toString(){return ca(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),sa(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):K(this.doc,n=>{pa(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)K(this.doc,n=>{let r=e&&e instanceof J?e._item:e;da(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw Se(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):K(this.doc,n=>{ha(n,this,e,t)})}toArray(){return oa(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ua(this,e)}slice(e=0,t=this.length){return aa(this,e,t)}forEach(e){sa(this,e)}_write(e){e.writeTypeRef(Do)}};let Ya=e=>new Ja;var Xa=class e extends Ja{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName),n=this.getAttributes();return rt(n,(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof J?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):K(this.doc,t=>{ga(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):K(this.doc,n=>{_a(n,this,e,t)})}getAttribute(e){return va(this,e)}hasAttribute(e){return ba(this,e)}getAttributes(e){return e?xa(this,e):ya(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return sa(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Eo),e.writeKey(this.nodeName)}};let Za=e=>new Xa(e.readKey());var Qa=class extends Yi{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},$a=class e extends Da{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Oo),e.writeKey(this.hookName)}};let eo=e=>new $a(e.readKey());var to=class e extends Ga{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(ko)}};let no=e=>new to;var ro=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ce()}mergeWith(e){return!1}write(e,t,n){throw Ce()}integrate(e,t){throw Ce()}},Y=class extends ro{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),gi(e.doc.store,this)}write(e,t){e.writeInfo(0),e.writeLen(this.length-t)}getMissing(e,t){return null}},io=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw Ce()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}};let ao=e=>new io(e.readBuf());var oo=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){gr(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}};let so=e=>new oo(e.readLen()),co=(e,t)=>new Cr({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});var lo=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(co(this.doc.guid,this.opts))}splice(e){throw Ce()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}};let uo=e=>new lo(co(e.readString(),e.readAny()));var fo=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw Ce()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}};let po=e=>new fo(e.readJSON());var X=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw Ce()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}};let mo=e=>new X(e.readKey(),e.readJSON());var ho=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}};let go=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new ho(n)},_o=bt(`node_env`)===`development`;var vo=class e{constructor(e){this.arr=e,_o&&ut(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}};let yo=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new vo(n)};var bo=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}};let xo=e=>new bo(e.readString()),So=[Ta,Oa,Ka,Za,Ya,eo,no],Co=0,wo=1,To=2,Eo=3,Do=4,Oo=5,ko=6;var Ao=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw Ce()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}};let jo=e=>new Ao(So[e.readTypeRef()](e)),Mo=(e,t)=>{let n=t,r=0,i;do r>0&&(n=U(n.client,n.clock+r)),i=vi(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Z);return{item:i,diff:r}},No=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Po=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Z(U(r,i+n),t,U(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=U(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},Fo=(e,t)=>d(e,e=>pr(e.deletions,t)),Io=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return G(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Io(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=G(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:G(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:G(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else{if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||pr(r,d.right.id)||Fo(a.undoStack,d.right.id)||Fo(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=G(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;d!==null&&d.parent._item!==u&&(d=p._map.get(t.parentSub)||null)}let m=W(s,c),h=U(c,m),g=new Z(h,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=h,No(g,!0),g.integrate(e,0),g};var Z=class e extends ro{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=W(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=W(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ei&&this.id.client!==this.parent.client&&this.parent.clock>=W(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=bi(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=G(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===Y||this.right&&this.right.constructor===Y)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ei){let e=vi(n,this.parent);this.parent=e.constructor===Y?null:e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=bi(e,e.doc.store,U(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),ti(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(ti(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(vi(e.doc.store,n.origin)))r.has(vi(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),gi(e.doc.store,this),this.content.integrate(e,this),Ti(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Y(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:U(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&ti(e.origin,this.lastId)&&this.right===e&&ti(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),gr(e.deleteSet,this.id.client,this.id.clock,this.length),Ti(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw we();this.content.gc(e),t?xi(e,this,new Y(this.id,this.length)):this.content=new oo(this.length)}write(e,t){let n=t>0?U(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=ni(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===ei?(e.writeParentInfo(!1),e.writeLeftID(t)):we();i!==null&&e.writeString(i)}this.content.write(e,t)}};let Lo=(e,t)=>Ro[t&31](e),Ro=[()=>{we()},so,go,ao,xo,po,mo,jo,yo,uo,()=>{we()}];var zo=class extends ro{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){we()}write(e,t){e.writeInfo(10),L(e.restEncoder,this.length-t)}getMissing(e,t){return null}};let Bo=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Vo=`__ $YJS$ __`;Bo[Vo]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Bo[Vo]=!0;let Q=Object.freeze({stateBytes:262144,updateBytes:32768,textLength:32768,clients:128,structs:16384,historyUnits:1048576,undoEntries:100,undoUnits:32768}),Ho=new TextEncoder,Uo=(e,t)=>{throw Object.assign(Error(t),{code:e})},$=(e,t,n)=>{e||Uo(t,n)},Wo=e=>Number.isSafeInteger(e)&&e>=0,Go=e=>{$(typeof e==`string`,`SHARED_TEXT_INPUT`,`Shared text must be a string`),$(e.length<=Q.textLength,`SHARED_TEXT_LIMIT`,`Shared text exceeds its character limit`);for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=55296&&n<=56319){let n=e.charCodeAt(++t);$(n>=56320&&n<=57343,`SHARED_TEXT_INPUT`,`Shared text contains an incomplete Unicode character`)}else $(n<56320||n>57343,`SHARED_TEXT_INPUT`,`Shared text contains an incomplete Unicode character`)}return e};function Ko(e){$(e instanceof Uint8Array,`SHARED_TEXT_INPUT`,`Expected shared text bytes`);let t=``;for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function qo(e,t=Q.updateBytes){$(typeof e==`string`&&e.length>0&&e.length<=4*Math.ceil(t/3),`SHARED_TEXT_LIMIT`,`Shared text data exceeds its byte limit`),$(e.length%4==0&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e),`SHARED_TEXT_INPUT`,`Expected canonical base64 shared text data`);let n=atob(e);$(n.length<=t,`SHARED_TEXT_LIMIT`,`Shared text data exceeds its byte limit`);let r=Uint8Array.from(n,e=>e.charCodeAt(0));return $(Ko(r)===e,`SHARED_TEXT_INPUT`,`Expected canonical base64 shared text data`),r}function Jo(e){let t;class n extends Tr{constructor(e){super(e),t=e}}let r=Li(e,n);$(t.pos===e.length,`SHARED_TEXT_STATE`,`Shared text data contains trailing bytes`),$(r.structs.length<=Q.structs&&r.ds.clients.size<=Q.clients,`SHARED_TEXT_LIMIT`,`Shared text history exceeds its limit`);let i=0,a=0,o=new Map;for(let e of r.structs)$(Wo(e.id.client)&&Wo(e.id.clock)&&Wo(e.length)&&e.length>0,`SHARED_TEXT_STATE`,`Invalid shared text history`),$(!o.has(e.id.client)||e.id.clock>=o.get(e.id.client),`SHARED_TEXT_STATE`,`Shared text history overlaps itself`),o.set(e.id.client,e.id.clock+e.length),i+=e.length,$(e.id.clock+e.length<=Q.historyUnits&&i<=Q.historyUnits,`SHARED_TEXT_LIMIT`,`Shared text history needs a new epoch`),e instanceof Z?($(e.parentSub===null&&(e.parent===null||typeof e.parent!=`string`||e.parent===`text`),`SHARED_TEXT_STATE`,`Shared text accepts only its plaintext field`),$(e.content instanceof bo||e.content instanceof oo,`SHARED_TEXT_STATE`,`Shared text cannot contain formatting, embedded values or other shared types`),e.content instanceof bo&&Go(e.content.str)):$(e instanceof Y,`SHARED_TEXT_STATE`,`Unsupported shared text history`);for(let[e,t]of r.ds.clients){$(Wo(e),`SHARED_TEXT_STATE`,`Invalid shared text deletion`),a+=t.length,$(a<=Q.structs,`SHARED_TEXT_LIMIT`,`Shared text deletion history exceeds its limit`);for(let e of t)$(Wo(e.clock)&&Wo(e.len)&&e.len>0&&e.clock+e.len<=Q.historyUnits,`SHARED_TEXT_STATE`,`Invalid shared text deletion`)}return r}function Yo(e,t){let n=new Map;for(let e of t.structs){let t=n.get(e.id.client)||[];t.push(e),n.set(e.id.client,t)}let r=(t,r)=>{let i=e=>{if(!e)return;let t=0,n=e.length;for(;t<n;){let i=t+n>>>1;e[i].id.clock<=r?t=i+1:n=i}let i=e[t-1];return i&&r<i.id.clock+i.length?i:void 0};return i(e.store.clients.get(t))||i(n.get(t))},i=(e,t)=>{let n=r(e,t);if(n instanceof Z&&n.content instanceof bo){let e=t-n.id.clock,r=n.content.str;$(ts(r,e),`SHARED_TEXT_STATE`,`Shared text update splits a Unicode character`)}};for(let e of t.structs)e instanceof Z&&(e.origin&&i(e.origin.client,e.origin.clock+1),e.rightOrigin&&i(e.rightOrigin.client,e.rightOrigin.clock));for(let[e,n]of t.ds.clients)for(let t of n)i(e,t.clock),i(e,t.clock+t.len)}function Xo(e){let t=e.getText(`text`);$(e.share.size===1&&e.share.get(`text`)===t&&t._map.size===0&&e.getSubdocs().size===0,`SHARED_TEXT_STATE`,`Shared text accepts only its plaintext field`),$(e.store.pendingStructs===null&&e.store.pendingDs===null,`SHARED_TEXT_STATE`,`Shared text update is missing earlier history`),$(e.store.clients.size<=Q.clients,`SHARED_TEXT_LIMIT`,`Shared text history needs a new epoch`);let n=0,r=0;for(let i of e.store.clients.values())for(let e of i)n++,r+=e.length,$(n<=Q.structs&&r<=Q.historyUnits,`SHARED_TEXT_LIMIT`,`Shared text history needs a new epoch`),e instanceof Z?$(e.parent===t&&e.parentSub===null&&(e.content instanceof bo||e.content instanceof oo),`SHARED_TEXT_STATE`,`Shared text contains unsupported history`):$(e instanceof Y,`SHARED_TEXT_STATE`,`Unsupported shared text history`);for(let e of t.toDelta())$(typeof e.insert==`string`&&e.attributes===void 0,`SHARED_TEXT_STATE`,`Shared text cannot contain formatting or embedded values`);return Go(t.toString())}function Zo(e,t,n){let r=qo(t,n);Yo(e,Jo(r)),zr(e,r),Xo(e)}function Qo(e){let t=new Cr;t.getText(`text`);try{return Zo(t,e,Q.stateBytes),t}catch(e){throw t.destroy(),e}}function $o(e){let t=Xo(e),n=Hr(e);return $(n.length<=Q.stateBytes,`SHARED_TEXT_LIMIT`,`Shared text history needs a new epoch`),{state:Ko(n),value:t}}function es(e){try{return e()}catch(e){if(typeof e?.code==`string`&&e.code.startsWith(`SHARED_TEXT_`))throw e;Uo(`SHARED_TEXT_STATE`,`Invalid shared text data`)}}let ts=(e,t)=>Wo(t)&&t<=e.length&&!(t>0&&t<e.length&&e.charCodeAt(t-1)>=55296&&e.charCodeAt(t-1)<=56319&&e.charCodeAt(t)>=56320&&e.charCodeAt(t)<=57343),ns=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function rs({protocol:e,epoch:t,state:n}){$(e===1&&typeof t==`string`&&ns.test(t),`SHARED_TEXT_INPUT`,`Expected a versioned shared text epoch`);let r=es(()=>Qo(n)),i=r.getText(`text`),a={},o={},s=new WeakMap,c=new Pi(i,{trackedOrigins:new Set([a]),captureTimeout:0}),l=!1,u=null,d=()=>{if($(!l,`SHARED_TEXT_CLOSED`,`Shared text session is closed`),u)throw u},f=e=>{throw u=e,e},p=(e=[])=>{let t=e=>[...e.deletions.clients.values()].reduce((e,t)=>e+t.reduce((e,t)=>e+t.len,0),0),n=[...c.undoStack,...c.redoStack].reduce((e,n)=>e+t(n),0);for(;c.undoStack.length+c.redoStack.length>Q.undoEntries||n>Q.undoUnits;){let r=(c.undoStack.length?c.undoStack:c.redoStack).shift();n-=t(r),e.push(r.deletions)}if(!e.length)return;let i=hr(e);r.transact(e=>{dr(e,i,e=>{e instanceof Z&&(e.keep=!1)});for(let t of[...c.undoStack,...c.redoStack])dr(e,t.deletions,e=>{e instanceof Z&&(e.keep=!0)});ki(i,r.store,()=>!0)},o)},m=e=>{d();let t=c.redoStack.map(e=>e.deletions);try{return r.transact(e,a),p(t),i.toString()}catch(e){return f(e)}},h=e=>{d();let t=c[e](),n;try{n=Go(i.toString())}catch(n){throw t&&c[e===`undo`?`redo`:`undo`](),n}try{return p(),n}catch(e){return f(e)}};return Object.freeze({getValue(){return $(!l,`SHARED_TEXT_CLOSED`,`Shared text session is closed`),i.toString()},splice(e,t,n=``){d();let r=i.toString();return Go(n),$(Wo(t)&&ts(r,e)&&ts(r,e+t),`SHARED_TEXT_INPUT`,`Choose complete characters within the shared text`),$(r.length-t+n.length<=Q.textLength&&Ho.encode(n).length+1024<=Q.updateBytes,`SHARED_TEXT_LIMIT`,`Shared text edit exceeds its limit`),!t&&!n?r:m(()=>{t&&i.delete(e,t),n&&i.insert(e,n)})},captureSelection(e,t=e,n=`none`){d();let r=i.toString();$(ts(r,e)&&ts(r,t)&&e<=t&&[`none`,`forward`,`backward`].includes(n),`SHARED_TEXT_INPUT`,`Invalid shared text selection`);let a=Object.freeze({});return s.set(a,{start:ci(i,e),end:ci(i,t),direction:n}),a},resolveSelection(e){d(),$(e&&s.has(e),`SHARED_TEXT_INPUT`,`Selection belongs to another shared text session`);let t=s.get(e),n=ui(t.start,r),a=ui(t.end,r);return $(n?.type===i&&a?.type===i,`SHARED_TEXT_STATE`,`Shared text selection is unavailable`),{start:Math.min(n.index,a.index),end:Math.max(n.index,a.index),direction:t.direction}},receive(n){return d(),$(n?.protocol===e&&n.epoch===t,`SHARED_TEXT_STATE`,`Shared text epoch changed; retain the local draft and reopen explicitly`),es(()=>{let e=Qo(Ko(Hr(r)));try{Zo(e,n.state,Q.stateBytes),$o(e)}finally{e.destroy()}return zr(r,qo(n.state,Q.stateBytes),o),i.toString()})},getUpdateSince(n){return d(),$(n?.protocol===e&&n.epoch===t,`SHARED_TEXT_STATE`,`Shared text epoch changed; retain the local draft and reopen explicitly`),es(()=>{let i=Qo(n.state);try{$o(r);let n=Hr(r,Jr(i));return $(n.length<=Q.updateBytes,`SHARED_TEXT_LIMIT`,`Shared text batch exceeds its limit`),{protocol:e,epoch:t,update:Ko(n)}}finally{i.destroy()}})},undo(){return h(`undo`)},redo(){return h(`redo`)},canUndo(){return!l&&c.undoStack.length>0},canRedo(){return!l&&c.redoStack.length>0},checkpoint(){return d(),es(()=>({protocol:e,epoch:t,...$o(r)}))},dispose(){l||(l=!0,c.destroy(),r.destroy())}})}function is(e,t,n,r=null,i=[]){let a=new Map,o=[`text`,`search`,`email`,`tel`,`url`],s=new Set(i),c=new Map,l=new Set,u=new Map,d=!1,f={},p=(e,t,n)=>e?e.some(e=>e.value===String(n)):t.tagName!==`SELECT`||[...t.options].some(e=>e.value===String(n)),m=(e,t)=>{if(clearTimeout(t.timer),c.delete(e),d)return;let r;return r=Promise.resolve().then(()=>{if(!d)return t.callback()}).catch(t=>{u.set(e,t),n(t.message)}).finally(()=>l.delete(r)),l.add(r),r},h=(e,t)=>{if(d)throw Error(`This interface has closed; shared edits stopped.`);if(typeof e!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(e))throw Error(`A shared edit key starts with a letter and holds only letters, digits, - and _ (up to 100 characters).`);if(typeof t!=`function`)throw Error(`Give scheduleSharedEdit a function to run.`);if(!c.has(e)&&c.size+l.size>=32||!u.has(e)&&u.size>=32)throw Error(`Too many scheduled shared edits`);u.delete(e);let n=c.get(e),r={callback:t,started:n?.started??Date.now(),timer:null};n&&clearTimeout(n.timer),r.timer=setTimeout(()=>m(e,r),Math.max(0,Math.min(150,500-(Date.now()-r.started)))),c.set(e,r)},g=(i,c)=>{if(!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(i)||a.has(i))throw Error(`Use one control per named shared field`);let l=e.getElementById(c),u=l?.tagName===`FIELDSET`?[...l.querySelectorAll(`input[type="radio"]`)]:null;if(!l||![`INPUT`,`TEXTAREA`,`SELECT`,`FIELDSET`].includes(l.tagName)||u&&!u.length||l.tagName===`INPUT`&&![`text`,`search`,`email`,`tel`,`url`,`number`,`range`,`checkbox`,`color`].includes(l.type))throw Error(`Bind an existing text, number, checkbox or select control, or a fieldset of radio buttons`);if(s.has(i)){let e=l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type),t=l.disabled,n=l.readOnly,r=l.getAttribute(`title`),s=l.getAttribute(`aria-readonly`),c=l.getAttribute(`aria-disabled`);e?(l.readOnly=!0,l.setAttribute(`aria-readonly`,`true`)):(l.disabled=!0,l.setAttribute(`aria-disabled`,`true`)),l.setAttribute(`title`,`Connected input. Change its source in Flow.`);let u={flush:async()=>{},status:()=>({dirty:!1,saving:!1,problem:null,canEdit:!1,composing:!1,interrupted:!1}),setDefault(){},dispose(){l.disabled=t,l.readOnly=n,r===null?l.removeAttribute(`title`):l.setAttribute(`title`,r),s===null?l.removeAttribute(`aria-readonly`):l.setAttribute(`aria-readonly`,s),c===null?l.removeAttribute(`aria-disabled`):l.setAttribute(`aria-disabled`,c),a.delete(i)}};return a.set(i,u),u.dispose}if(r&&(l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type))){let e=r.bind(i,l),t=e.dispose;return e.dispose=()=>{t(),a.delete(i)},a.set(i,e),e.dispose}let d=l.disabled,m={exists:!1},h,g=!1,_=!1,v=null,y=!1,b=!1,x=null,S=null,C=null,w=!1,T=!1,E,D=l.tagName===`TEXTAREA`||l.tagName===`INPUT`&&o.includes(l.type),ee=e=>{S=e,l.setCustomValidity(e.message),n(e.message)},O=()=>u.find(e=>e.checked)?.value??``,k=e=>{let n=u?O():l.type===`checkbox`?l.checked:l.value;if(u)for(let t of u)t.checked=t.value===String(e??``);else l.type===`checkbox`?l.checked=!!e:l.value!==String(e??``)&&(l.value=String(e??``));(u?O():l.type===`checkbox`?l.checked:l.value)!==n&&queueMicrotask(()=>{y||t.announce?.()})},A=()=>u?O():l.type===`checkbox`?l.checked:[`number`,`range`].includes(l.type)?l.valueAsNumber:l.value,j=Object.hasOwn(f,i)&&p(u,l,f[i])?f[i]:A(),M=()=>{if(clearTimeout(v),v=null,_)return x;if(y||w||!g||!b||S)return;let e=h;g=!1,C=null,_=!0;let n=!1;return x=Promise.resolve().then(()=>t.updateShared({[i]:e},{[i]:m})).then(()=>{m={exists:!0,value:e},l.setCustomValidity(``),!S&&g&&Object.is(h,e)&&(g=!1,C=null)},e=>{n=!0,g=!0,ee(e)}).finally(()=>{_=!1,x=null,!y&&!n&&g&&h!==e&&N(),!y&&!g&&F(t.getShared())}),x},N=()=>{clearTimeout(v),v=setTimeout(M,Math.max(0,Math.min(150,500-(Date.now()-(C??Date.now())))))},te=()=>{!y&&D&&b&&!d&&(w=!0,clearTimeout(v),v=null)},P=e=>{if(y||!b||d)return;if(D&&e?.isComposing){te();return}if(w)return;let t=A();if(typeof t==`number`&&!Number.isFinite(t)){ee(Error(`Enter a finite number`));return}E!==void 0&&Object.is(t,E)||(E=void 0,(S||!Object.is(t,g||_?h:m.exists?m.value:j))&&((S||C===null)&&(C=Date.now()),h=t,S=null,g=!0,N()))},F=e=>{y||(b=e.canEdit,l.disabled=d||!b,!b&&w&&(T=!0),!b&&(g||w)&&ee(Error(`Editing access changed. Your unsaved draft has been preserved.`)),!(w||g||_||S)&&(m=Object.hasOwn(e.state,i)?{exists:!0,value:e.state[i]}:{exists:!1},k(m.exists?m.value:j)))},ne=t.onShared(F),I=()=>{if(!y&&w){if(w=!1,!b||T){T=!1,h=A(),E=h,g=!0,ee(Error(`Editing access changed. Your unsaved draft has been preserved.`));return}P(),g&&!_&&!S?(C=Date.now(),N()):!g&&!_&&!S&&F(t.getShared())}};l.disabled=d||!t.getShared().canEdit;let re=u?`focusout`:`blur`;l.addEventListener(`input`,P),l.addEventListener(`change`,P),l.addEventListener(re,M),l.addEventListener(`compositionstart`,te),l.addEventListener(`compositionend`,I);let L=()=>{y=!0,w=!1,clearTimeout(v),ne(),l.removeEventListener(`input`,P),l.removeEventListener(`change`,P),l.removeEventListener(re,M),l.removeEventListener(`compositionstart`,te),l.removeEventListener(`compositionend`,I),l.disabled=d,a.delete(i)};return a.set(i,{dispose:L,flush:M,status(){return{dirty:g,saving:_,problem:S,canEdit:b,composing:w,interrupted:E!==void 0}},setDefault(e){j=e,F(t.getShared())},setInputDefault(e){p(u,l,e)&&this.setDefault(e)}}),L},_=new Map,v=new Map,y=new WeakSet,b=[`text`,`search`,`email`,`tel`,`url`,`number`,`range`,`checkbox`,`color`],x=/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/,S=/(?:password|secret|credential|authorization|cookie|token|api[_-]?key|private[_-]?key)/i,C=/^(?:current-password|new-password|one-time-code|cc-)/i,w=null,T=null,E=e=>{let t=_.get(e);if(t!==void 0){_.delete(e),v.delete(t);try{a.get(t)?.dispose()}catch{}a.delete(t)}},D=(t,n)=>{let r=e.getElementById(n);r&&_.has(r)&&E(r),v.has(t)&&E(v.get(t));let i=g(t,n);return r&&y.add(r),i},ee=e=>{let t=e.getAttribute(`data-stillmade-share`)||e.getAttribute(`name`)||e.id||(e.tagName===`FIELDSET`?e.querySelector(`input[type="radio"][name]`)?.getAttribute(`name`):``)||``;return x.test(t)?t:null},O=e=>!e.isConnected||e.closest(`[data-stillmade-local]`)?!1:e.tagName===`FIELDSET`?!!e.querySelector(`input[type="radio"]`)&&!e.querySelector(`fieldset`):e.tagName===`INPUT`?b.includes(e.type):e.tagName===`TEXTAREA`||e.tagName===`SELECT`,k=t=>{if(y.has(t)||_.has(t)||!O(t))return;let n=ee(t);if(!(!n||a.has(n)||a.size>=100)&&!(!t.hasAttribute(`data-stillmade-share`)&&(S.test(n)||S.test(t.getAttribute(`name`)||``)||S.test(t.id||``)||C.test(t.getAttribute(`autocomplete`)||``)))){if(!t.id){let r=`sm-shared-${n}`,i=1;for(;e.getElementById(r);)r=`sm-shared-${n}-${++i}`;t.id=r}else if(e.getElementById(t.id)!==t)return;try{g(n,t.id),_.set(t,n),v.set(n,t)}catch{a.delete(n)}}},A=()=>{if(T=null,!(d||j))try{for(let e of[..._.keys()])(!e.isConnected||e.closest(`[data-stillmade-local]`))&&E(e);for(let t of e.querySelectorAll(`input,textarea,select,fieldset`))k(t)}catch(e){n(e.message)}},j=!1,M=()=>{if(!j){j=!0,w?.disconnect(),w=null,T&&=(clearTimeout(T),null);for(let e of[..._.keys()])E(e)}},N=()=>{j||d||w||typeof MutationObserver!=`function`||!e.documentElement||(A(),w=new MutationObserver(()=>{!T&&!d&&(T=setTimeout(A,30))}),w.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`name`,`id`,`type`,`data-stillmade-local`,`data-stillmade-share`]}))};e.readyState===`loading`?e.addEventListener?.(`DOMContentLoaded`,N,{once:!0}):typeof setTimeout==`function`&&typeof MutationObserver==`function`&&setTimeout(N,0);let te=()=>{let t=[...e.querySelectorAll(`[data-stillmade-share]`)];if(t.length>100)throw Error(`Use at most 100 shared controls`);for(let n of t){let t=n.getAttribute(`data-stillmade-share`),r=n.id;if(typeof t!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(t)||typeof r!=`string`||!r||r.length>200||e.getElementById(r)!==n)throw Error(`Each data-stillmade-share control needs a unique ID and valid shared field name`);D(t,r)}return t.length},P=()=>{if(d)throw Error(`Block closed before edits could be flushed`);if([...a.values()].some(e=>e.status().composing))throw Error(`Finish composing text before leaving this Block or running an action.`);let e=[...a.values()].find(e=>e.status().interrupted);if(e)throw e.status().problem};return{bindShared:D,bindAnnotated:te,bindAutomatic:N,ownSharing:M,scheduleSharedEdit:h,flushAll:async()=>{if(d)throw Error(`Block closed before edits could be flushed`);for(let e=0;e<32;e++){if(d)throw Error(`Block closed before edits could be flushed`);P();let e=[...l];for(let[t,n]of[...c])e.push(m(t,n));for(let t of a.values())e.push(t.flush());if(await Promise.all(e),d)throw Error(`Block closed before edits could be flushed`);if(u.size)throw u.values().next().value;let t=!1;for(let e of a.values()){let n=e.status();if(n.problem)throw n.problem;if(n.composing)throw Error(`Finish composing text before leaving this Block or running an action.`);if(n.dirty&&!n.canEdit)throw Error(`Editing access changed. Your draft is not saved.`);t||=n.dirty||n.saving}if(!t&&!c.size&&!l.size)return{queued:!0}}throw Error(`Edits are still arriving. Finish editing before leaving this Block.`)},assertNoComposition:P,getBindingStatus:e=>a.get(e)?.status(),setSharedDefaults(e){if(!e||typeof e!=`object`||Array.isArray(e)||Object.keys(e).length>100||JSON.stringify(e).length>65536)throw Error(`Use bounded shared control defaults`);for(let[t,n]of Object.entries(e))a.get(t)?.setDefault(n)},useInputDefaults(e){let t=f;if(f={},e&&typeof e==`object`&&!Array.isArray(e))for(let[t,n]of Object.entries(e))[`string`,`number`,`boolean`].includes(typeof n)&&(f[t]=n);for(let[e,n]of a)if(Object.hasOwn(f,e)&&!(Object.hasOwn(t,e)&&t[e]===f[e]))try{(n.setInputDefault||n.setDefault)?.call(n,f[e])}catch{}},dispose(){d=!0,w?.disconnect(),T&&clearTimeout(T);for(let e of c.values())clearTimeout(e.timer);c.clear();for(let e of[...a.values()])e.dispose()}}}function as(e,t,n,r,i,a=null){let o=new Map,s=new Map,c=[],l=0,u=!1,d=``,f=()=>{if(u)return;let e=[...o.values()].map(e=>e.status()),t={count:e.length,dirty:e.filter(e=>e.dirty||e.composing||e.interrupted).length,pending:e.filter(e=>e.saving).length,readonly:e.filter(e=>!e.canEdit).length,error:e.find(e=>e.problem)?.problem.message?.slice(0,1e3)||null,retryable:e.some(e=>e.retryable)},n=JSON.stringify(t);n!==d&&(d=n,parent.postMessage({channel:r,session:i,op:`text-recovery-status`,status:t},`*`),a&&a.send({channel:r,session:i,op:`named-text-controls`,token:a.token,snapshot:[...o.values()].map(e=>e.nativeState?.()).filter(Boolean).slice(0,50)},`*`))},p=e=>Object.assign(Error(e?.message||String(e)),e?.code?{code:e.code}:{}),m=()=>{for(;!u&&s.size<4&&c.length;){let e=c.findIndex(e=>e.action!==`read`),t=c.splice(e<0?0:e,1)[0],n=String(++l);t.id=n,s.set(n,t),(a?.send||parent.postMessage.bind(parent))({channel:r,session:i,op:`text-request`,id:n,action:t.action,key:t.key,body:t.body,...t.nativeProof&&a?{nativeText:{token:a.token,callId:t.nativeProof.callId}}:{}},`*`)}},h=(e,t,n={},r=null)=>new Promise((i,a)=>{if(u||s.size+c.length>=128){a(Error(`Shared text is unavailable or busy. Your draft is retained.`));return}let o={action:e,key:t,body:n,nativeProof:r,resolve:i,reject:a,timer:null,id:null};o.timer=setTimeout(()=>{if(o.id)s.delete(o.id);else{let e=c.indexOf(o);e>=0&&c.splice(e,1)}a(Error(`Shared text acknowledgement timed out. Your draft is retained.`)),m()},3e4),c.push(o),m()}),g=e=>{let t=e.data;if(!(e.source!==parent||t?.channel!==r||t.session!==i||u)){if(t.op===`text-result`){let e=s.get(t.id);if(!e)return;s.delete(t.id),clearTimeout(e.timer),t.error?e.reject(p(t.error)):e.resolve(t.result),m()}else if(t.op===`text-refresh`)for(let e of o.values())e.refresh();else if(t.op===`text-retry`)for(let e of o.values())e.retry().catch(()=>{})}};addEventListener(`message`,g);let _=(r,i)=>{if(o.has(r)||o.size>=100)throw Error(`Use at most 100 distinct shared text controls.`);let s=new WeakMap,c=null,l=i.disabled,u=i.readOnly,d=i.value,m=`loading`,g=!1,_=null,v=null,y=null,b=null,x=!1,S=0,C=null,w=null,T=null,E=!1,D=!1,ee=!1,O=!1,k=null,A=null,j=null,M=t.getShared().canEdit===!0,N=i.value,te=()=>!!b&&!O&&!D&&M&&!/^(READ_ONLY|SHARED_TEXT_(SOURCE|EPOCH|CONFLICT|INPUT|LIMIT|STATE|UPDATE|PROTOCOL))$/.test(b.code||``),P=e=>{E||(b=p(e),D&&(O=!0),i.readOnly=!0,(x||O)&&(i.disabled=l),i.setCustomValidity(b.message),n(b.message),f())},F=()=>({start:i.selectionStart??0,end:i.selectionEnd??0,direction:i.selectionDirection||`none`}),ne=e=>{i.value!==e&&(i.value=e,queueMicrotask(()=>{E||t.announce?.()}))},I=t=>{if(N=v.getValue(),ne(N),t&&e.activeElement===i){let e=v.resolveSelection(t);i.setSelectionRange(e.start,e.end,e.direction)}},re=()=>{let e=F();return v.captureSelection(e.start,e.end,e.direction)},L=e=>{if(!E&&e){if(b||O){(!A||e.textRevision>=A.textRevision)&&(A=e);return}if(D){(!A||e.textRevision>=A.textRevision)&&(A=e);return}if(v&&i.value!==N)throw O=!0,x=!0,Error(`This control has an uncommitted draft. Copy it before reopening the Block.`);if(y&&e.epoch!==y.epoch)throw Object.assign(Error(`This shared text was reset. Copy your draft before reloading the Block.`),{code:`SHARED_TEXT_EPOCH`});if(!(y&&e.textRevision<y.textRevision)){if(y&&e.protocol===y.protocol&&e.sourceIdentity===y.sourceIdentity&&e.textRevision===y.textRevision&&e.state===y.state&&e.value===y.value){y=e;return}if(!v)v=rs(e),y=e,I();else{let t=re();v.receive(e),y=e,I(t)}m=`text`,i.disabled=l||!M,i.readOnly=u,i.setCustomValidity(``),f()}}},ie=()=>{m=`legacy`,i.disabled=l,i.readOnly=u,i.value=d,_=is(e,t,n),_.ownSharing(),_.bindShared(r,i.id),_.setSharedDefaults({[r]:d}),queueMicrotask(()=>{E||t.announce?.()})},ae=async(e=!1)=>E||!g||m===`legacy`||k||b?k:(k=(async()=>{let t=await h(`read`,r);if(E)return;if(t.unsupported){if(e)ie();else throw Error(`Shared text is no longer available. Your draft is retained.`);return}if(t.enabled){L(t.snapshot);return}if(!M){m=`waiting`,N=t.value,ne(t.value),i.disabled=!0;return}j={action:`initialize`,body:{protocol:1,requestId:crypto.randomUUID(),sourceIdentity:t.sourceIdentity}};let n=await h(j.action,r,j.body);j=null,E||L(n.snapshot)})().catch(P).finally(()=>{k=null,f()}),f(),k),oe=()=>{E||b||D||(T===null&&(T=Date.now()),clearTimeout(w),w=setTimeout(()=>{w=null,se().catch(()=>{})},Math.max(0,Math.min(200,600-(Date.now()-T)))))},se=async()=>{if(clearTimeout(w),w=null,_)return _.flushAll();if(k&&await k,b)throw b;if(E)throw Error(`Block closed before text was saved.`);if(!g||m===`loading`)throw Error(`Shared text is still loading. Wait before leaving this Block or running an action.`);if(D)throw Error(`Finish composing text before leaving this Block or running an action.`);if(v&&i.value!==N)throw O=!0,x=!0,P(Error(`This control has an uncommitted draft. Copy it before reopening the Block.`)),b;if(C){await C;return}if(!x)return;if(!M)throw Error(`Editing access changed. Your draft is retained.`);try{j={action:`update`,version:S,nativeProof:c?.version===S?{callId:c.callId}:null,body:{...v.getUpdateSince(y),requestId:crypto.randomUUID()}}}catch(e){throw P(e),e}x=!1,T=null;let e=j;C=h(e.action,r,e.body,e.nativeProof).then(t=>{E||(L(t.snapshot),!b&&!O&&(x=S!==e.version)),j=null}).catch(e=>{throw x=!0,P(e),e}).finally(()=>{C=null,x&&!b&&oe(),f()}),f(),await C},ce=e=>{if(m!==`text`||E||l||u||!M||O)return;if(e?.isComposing){R();return}if(D)return;if(b){i.value!==N&&(O=!0,x=!0,f());return}let t=i.value;if(t!==N)try{let n=0,r=N.length,i=t.length;for(;n<r&&n<i&&N[n]===t[n];)n++;for(n>0&&n<r&&/[\\uDC00-\\uDFFF]/.test(N[n])&&n--;r>n&&i>n&&N[r-1]===t[i-1];)r--,i--;r<N.length&&/[\\uDC00-\\uDFFF]/.test(N[r])&&(r++,i++),v.splice(n,r-n,t.slice(n,i)),N=v.getValue(),S++,c=s.has(e)?{version:S,callId:s.get(e)}:null,x=!0,oe(),f()}catch(e){O=!0,x=!0,P(e)}},R=()=>{m!==`text`||E||!M||l||u||b||(D=!0,clearTimeout(w),w=null,f())},le=()=>{if(D){if(D=!1,b||!M||ee){O=!0,x=!0,b||P(Error(`Editing access changed. Your composed draft is retained.`));return}if(ce(),A){let e=A;A=null;try{L(e)}catch(e){P(e)}}x&&oe(),f()}},ue=e=>{if(!(m!==`text`||D||b||!M||l||u||!(e.metaKey||e.ctrlKey)||e.altKey||![`z`,`y`].includes(e.key.toLowerCase()))){e.preventDefault();try{e.key.toLowerCase()===`y`||e.shiftKey?v.redo():v.undo(),I(),S++,x=!0,oe(),f()}catch(e){P(e)}}},de=()=>{m===`text`&&se().catch(()=>{})},fe=t.onShared(e=>{g=!0,M=e.canEdit===!0,m!==`legacy`&&(i.disabled=l||m!==`text`||!M,!M&&(x||D)&&(ee||=D,O=!0,P(Error(`Editing access changed. Your unsaved draft is retained.`))),o.has(r)&&m===`loading`&&ae(!0),f())});i.disabled=!0,i.addEventListener(`input`,ce),i.addEventListener(`change`,ce),i.addEventListener(`blur`,de),i.addEventListener(`keydown`,ue),i.addEventListener(`compositionstart`,R),i.addEventListener(`compositionend`,le);let pe=()=>{let e=String(i.value),t=i.hidden||i.closest(`[hidden]`)!==null;return{field:r,nodeId:i.id,type:i.tagName.toLowerCase()===`textarea`?`textarea`:i.type,value:e.slice(0,1e4),partial:e.length>1e4,disabled:i.disabled||l||u||t,ready:m===`text`&&!E&&!b&&!O&&!D&&!C&&!k&&!x&&!j&&M,identity:JSON.stringify([r,i.id,i.type,y?.protocol??null,y?.epoch??null,y?.sourceIdentity??null,y?.textRevision??null])}},me={nativeState:pe,async nativeEdit(e,t){let n=pe();if(!a||typeof t!=`string`||!/^\\d{1,9}$/.test(t)||!e||Object.keys(e).sort().join(`,`)!==`field,identity,previous,value`||e.field!==r||e.identity!==n.identity||n.partial||!n.ready||n.disabled||typeof e.previous!=`string`||e.previous!==n.value||typeof e.value!=`string`||e.value.length>1e4||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(r)||/password|credential|authorization|cookie|secret|token|api.?key/i.test(r)||!i.id||![`text`,`textarea`].includes(n.type))throw Error(`The original named text control changed or is unavailable.`);let o=new Event(`input`,{bubbles:!0});if(s.set(o,t),i.value=e.value,i.dispatchEvent(o),s.delete(o),i.value!==e.value||!x||D||O||b)throw Error(`The original text handler changed or refused this edit.`);let c=S;if(await se(),S!==c||i.value!==e.value||x||j||C||b)throw Error(`Original text changed while its acknowledgement was pending. Do not repeat the edit.`);return{value:i.value,identity:pe().identity}},flush:se,getValue:()=>i.value,status:()=>_?_.getBindingStatus(r):{dirty:x||!!j,saving:!!C||!!k,problem:b,canEdit:M,composing:D,interrupted:O,retryable:te()},setDefault(e){d=String(e??``),_&&_.setSharedDefaults({[r]:e})},refresh(){!b&&!E&&ae()},async retry(){if(!(E||C||k||!te())){if(b=null,i.setCustomValidity(``),j){let e=j;C=h(e.action,r,e.body,e.nativeProof).then(t=>{L(t.snapshot),e.action===`update`&&!b&&!O&&(x=S!==e.version),j=null}).catch(e=>{throw P(e),e}).finally(()=>{C=null,f()}),f(),await C}else await ae(m===`loading`);if(b)throw b;if(i.readOnly=u,A){let e=A;A=null;try{L(e)}catch(e){throw P(e),e}}x&&await se(),f()}},dispose(){E=!0,clearTimeout(w),fe(),_?.dispose(),v?.dispose(),o.delete(r),i.removeEventListener(`input`,ce),i.removeEventListener(`change`,ce),i.removeEventListener(`blur`,de),i.removeEventListener(`keydown`,ue),i.removeEventListener(`compositionstart`,R),i.removeEventListener(`compositionend`,le),i.disabled=l,i.readOnly=u,f()}};return o.set(r,me),g&&ae(!0),me},v=setInterval(()=>{for(let e of o.values())e.refresh()},15e3);return{bind:_,inspectNative(){return[...o.values()].map(e=>e.nativeState()).filter(e=>e.nodeId&&[`text`,`textarea`].includes(e.type)&&!/password|credential|authorization|cookie|secret|token|api.?key/i.test(e.field)).slice(0,50)},async dispatchNative(e,t){if(!e||typeof e.field!=`string`||!o.has(e.field))throw Error(`Inspect an existing original named text field.`);return o.get(e.field).nativeEdit(e,t)},getValues:()=>Object.fromEntries([...o].map(([e,t])=>[e,t.getValue()])),dispose(){u=!0,clearInterval(v),removeEventListener(`message`,g);for(let e of[...o.values()])e.dispose();for(let e of[...s.values(),...c])clearTimeout(e.timer),e.reject(Error(`Block closed before text was acknowledged.`));s.clear(),c.length=0}}}return e.installTextFrame=as,e})({});',nr=`(sharedAPI,onStatus)=>{const documentTools=(()=>{const BlockError=(class extends Error {
10
10
  constructor(code, message, details = []) {
11
11
  super(message);
12
12
  this.name = "BlockError";
@@ -1167,7 +1167,7 @@ bitsperframe: %d
1167
1167
  </g>
1168
1168
  </g>
1169
1169
  </g>
1170
- </g>`,Bk=`http://www.w3.org/2000/svg`,Vk=e=>e===`left`||e===`right`,Hk=(e,t)=>e.querySelector(`[data-role="${t}"]`)}));function Wk(e,t,n){e===`talk`&&(e=`talkGesture`);let r=Qk[e];return r?r(t,n):{}}function Gk(e){let t=(X(e*8.7)+1)/2;return{mOpen:2+t*12,mWidth:12+t*15,mCurve:2+X(e*4.6)*6}}function Kk(e,t=0){return{armR:6*X(e*4.6),armL:4*X(e*4.6+1),headTilt:1.2*X(e*2.2)+t*3}}function qk(e,...t){let n={...e};for(let e of t)for(let t in e)n[t]=(n[t]||0)+e[t];return n}var X,Jk,Yk,Xk,Zk,Qk,$k,eA,tA=o((()=>{X=Math.sin,Jk=Math.cos,Yk=Math.max,Xk=Math.PI,Zk=(e,t,n)=>e<t?t:e>n?n:e,Qk={idle(e){return{headTilt:1.2*X(e*1.2),bob:1.5*X(e*1.5),armR:-8+2*X(e),armL:8-2*X(e)}},stand(e){return{headTilt:.5*X(e*1.1),bob:.6*X(e*1.3)}},turn(e){return Qk.idle(e)},wave(e){return{armR:-150,elbowR:-30+18*X(e*9),headTilt:3,bob:1.2*X(e*1.5)}},point(e,t={}){return{armR:-132-Zk((t.aimDY||0)*18,-10,22),elbowR:-6,headTilt:Zk(-4+(t.aimDX||0)*6,-11,7),card:1,bob:X(e*1.3)}},look(e,t={}){return{headTilt:Zk((t.aimDX||0)*9,-11,11),bob:1.1*X(e*1.3)}},lookAround(e,t={}){return{headTilt:((t.aimDX||0)*8||0)+10*X(e*.9),bob:1.1*X(e*1.2),armR:-8+2*X(e)}},walk(e,t={}){let n=e*(t.speed||1.2)%1*2*Xk;return{legR:-28*X(n),legL:-28*X(n+Xk),kneeR:34*Yk(0,X(n+2)),kneeL:34*Yk(0,X(n+Xk+2)),armR:-8+22*X(n+Xk),armL:8+22*X(n),elbowR:-12,elbowL:12,bob:-2-4*(.5-.5*Jk(2*n))}},run(e,t={}){let n=e*(t.speed||1.2)*1.6%1*2*Xk;return{legR:-42*X(n),legL:-42*X(n+Xk),kneeR:46*Yk(0,X(n+2)),kneeL:46*Yk(0,X(n+Xk+2)),armR:-22+34*X(n+Xk),armL:22+34*X(n),elbowR:-42,elbowL:42,bob:-3-7*(.5-.5*Jk(2*n)),headTilt:-4}},sit(e){return{legR:-58,legL:-56,kneeR:76,kneeL:74,bob:40,armR:-14,armL:14,headTilt:1*X(e*1.1)}},fall(e){return{headTilt:34,armR:-58,armL:58,elbowR:20,elbowL:-20,legR:-42,legL:18,kneeR:20,bob:22}},handshake(e){return{armR:-72+5*X(e*7),elbowR:34,headTilt:4,bob:1}},handOverItem(e){return{armR:-84,elbowR:22,armL:12,headTilt:3,bob:X(e*1.4)}},argue(e){return{armR:-66+22*X(e*6),elbowR:-22,armL:12,headTilt:5*X(e*3.2),bob:1.5*X(e*2)}},shrug(e){return{armL:26,armR:-26,elbowL:-34,elbowR:34,headTilt:2*X(e*1.4),bob:1+1.4*(.5-.5*Jk(e*3))}},think(e){return{armR:-96,elbowR:-62,headTilt:8,armL:6,bob:.8*X(e*1.1)}},shocked(e){return{armR:-42,armL:42,elbowR:22,elbowL:-22,headTilt:-6,mOpen:15,mWidth:12,bob:-3+.6*X(e*8)}},celebrate(e){return{armL:150,armR:-150,elbowL:10,elbowR:-10,headTilt:2*X(e*4),bob:-6*Math.abs(X(e*4))}},cry(e){return{armR:-104,armL:104,elbowR:-58,elbowL:58,headTilt:12+2*X(e*5),mCurve:-8,bob:1.4*X(e*3)}},whisper(e){return{armR:-98,elbowR:-54,headTilt:6,mOpen:3+1.5*X(e*8),mWidth:12,bob:.6*X(e*1.5)}},talkGesture(e,t={}){return{armR:-14+10*X(e*4.6),elbowR:-16,armL:12+8*X(e*4.6+1),headTilt:1.6*X(e*2.2)+(t.aimDX||0)*4,bob:1.1*X(e*1.5)}},carryBox(e){return{armL:66,armR:-66,elbowL:-40,elbowR:40,headTilt:2,bob:1+.8*X(e*1.4)}},type(e){return{armR:-30,armL:30,elbowR:22,elbowL:-22,headTilt:7,bob:.5*X(e*6)}},drink(e){return{armR:-120,elbowR:-72,headTilt:-5,armL:8,bob:.6*X(e*1.3)}},sleep(e){return{headTilt:32,bob:1.4*X(e*.8),armR:-4,armL:4}},march(e,t={}){let n=e*(t.speed||1)%1*2*Xk;return{legR:-24*X(n),legL:-24*X(n+Xk),kneeR:40*Yk(0,X(n+2)),kneeL:40*Yk(0,X(n+Xk+2)),armR:-10+16*X(n+Xk),armL:10+16*X(n),elbowR:-24,elbowL:24,bob:-2-3*(.5-.5*Jk(2*n)),headTilt:0}},flee(e,t={}){return{...Qk.run(e,t),headTilt:-18+3*X(e*6),armR:-30+40*X(e*8),armL:30+40*X(e*8+Xk),mOpen:6}},salute(e){return{armR:-150,elbowR:-78,headTilt:-2,armL:6,bob:.5*X(e*1.2)}},aim(e,t={}){return{armR:-92-Zk((t.aimDY||0)*16,-12,16),elbowR:4,armL:6,headTilt:Zk((t.aimDX||0)*6,-8,8),bob:.5*X(e*1.3)}},duck(e){return{bob:30,kneeR:60,kneeL:60,legR:-18,legL:-18,headTilt:14,armR:-30,armL:30,elbowR:30,elbowL:-30}},cheer(e){return{armL:160,armR:-160,elbowL:8,elbowR:-8,headTilt:3*X(e*5),bob:-7*Math.abs(X(e*5)),mOpen:10,mWidth:14}},tablePoint(e,t={}){return{armR:-50-Zk((t.aimDY||0)*20,-14,18),elbowR:40,headTilt:Zk(10+(t.aimDX||0)*6,2,18),armL:8,bob:.6*X(e*1.2)}},standGuard(e){return{headTilt:.6*X(e*.8),bob:.5*X(e*1),armR:-4,armL:4,elbowR:8,elbowL:-8,legR:-6,legL:6}},sneak(e,t={}){let n=e*(t.speed||.7)%1*2*Xk;return{legR:-16*X(n),legL:-16*X(n+Xk),kneeR:44+10*Yk(0,X(n)),kneeL:44+10*Yk(0,X(n+Xk)),bob:22,headTilt:6,armR:-24,armL:24,elbowR:30,elbowL:-30}},jump(e){let t=e%1*2*Xk,n=Yk(0,X(t));return{bob:30-n*70,legR:-20+n*40,legL:-20+n*40,kneeR:40-n*30,kneeL:40-n*30,armR:-20-n*120,armL:20+n*120,headTilt:-2}},climb(e){let t=e*3;return{armR:-150+20*X(t),armL:-150+20*X(t+Xk),elbowR:-20,elbowL:-20,legR:-30+20*X(t+Xk),legL:-30+20*X(t),kneeR:40,kneeL:40,bob:-2+3*X(t*2),headTilt:-4}},nod(e){let t=X(e*4);return{headTilt:1.5*X(e*1.1),bob:1+3*Yk(0,t),armR:-8,armL:8}},headShake(e){return{headTilt:12*X(e*5),bob:.6*X(e*1.3),armR:-8,armL:8}},facepalm(e){return{armR:-128,elbowR:-96,headTilt:16,armL:6,bob:.6*X(e*1.1)}},thumbsUp(e){return{armR:-70,elbowR:44,headTilt:-3,armL:8,bob:.8*X(e*1.4)}},clap(e){let t=24*(.5+.5*X(e*9));return{armR:-40-t,armL:40+t,elbowR:40,elbowL:-40,headTilt:2*X(e*2),bob:1+.8*X(e*4.5)}},beckon(e,t={}){return{armR:-60+12*X(e*5),elbowR:30+20*X(e*5),headTilt:Zk(2+(t.aimDX||0)*5,-8,8),armL:8,bob:.8*X(e*1.4)}},presentPalm(e,t={}){return{armR:-58-Zk((t.aimDY||0)*14,-10,14),elbowR:24,headTilt:Zk((t.aimDX||0)*6,-8,8),armL:8,bob:.6*X(e*1.3)}},laugh(e){return{headTilt:-12+4*X(e*9),bob:2+3*Yk(0,X(e*7)),armR:-40,armL:40,elbowR:30,elbowL:-30,mOpen:12,mWidth:18,mCurve:8}},angryStomp(e){let t=e%1*2*Xk,n=Yk(0,X(t));return{legR:-10-n*20,kneeR:20+n*40,legL:4,bob:6-n*8,headTilt:-8,armR:-30+10*X(e*6),armL:30-10*X(e*6),elbowR:40,elbowL:-40,mOpen:6}},exhausted(e){return{headTilt:20,bob:8+3*X(e*1.4),armR:-18,armL:18,elbowR:8,elbowL:-8,legR:-4,legL:4,mOpen:3+2*X(e*1.4)}},proud(e){return{armR:-44,armL:44,elbowR:64,elbowL:-64,headTilt:-4,bob:.6*X(e*1.1),legR:-8,legL:8}},worry(e){let t=X(e*.8);return{headTilt:5*X(e*1.6),bob:1*X(e*1.4),armR:-70+4*X(e*3),armL:-70-4*X(e*3),elbowR:-40,elbowL:40,legR:-3*t,legL:3*t}},hug(e){return{armR:-74,armL:74,elbowR:64,elbowL:-64,headTilt:6,bob:1+.6*X(e*1.3),legR:-4,legL:4}},pushObject(e){let t=.5-.5*Jk(e*3);return{armR:-70,armL:70,elbowR:12,elbowL:-12,headTilt:9,bob:2+2*t,legR:-18-4*t,legL:10}},pull(e){let t=X(e*3.4);return{armR:-46-6*t,armL:46+6*t,elbowR:72,elbowL:-72,headTilt:-7,bob:2+2*t,legR:-16,legL:8}},liftOverhead(e){return{armR:-172,armL:172,elbowR:-8,elbowL:8,headTilt:-6,bob:2+1.4*X(e*1.6),legR:-6,legL:6}},throw(e){let t=e%1*2*Xk,n=Jk(t);return{armR:-70-90*n,elbowR:-30-30*Yk(0,-n),armL:20+14*n,headTilt:-4-4*n,bob:1+1.5*X(e*1.4),legR:-10-6*n,legL:8}},catch(e){let t=Yk(0,X(e*2.4));return{armR:-58+6*t,armL:58-6*t,elbowR:52,elbowL:-52,headTilt:-4,bob:-2+4*t}},examine(e,t={}){return{armR:-110,elbowR:-68,headTilt:10+3*X(e*1.6)+(t.aimDX||0)*4,armL:14,elbowL:-10,bob:.5*X(e*1.3)}},write(e){return{armR:-34+3*X(e*8),elbowR:26,armL:22,elbowL:-12,headTilt:13,bob:.4*X(e*5)}},eat(e){let t=Yk(0,X(e*3));return{armR:-96-26*t,elbowR:-60-10*t,headTilt:-3,armL:10,bob:.5*X(e*1.3),mOpen:3+6*t}},phoneTalk(e){return{armR:-142,elbowR:-98,headTilt:8,armL:8,bob:.5*X(e*1.3),mOpen:3+2*X(e*7),mWidth:10}},phoneScroll(e){return{armL:44,armR:-34+2*X(e*7),elbowL:-34,elbowR:42,headTilt:15,bob:.4*X(e*1.4)}},sweep(e){let t=X(e*2.2);return{armR:-66+22*t,armL:-38+22*t,elbowR:28,elbowL:22,headTilt:9,bob:1+.6*t,legR:-6,legL:6}},hammer(e){let t=e*2%1*2*Xk,n=Yk(0,X(t));return{armR:-56-84*n,elbowR:-38,headTilt:6-4*n,armL:10,bob:1+1.4*n,legR:-6,legL:6}},dig(e){let t=e*1.5%1*2*Xk,n=Yk(0,X(t));return{armR:-44-10*n,armL:30-10*n,elbowR:34,elbowL:-20,headTilt:12+8*n,bob:5+12*n,kneeR:24+16*n,kneeL:24+16*n,legR:-10,legL:6}},drive(e){return{bob:40,legR:-52,legL:-50,kneeR:72,kneeL:70,armR:-46,armL:46,elbowR:38,elbowL:-38,headTilt:2*X(e*1.1)}},read(e){return{armR:-66,armL:66,elbowR:46,elbowL:-46,headTilt:16,bob:.5*X(e*1.2)}},blockShield(e){return{armR:-28,armL:38,elbowR:52,elbowL:-74,headTilt:6,bob:6+.6*X(e*2),kneeR:26,kneeL:26,legR:-8,legL:8}},dodge(e){let t=X(e*3.2);return{headTilt:-16+6*t,bob:5,armR:-40+8*t,armL:40+8*t,elbowR:24,elbowL:-24,legR:-20,legL:12,kneeR:22}}},$k=Object.keys(Qk),eA=[`point`,`look`,`talk`,`talkGesture`,`lookAround`,`aim`,`tablePoint`,`presentPalm`,`beckon`]}));function nA(){return{limbWidenX:1,limbWidenLeg:1,torsoScale:1,cover:{}}}function rA(e={}){let t=nA();return[RA[e.outerwear],FA[e.top],BA[e.bottom],IA[e.sleeves]].filter(Boolean).forEach(e=>{let n=e.fit||{};t.limbWidenX=Math.max(t.limbWidenX,n.limbWidenX||1),t.limbWidenLeg=Math.max(t.limbWidenLeg,n.limbWidenLeg||1),t.torsoScale=Math.max(t.torsoScale,n.torsoScale||1)}),t}function iA(e,t,n=0){let r=104-e,i=134-n,a=226+n;return DA(`M${i} 100 Q${i-4} ${r} 180 ${r-6} Q${a+4} ${r} ${a} 100 L${a-6} ${t+100} Q180 ${t+108} ${i+6} ${t+100} Z`)}function aA(e={}){let t=e.h||34,n=e.b||-34,r=100-t*.5;return iA(t,n,e.wob||0)+DA(`M136 ${r} Q180 ${68-t*.3} 224 ${r} Q200 ${80-t*.3} 180 80 Q160 80 136 ${r} Z`,`hairSh`,` opacity=".3"`)}function oA(e={}){let t=e.up||20,n=52-t,r=46-t;return DA(`M130 104 Q126 ${n} 180 ${r} Q234 ${n} 230 104 Q222 ${80-t*.5} 200 76 Q188 66 174 70 Q152 74 140 86 Q133 94 130 104 Z`)+DA(`M130 104 Q126 ${54-t} 180 ${48-t} Q150 58 140 92 Q134 99 130 104 Z`,`hairSh`,` opacity=".28"`)}function sA(e={}){let t=e.s||1;return DA(`M132 104 Q130 54 180 50 Q230 54 228 104 Q220 82 196 78 Q${180-20*t} 64 ${160-6*t} 74 Q144 82 132 104 Z`)+DA(`M132 104 Q130 56 180 52 Q164 60 150 88 Q138 98 132 104 Z`,`hairSh`,` opacity=".26"`)}function cA(e={}){let t=e.len||210;return DA(`M126 108 Q124 50 180 46 Q236 50 234 108 L228 ${t} Q224 ${t+22} 210 ${t+26} L206 150 Q206 96 180 92 Q154 96 154 150 L150 ${t+26} Q136 ${t+22} 132 ${t} Z`)+DA(`M132 100 Q145 58 180 56 Q215 58 228 100 Q206 74 180 74 Q154 74 132 100 Z`,`hairSh`,` opacity=".3"`)}function lA(e={}){let t=e.r||27,n=e.rows||2,r=``,i=[137,163,195,222],a=[85,61,61,85];return i.forEach((e,n)=>r+=OA(e,a[n],t)),n>1&&[132,154,205,228].forEach((e,n)=>r+=OA(e,[115,126,126,115][n],t-2)),r}function uA(e={}){let t=e.n||10,n=iA(30,-30);for(let e=0;e<t;e++){let r=e/t*Math.PI,i=180+Math.cos(r)*48,a=80-Math.sin(r)*26;n+=OA(i,a,7)}return n}function dA(e={}){let t=e.n||7,n=DA(`M134 102 Q140 78 180 74 Q220 78 226 102 Q206 88 180 86 Q154 88 134 102 Z`);for(let e=0;e<t;e++){let r=138+e*(80/(t-1));n+=DA(`M${r} 86 L${r-5} ${52+e%2*8} L${r+5} 54 Z`)}return n}function fA(){return DA(`M168 108 Q168 46 180 44 Q192 46 192 108 Z`)+DA(`M170 100 Q170 52 180 50 Q178 70 178 100 Z`,`hairSh`,` opacity=".3"`)}function pA(e={}){return iA(28,-30)+OA(180,46,e.r||16)}function mA(e={}){let t=e.side||1,n=e.len||170;return iA(30,-28)+DA(`M${180+t*40} 70 Q${180+t*70} 90 ${180+t*62} ${n} Q${180+t*44} ${n+10} ${180+t*40} ${n} Q${180+t*50} 120 ${180+t*30} 78 Z`)}function hA(e={}){return e.fringe?DA(`M136 100 Q140 84 180 82 Q220 84 224 100 Q206 92 180 92 Q154 92 136 100 Z`):``}function gA(){return DA(`M138 104 Q140 74 165 72 Q150 82 146 104 Z M222 104 Q220 74 195 72 Q210 82 214 104 Z`)}function _A(e={}){let t=e.n||6,n=iA(20,-22);for(let e=0;e<t;e++){let r=142+e*(76/(t-1)),i=180+(r-180)*.3;n+=DA(`M${r-2.5} 100 Q${r-2.5} 62 ${i-2.5} 54 L${i+2.5} 54 Q${r+2.5} 62 ${r+2.5} 100 Z`)}return n}function vA(e,t=`#59352b`){return`<g class="wardrobeHairArt" style="color:${t}">${(kA[e]||kA.crop).fn({})}</g>`}function yA(e,t){if(!RA[e])return``;let n=yk(t,.8),r=yk(t,.72),i=[`jacket`,`blazer`,`cardigan`,`hoodieOpen`,`bomber`,`suitJacket`,`denimJacket`,`vestOuter`,`kimono`,`peacoat`].includes(e),a=`<path d="M124 192 Q108 210 116 258 Q120 310 136 346 Q180 360 224 346 Q240 310 244 258 Q252 210 236 192 Q208 172 180 170 Q152 172 124 192 Z" fill="${t}"/>`,o=i?`<path d="M180 172 L164 348 M180 172 L196 348" stroke="${r}" stroke-width="4" fill="none"/><path d="M180 172 L150 196 L164 348 M180 172 L210 196 L196 348" fill="${n}" opacity=".5"/>`:`<path d="M180 172 L180 348" stroke="${r}" stroke-width="2.5" fill="none"/>`,s=e===`hiVisVest`?`<rect x="150" y="238" width="60" height="14" fill="#fff" opacity=".75"/><rect x="150" y="262" width="60" height="14" fill="#fff" opacity=".75"/>`:e===`labCoat`?`<rect x="152" y="256" width="16" height="20" fill="#eef2f5"/>`:e===`apron`?`<path d="M158 200 L158 344 L202 344 L202 200 Q180 190 158 200 Z" fill="${n}"/>`:e===`cape`?`<path d="M126 190 Q112 300 130 360 L230 360 Q248 300 234 190 Q208 200 180 200 Q152 200 126 190 Z" fill="${n}" opacity=".9"/>`:``;return`<g data-role="wardrobeOuter">${e===`cape`?s:``}${a}${o}${e===`cape`?``:s}</g>`}function bA(e,t){let n=t,r=yk(n,.82),i=e===`skirtLong`||e===`dressBottom`||e===`palazzo`,a=i?470:400,o=i?26:14;return`<g data-role="wardrobeBottom"><path d="M150 330 Q180 322 210 330 L${210+o} ${a} Q180 ${a+14} ${150-o} ${a} Z" fill="${n}"/><path d="M150 330 Q180 322 210 330" fill="none" stroke="${r}" stroke-width="3"/></g>`}function xA(e,t=`#2a2f3a`){if(e===`barefoot`||!HA[e])return``;let n=n=>{let r=e===`heels`?`<rect x="${n+12}" y="568" width="5" height="18" fill="${t}"/>`:``;return`${e===`boots`||e===`winterBoots`?`<rect x="${n-16}" y="530" width="32" height="34" rx="6" fill="${t}"/>`:``}<path d="M${n-20} 566Q${n-22} 556 ${n-12} 554L${n+18} 554Q${n+26} 556 ${n+26} 566Q${n+26} 574 ${n+14} 574L${n-18} 574Q${n-22} 572 ${n-20} 566Z" fill="${t}"/>${r}`};return`<g data-role="wardrobeFeet">${n(160)}${n(200)}</g>`}function SA(e,t=`#2a2018`){if(e===`none`||!qA(e))return``;let n={stubble:`M145 131Q152 152 180 160Q208 152 215 131Q208 145 180 149Q152 145 145 131Z`,shortBeard:`M145 130Q150 160 180 170Q210 160 215 130Q208 152 180 156Q152 152 145 130Z`,fullBeard:`M143 126Q146 172 180 186Q214 172 217 126Q210 156 180 160Q150 156 143 126Z`,goatee:`M170 140Q180 168 190 140Q184 156 180 156Q176 156 170 140Z`,vanDyke:`M170 138Q180 164 190 138Q184 152 180 152ZM168 120Q180 126 192 120Q180 130 168 120Z`,mustache:`M164 122Q180 130 196 122Q188 118 180 120Q172 118 164 122Z`,handlebar:`M158 122Q180 132 202 122Q194 116 180 120Q166 116 158 122Q160 128 156 130Q162 126 158 122ZM202 122Q204 128 208 130Q202 126 202 122Z`,mutton:`M145 118Q142 150 158 164Q160 140 156 118ZM215 118Q218 150 202 164Q200 140 204 118Z`,soulPatch:`M176 138Q180 148 184 138Q180 144 176 138Z`,circleBeard:`M164 122Q180 130 196 122Q188 118 180 120Q172 118 164 122ZM170 138Q180 166 190 138Q184 154 180 154Q176 154 170 138Z`,chinStrap:`M146 118Q148 158 180 168Q212 158 214 118Q210 150 180 154Q150 150 146 118ZM160 130L200 130Q198 140 180 142Q162 140 160 130Z`,verstache:`M164 122Q180 130 196 122Q188 118 180 120Q172 118 164 122ZM176 138Q180 148 184 138Z`,longBeard:`M143 126Q146 190 180 210Q214 190 217 126Q210 156 180 160Q150 156 143 126Z`};return`<path data-role="wardrobeFacial" d="${n[e]||n.shortBeard}" fill="${t}"/>`}function CA(e){if(e===`none`||e===!1||!YA(e))return``;let t=`#26313a`,n=e===`square`?e=>`<rect x="${e-13}" y="99" width="26" height="22" rx="4" fill="none" stroke="${t}" stroke-width="3"/>`:e===`catEye`?e=>`<path d="M${e-13} 116 Q${e-14} 100 ${e} 100 Q${e+14} 100 ${e+13} 116 Q${e} 122 ${e-13} 116 Z" fill="none" stroke="${t}" stroke-width="3"/>`:e===`sunglasses`?e=>`<circle cx="${e}" cy="110" r="13" fill="#26313a"/>`:n=>`<circle cx="${n}" cy="110" r="13" fill="${e===`rimless`?`rgba(180,200,220,.25)`:`none`}" stroke="${e===`rimless`?`none`:t}" stroke-width="3"/>`;return`<g data-role="wardrobeGlasses">${n(164)}${n(196)}<rect x="177" y="108" width="6" height="3" rx="1.5" fill="${t}"/></g>`}function wA(e,t=`#37455a`){if(e===`none`||!ZA(e))return``;let n=yk(t,.8);return`<g data-role="wardrobeHat">${{cap:`<path d="M134 66 Q180 30 226 62 Q228 74 180 74 Q140 74 134 66 Z" fill="${t}"/><path d="M226 62 Q252 62 256 74 L226 76 Q224 68 226 62 Z" fill="${n}"/>`,beanie:`<path d="M132 72 Q132 34 180 32 Q228 34 228 72 Q180 82 132 72 Z" fill="${t}"/><rect x="130" y="66" width="100" height="12" rx="6" fill="${n}"/>`,fedora:`<ellipse cx="180" cy="72" rx="66" ry="12" fill="${n}"/><path d="M146 70 Q150 38 180 36 Q210 38 214 70 Z" fill="${t}"/><rect x="146" y="60" width="68" height="8" fill="${n}"/>`,topHat:`<ellipse cx="180" cy="66" rx="58" ry="10" fill="${n}"/><rect x="150" y="8" width="60" height="60" rx="4" fill="${t}"/><rect x="150" y="52" width="60" height="8" fill="${n}"/>`,hardHat:`<path d="M138 66 Q180 30 222 66 Q180 76 138 66 Z" fill="${t}"/><rect x="132" y="64" width="96" height="8" rx="4" fill="${t}"/><rect x="176" y="34" width="8" height="30" fill="${n}"/>`,crown:`<path d="M142 66 L146 40 L160 56 L180 34 L200 56 L214 40 L218 66 Z" fill="#f2b134"/><circle cx="180" cy="40" r="4" fill="#fff"/>`,helmet:`<path d="M130 76 Q130 32 180 30 Q230 32 230 76 Q180 86 130 76 Z" fill="${t}"/><rect x="176" y="30" width="8" height="46" fill="${n}"/>`,headband:`<rect x="132" y="60" width="96" height="12" rx="6" fill="${t}"/>`,cowboyHat:`<path d="M118 72 Q180 60 242 72 Q180 88 118 72 Z" fill="${t}"/><path d="M150 68 Q154 38 180 36 Q206 38 210 68 Z" fill="${t}"/><rect x="150" y="60" width="60" height="7" fill="${n}"/>`,wizardHat:`<path d="M180 4 L214 70 L146 70 Z" fill="${t}"/><ellipse cx="180" cy="70" rx="44" ry="8" fill="${n}"/><circle cx="180" cy="26" r="4" fill="#ffd54a"/>`,beret:`<ellipse cx="180" cy="52" rx="42" ry="22" fill="${t}"/><circle cx="200" cy="40" r="4" fill="${n}"/>`,visor:`<rect x="134" y="62" width="92" height="10" rx="5" fill="${t}"/><path d="M226 66 Q250 66 254 76 L226 78 Z" fill="${n}"/>`,bandana:`<path d="M132 66 Q180 52 228 66 Q228 74 180 78 Q140 74 132 66 Z" fill="${t}"/><path d="M226 68 L246 84 L232 86 L222 72 Z" fill="${n}"/>`,partyHat:`<path d="M180 8 L200 66 L160 66 Z" fill="${t}"/><circle cx="180" cy="12" r="5" fill="#ff6b5e"/>`,santaHat:`<path d="M134 68 Q140 30 202 34 Q214 40 210 66 Z" fill="#c0392b"/><rect x="126" y="64" width="92" height="12" rx="6" fill="#fff"/><circle cx="210" cy="38" r="8" fill="#fff"/>`}[e]||``}</g>`}function TA(e={}){let t=``;return e.freckles&&(t+=`<g fill="#b5794f" opacity=".5">${[[152,116],[158,120],[148,122],[202,116],[208,120],[212,122]].map(([e,t])=>`<circle cx="${e}" cy="${t}" r="1.6"/>`).join(``)}</g>`),e.blush&&(t+=`<ellipse cx="150" cy="120" rx="10" ry="6" fill="#ff8a8a" opacity=".3"/><ellipse cx="210" cy="120" rx="10" ry="6" fill="#ff8a8a" opacity=".3"/>`),e.earrings&&(t+=`<circle cx="134" cy="122" r="3" fill="#f2b134"/><circle cx="226" cy="122" r="3" fill="#f2b134"/>`),e.wrinkles&&(t+=`<g stroke="#c9a882" stroke-width="1.2" fill="none" opacity=".5"><path d="M150 90 Q164 88 176 90"/><path d="M186 90 Q198 88 210 90"/><path d="M156 128 Q164 132 172 128"/><path d="M188 128 Q196 132 204 128"/></g>`),t?`<g data-role="wardrobeFaceExtras">${t}</g>`:``}var EA,DA,OA,kA,AA,jA,MA,NA,PA,FA,IA,LA,RA,zA,BA,VA,HA,UA,WA,GA,KA,qA,JA,YA,XA,ZA,QA,$A,ej,tj,nj,rj,ij,aj=o((()=>{Tk(),EA={armU:20,armL:17,legU:26,legL:22},DA=(e,t=`hair`,n=``)=>`<path class="${t}" d="${e}"${n}/>`,OA=(e,t,n,r=`hair`)=>`<circle class="${r}" cx="${e}" cy="${t}" r="${n}"/>`,kA={},AA=(e,t,n)=>t.forEach((t,r)=>{kA[t]={cat:e,fn:n(r)}}),AA(`short`,[`crop`,`buzz`,`caesar`,`ivyLeague`,`crewCut`,`taper`,`flatTop`,`hightop`,`shortAfro`,`pixie`,`frenchCrop`,`butch`,`burr`,`induction`,`shortBrush`,`lowFade`,`midFade`,`highFade`,`blowout`,`edgar`],e=>e===8?e=>lA({r:20,rows:1}):e===6||e===7?e=>oA({up:8}):t=>aA({h:28+e%5*2,wob:e%3-1})),AA(`medium`,[`quiff`,`pompadour`,`sidePart`,`comboOver`,`sweptBack`,`curtains`,`waves`,`shag`,`bob`,`lob`,`fauxHawkMed`,`texturedCrop`,`messyMed`,`flowMed`,`middlePart`,`slickBack`,`wolfCut`,`mullet`,`featheredMed`,`layeredMed`],e=>e<=1?t=>oA({up:18+e*6}):e===8||e===9?e=>cA({len:160}):e<=4?t=>sA({s:e%2?1:-1}):e=>aA({h:38,b:6,wob:2})),AA(`long`,[`straightLong`,`ponytail`,`highPonytail`,`braid`,`doubleBraid`,`bun`,`topKnot`,`spaceBuns`,`longAfro`,`dreads`,`longLayers`,`sidePonytail`,`lowBun`,`halfUp`,`mermaid`,`hime`,`longWavy`,`longStraight`,`longCurly`,`longShag`],e=>e===1||e===2||e===11?t=>mA({len:175,side:e===11?1:.1}):e===5||e===6||e===12?e=>pA({}):e===8?e=>lA({r:27,rows:2}):t=>cA({len:200+e%3*10})),AA(`textured`,[`curly`,`tightCurls`,`afro`,`afroTaper`,`coils`,`ringlets`,`wavyLong`,`kinky`,`twistOut`,`curlyFade`,`curlyBob`,`curlyShag`,`looseCurls`,`spiralCurls`,`bantuKnots`],e=>e===2||e===3?e=>lA({r:27,rows:2}):e===4||e===8?e=>uA({n:10}):e=>lA({r:22,rows:1})),AA(`styled`,[`mohawk`,`fauxHawk`,`undercut`,`manBun`,`cornrows`,`locs`,`spiky`,`emoFringe`,`bunched`,`hatHairShort`,`liberty`,`devilock`,`quiffPunk`,`razorPart`,`flattopHi`],e=>e===0||e===10||e===11||e===12?e=>fA():e===3?e=>pA({r:14}):e===4?e=>_A({n:6}):e===6||e===13||e===14?e=>dA({n:7}):e=>aA({h:30})),AA(`aged`,[`greySwept`,`greyBun`,`balding`,`saltPepper`,`wispy`,`recedingGrey`,`baldFringe`,`thinTop`,`combover`,`silverLong`],e=>e===1?e=>pA({}):e===2||e===7?e=>gA():e===6?e=>hA({fringe:!0}):e===9?e=>cA({len:180}):e=>sA({s:1})),kA.bald={cat:`aged`,fn:e=>hA({})},kA.widowsPeak={cat:`styled`,fn:e=>DA(`M136 104Q138 70 165 68L180 84L195 68Q222 70 224 104Q206 84 180 82Q154 84 136 104Z`)},kA.receding={cat:`aged`,fn:e=>gA()},jA=Object.keys(kA),MA=e=>Object.prototype.hasOwnProperty.call(kA,e),NA={tee:``,tank:e=>`<path d="M156 196L156 250M204 196L204 250" stroke="${yk(e,.8)}" stroke-width="3" fill="none" opacity=".5"/>`,poloShirt:e=>`<path d="M168 176L180 190L192 176" fill="none" stroke="${yk(e,.78)}" stroke-width="4"/><circle cx="180" cy="210" r="2.4" fill="${yk(e,.7)}"/><circle cx="180" cy="226" r="2.4" fill="${yk(e,.7)}"/>`,buttonUp:e=>`<path d="M180 176L180 340" stroke="${yk(e,.72)}" stroke-width="2.5"/>${[196,220,252,284,316].map(t=>`<circle cx="180" cy="${t}" r="2.2" fill="${yk(e,.6)}"/>`).join(``)}`,hoodie:e=>`<path d="M150 182Q180 168 210 182Q206 200 180 206Q154 200 150 182Z" fill="${yk(e,.82)}"/><path d="M172 206L172 250M188 206L188 250" stroke="${yk(e,.7)}" stroke-width="3"/><rect x="150" y="300" width="60" height="26" rx="8" fill="${yk(e,.86)}"/>`,jersey:e=>`<text x="180" y="270" text-anchor="middle" font-size="34" font-weight="900" fill="${yk(e,.6)}">${`0`+(1+e.length%9)}</text>`,turtleneck:e=>`<rect x="164" y="158" width="32" height="22" rx="8" fill="${e}"/>`,vest:e=>`<path d="M150 196L150 330M210 196L210 330" stroke="${yk(e,.7)}" stroke-width="4" fill="none"/>`,henley:e=>`<path d="M180 178L180 220" stroke="${yk(e,.72)}" stroke-width="2.5"/><circle cx="180" cy="196" r="2" fill="${yk(e,.6)}"/><circle cx="180" cy="212" r="2" fill="${yk(e,.6)}"/>`},PA=[`tee`,`tank`,`poloShirt`,`buttonUp`,`blouse`,`sweater`,`turtleneck`,`hoodie`,`jersey`,`croptop`,`vest`,`dressTop`,`tunic`,`henley`,`flannel`,`stripedTee`,`graphicTee`,`longSleeveTee`,`raglan`,`workShirt`,`scrubTop`,`thermal`,`poncho`,`halterTop`,`wrapTop`],FA={},PA.forEach(e=>{let t=[`sweater`,`turtleneck`,`hoodie`,`longSleeveTee`,`workShirt`,`thermal`,`flannel`,`blouse`,`scrubTop`].includes(e);FA[e]={id:e,slot:`top`,kind:`paint`,covers:[`arm`],longSleeve:t,capRx:10,detail:NA[e]||``,fit:{limbWidenX:t?1.12:1}}}),IA={short:{id:`short`,slot:`sleeves`,kind:`paint`,covers:[`arm`],longSleeve:!1,capRx:10},long:{id:`long`,slot:`sleeves`,kind:`paint`,covers:[`arm`],longSleeve:!0,capRx:8.5,fit:{limbWidenX:1.1}},rolled:{id:`rolled`,slot:`sleeves`,kind:`paint`,covers:[`arm`],longSleeve:!1,capRx:10},threeQuarter:{id:`threeQuarter`,slot:`sleeves`,kind:`paint`,covers:[`arm`],longSleeve:!0,capRx:8.5,fit:{limbWidenX:1.06}},sleeveless:{id:`sleeveless`,slot:`sleeves`,kind:`paint`,covers:[],capRx:10}},LA=[`jacket`,`blazer`,`coat`,`trenchcoat`,`hoodieOpen`,`cardigan`,`puffer`,`bomber`,`apron`,`labCoat`,`hiVisVest`,`robe`,`cape`,`suitJacket`,`denimJacket`,`raincoat`,`parka`,`peacoat`,`windbreaker`,`fleece`,`vestOuter`,`poncho2`,`kimono`,`overalls`,`wetsuitTop`],RA={},LA.forEach(e=>{let t=[`coat`,`trenchcoat`,`puffer`,`parka`,`peacoat`,`robe`,`labCoat`,`raincoat`,`fleece`].includes(e),n=e===`puffer`||e===`parka`?1.5:t?1.34:1.18;RA[e]={id:e,slot:`outerwear`,kind:`overlay`,covers:[`arm`],longSleeve:!0,capRx:12,fit:{limbWidenX:n,torsoScale:t?1.08:1.03,cover:{armU:EA.armU*n+2,armL:EA.armL*n+2}}}}),zA=[`shorts`,`jeans`,`trousers`,`slacks`,`joggers`,`cargos`,`skirtShort`,`skirtLong`,`leggings`,`dressBottom`,`kilt`,`shortsAthletic`,`snowPants`,`chinos`,`sweatpants`,`capris`,`overallsBottom`,`palazzo`,`culottes`,`bikeShorts`],BA={},zA.forEach(e=>{let t=![`shorts`,`skirtShort`,`shortsAthletic`,`bikeShorts`,`capris`].includes(e),n=e===`snowPants`;BA[e]={id:e,slot:`bottom`,kind:`paint`,covers:[`leg`],longLeg:t,capRx:11,skirt:e.startsWith(`skirt`)||e===`kilt`||e===`dressBottom`||e===`palazzo`,fit:{limbWidenLeg:n?1.4:t?1.06:1}}}),VA=[`sneakers`,`dressShoes`,`boots`,`heels`,`sandals`,`cleats`,`winterBoots`,`barefoot`,`loafers`,`hightops`],HA={},VA.forEach(e=>HA[e]={id:e,slot:`footwear`,kind:`overlay`}),UA=[`oval`,`round`,`square`,`heart`,`long`,`diamond`,`wide`,`narrow`,`soft`,`angular`,`chubby`,`gaunt`],WA={oval:[1,1],round:[1.06,.96],square:[1.04,1],heart:[1.03,1],long:[.94,1.08],diamond:[.98,1.04],wide:[1.12,.96],narrow:[.9,1.02],soft:[1.05,1],angular:[.98,1.02],chubby:[1.1,.98],gaunt:[.9,1.05]},GA=e=>UA.includes(e),KA=[`none`,`stubble`,`shortBeard`,`fullBeard`,`goatee`,`vanDyke`,`mustache`,`handlebar`,`mutton`,`soulPatch`,`circleBeard`,`chinStrap`,`verstache`,`longBeard`],qA=e=>KA.includes(e),JA=[`none`,`round`,`square`,`rimless`,`sunglasses`,`catEye`,`aviator`],YA=e=>JA.includes(e),XA=[`none`,`cap`,`beanie`,`fedora`,`topHat`,`hardHat`,`crown`,`helmet`,`headband`,`cowboyHat`,`wizardHat`,`beret`,`visor`,`bandana`,`partyHat`,`santaHat`],ZA=e=>XA.includes(e),QA=[`round`,`almond`,`narrow`,`wide`],$A={round:[6.5,9],almond:[7,6],narrow:[7,4.5],wide:[8,9.5]},ej=[`flat`,`arched`,`angled`],tj={flat:0,arched:-4,angled:3},nj={casual:{top:`tee`,sleeves:`short`,bottom:`jeans`,footwear:`sneakers`,outerwear:`none`},business:{top:`buttonUp`,sleeves:`long`,outerwear:`blazer`,bottom:`slacks`,footwear:`dressShoes`},uniformMilitary:{top:`workShirt`,sleeves:`long`,outerwear:`jacket`,bottom:`cargos`,footwear:`boots`},uniformPolice:{top:`buttonUp`,sleeves:`long`,outerwear:`vestOuter`,bottom:`trousers`,footwear:`boots`},doctor:{top:`scrubTop`,sleeves:`short`,outerwear:`labCoat`,bottom:`trousers`,footwear:`sneakers`},worker:{top:`workShirt`,sleeves:`long`,outerwear:`hiVisVest`,bottom:`cargos`,footwear:`boots`},chef:{top:`buttonUp`,sleeves:`long`,outerwear:`apron`,bottom:`trousers`,footwear:`sneakers`},athlete:{top:`jersey`,sleeves:`sleeveless`,bottom:`shortsAthletic`,footwear:`cleats`,outerwear:`none`},royal:{top:`dressTop`,sleeves:`long`,outerwear:`cape`,bottom:`dressBottom`,footwear:`dressShoes`},winter:{top:`sweater`,sleeves:`long`,outerwear:`puffer`,bottom:`snowPants`,footwear:`winterBoots`},ancient:{top:`tunic`,sleeves:`long`,outerwear:`robe`,bottom:`trousers`,footwear:`sandals`},spacesuit:{top:`thermal`,sleeves:`long`,outerwear:`parka`,bottom:`snowPants`,footwear:`boots`}},rj=Object.keys(nj),ij={hair:jA,top:Object.keys(FA),sleeves:Object.keys(IA),outerwear:[`none`,...LA],bottom:Object.keys(BA),footwear:VA,faceShape:UA,facialHair:KA,glasses:JA}}));function oj(e,t){return typeof e==`string`&&e[0]===`@`?(vj[t]||vj.auto)[e.slice(1)]||vj.auto[e.slice(1)]||`#888888`:e}function sj(e,t){let n={...e};return[`skin`,`hairColor`,`shirt`,`shorts`,`legs`].forEach(e=>{n[e]!=null&&(n[e]=oj(n[e],t))}),n}function cj(e={}){return{...yj,...e}}function lj(e,t,n){e.querySelectorAll(`.`+t).forEach(e=>e.setAttribute(`fill`,n))}function uj(e,t){let n=cj(t),r=n.shorts||n.shirt,i=n.legs||n.shirt;e.querySelectorAll(`.hairStyle`).forEach(e=>e.setAttribute(`opacity`,e.dataset.style===n.hairStyle?`1`:`0`)),lj(e,`hair`,n.hairColor),lj(e,`hairSh`,yk(n.hairColor,.78)),lj(e,`shirt`,n.shirt),lj(e,`shirtSh`,yk(n.shirt,.78)),lj(e,`shorts`,r),lj(e,`shortsSh`,yk(r,.78)),lj(e,`leg`,i),lj(e,`legSh`,yk(i,.78)),lj(e,`skin`,n.skin),lj(e,`skinSh`,yk(n.skin,.88));let a=e.querySelector(`[data-role="glasses"]`);a&&a.setAttribute(`opacity`,n.glasses?`1`:`0`);let o=e.querySelector(`[data-role="beard"]`);o&&(o.setAttribute(`opacity`,n.beard?`1`:`0`),n.beard&&o.setAttribute(`fill`,yk(n.hairColor,.85)));let s=e.querySelector(`[data-role="collar"]`);if(s&&s.setAttribute(`opacity`,n.collar||n.build===`dave`?`1`:`0`),e.querySelector(`[data-role="hairProfShort"]`)){let t=[`bob`,`long`,`ponytail`,`curly`,`afro`].includes(n.hairStyle),r=e.querySelector(`[data-role="hairProfLong"]`);r&&r.setAttribute(`opacity`,t?`1`:`0`);let i=e.querySelector(`[data-role="hairPony"]`);i&&i.setAttribute(`opacity`,n.hairStyle===`ponytail`?`1`:`0`)}n.appearance&&mj(e,n)}function dj(e,t,n){let r=e.querySelector(`[data-role="${t}"]`);return r||(r=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),r.setAttribute(`data-role`,t),(e.querySelector(n)||e).appendChild(r)),r}function fj(e,t,n=`char`,r=`head`){let i=e.querySelector(`[data-role="${t}"]`);if(!i){i=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),i.setAttribute(`data-role`,t);let a=e.querySelector(`[data-role="${n}"]`),o=e.querySelector(`[data-role="${r}"]`);a&&o?a.insertBefore(i,o):a&&a.appendChild(i)}return i}function pj(e,t,n){[`armL`,`armR`].forEach(n=>{let r=e.querySelector(`[data-role="${n}"] > rect`);r&&r.setAttribute(`fill`,t)}),n&&[`armLf`,`armRf`].forEach(n=>{let r=e.querySelector(`[data-role="${n}"] > rect`);r&&r.setAttribute(`fill`,t)})}function mj(e,t){let n=t.appearance,r=t.hairColor;if(n.hair&&MA(n.hair)&&(e.querySelectorAll(`.hairStyle`).forEach(e=>e.setAttribute(`opacity`,`0`)),e.querySelector(`[data-role="hairRoot"]`))){let t=dj(e,`wardrobeHair`,`[data-role="hairRoot"]`);t.innerHTML=vA(n.hair,r),lj(t,`hair`,r),lj(t,`hairSh`,yk(r,.78))}if(n.faceShape&&GA(n.faceShape)){let[t,r]=WA[n.faceShape],i=e.querySelector(`[data-role="face"]`);i&&i.setAttribute(`transform`,`translate(180 104) scale(${t} ${r}) translate(-180 -104)`)}if(n.top&&FA[n.top]){let r=n.topColor||t.shirt;lj(e,`shirt`,r),lj(e,`shirtSh`,yk(r,.78));let i=FA[n.top].detail,a=dj(e,`wardrobeTop`,`[data-role="torsoWrap"]`);a.innerHTML=typeof i==`function`?i(r):i||``}if(n.sleeves&&IA[n.sleeves]&&IA[n.sleeves].longSleeve&&pj(e,n.topColor||t.shirt,!0),n.outerwear&&n.outerwear!==`none`&&RA[n.outerwear]){let r=n.outerColor||yk(t.shirt,.7);pj(e,r,!0);let i=fj(e,`wardrobeOuterRoot`);i.innerHTML=yA(n.outerwear,r)}else{let t=e.querySelector(`[data-role="wardrobeOuterRoot"]`);t&&(t.innerHTML=``)}if(n.bottom&&BA[n.bottom]){let r=n.bottomColor||t.shorts||t.shirt;lj(e,`shorts`,r),lj(e,`shortsSh`,yk(r,.78)),BA[n.bottom].longLeg&&(lj(e,`leg`,r),lj(e,`legSh`,yk(r,.78)));let i=fj(e,`wardrobeBottomRoot`);i.innerHTML=BA[n.bottom].skirt?bA(n.bottom,r):``}{let t=dj(e,`wardrobeFeetRoot`,`[data-role="char"]`);t.innerHTML=n.footwear?xA(n.footwear,n.footColor||`#2a2f3a`):``}if(n.facialHair&&qA(n.facialHair)){let t=e.querySelector(`[data-role="beard"]`);t&&t.setAttribute(`opacity`,(n.facialHair,`0`));let i=fj(e,`wardrobeFacialRoot`,`faceFeatures`,`mouth`);i.innerHTML=SA(n.facialHair,yk(r,.85))}if(n.glasses&&YA(n.glasses)){let t=e.querySelector(`[data-role="glasses"]`);t&&t.setAttribute(`opacity`,`0`);let r=dj(e,`wardrobeGlassesRoot`,`[data-role="faceFeatures"]`);r.innerHTML=CA(n.glasses)}{let t=dj(e,`wardrobeHatRoot`,`[data-role="head"]`);t.innerHTML=n.headwear&&ZA(n.headwear)?wA(n.headwear,n.headwearColor||`#37455a`):``}{let t=fj(e,`wardrobeExtrasRoot`,`faceFeatures`,`mouth`);t.innerHTML=TA(n)}if(n.eyeShape||n.irisColor||n.eyeSpacing!=null||n.lashes){let[t,r]=$A[n.eyeShape]||$A.round,i=(n.eyeSpacing||0)*6;[[`eyeL`,164-i],[`eyeR`,196+i]].forEach(([i,a])=>{let o=e.querySelector(`[data-role="${i}"]`);o&&(o.setAttribute(`rx`,t),o.setAttribute(`ry`,r),o.setAttribute(`cx`,a),n.irisColor&&o.setAttribute(`fill`,n.irisColor))});let a=dj(e,`wardrobeLashRoot`,`[data-role="faceFeatures"]`);a.innerHTML=n.lashes?`<path d="M${158-i} ${104-r} Q${164-i} ${101-r} ${170-i} ${104-r}" stroke="#243038" stroke-width="1.4" fill="none"/><path d="M${190+i} ${104-r} Q${196+i} ${101-r} ${202+i} ${104-r}" stroke="#243038" stroke-width="1.4" fill="none"/>`:``}if(n.browShape||n.browThickness||n.browColor){let t=tj[n.browShape]||0;[[`browL`,153,174],[`browR`,186,207]].forEach(([r,i,a])=>{let o=e.querySelector(`[data-role="${r}"]`);o&&(n.browThickness&&o.setAttribute(`stroke-width`,n.browThickness),n.browColor&&o.setAttribute(`stroke`,n.browColor),o.setAttribute(`d`,`M${i} 94 Q${(i+a)/2} ${89+t} ${a} 94`))})}}function hj(e,t,n={}){let r=cj(e),i=_j[r.ageHint]||_j.adult,a=gj.includes(r.ageHint)?Fk[r.ageHint]:null,o=a||Fk[r.build]||Fk.default,s=rA(r.appearance||{}),c={...o,armX:o.armX*s.limbWidenX,legX:o.legX*s.limbWidenLeg,torsoX:o.torsoX*s.torsoScale},l=a?1:i.headScale,u=a?o.scale||1:i.heightScale;return{profile:Pk[r.body]||Pk.regular,build:c,hairVol:r.hairVol,eyeMul:r.eye,browTilt:n.browTilt||0,headScale:l,heightScale:(r.heightScale||1)*u*(n.depthScale||1),limbScale:n.limbScale||1,rigX:t,facing:n.facing||`front`,squash:n.squash==null?1:n.squash,yShift:n.yShift||0,opacity:n.opacity==null?1:n.opacity}}var gj,_j,vj,yj,bj=o((()=>{Tk(),Uk(),aj(),gj=[`childYoung`,`child`,`teen`],_j={child:{heightScale:.72,headScale:1.14},adult:{heightScale:1,headScale:1},elder:{heightScale:.95,headScale:1.02}},Object.keys(_j),vj={auto:{primary:`#2BB3A3`,accent:`#FF6B5E`,warm:`#F2B134`,cool:`#5B6CE0`,ink:`#2E3440`,pale:`#F2C9A0`},sunset:{primary:`#E07A5F`,accent:`#F2CC8F`,warm:`#F4A261`,cool:`#81B29A`,ink:`#3D405B`,pale:`#F4EBDD`},ocean:{primary:`#2b6cb0`,accent:`#38b2ac`,warm:`#ecc94b`,cool:`#4299e1`,ink:`#1a365d`,pale:`#bee3f8`}},yj={skin:`#F2C9A0`,hairStyle:`bob`,hairColor:`#59352B`,hairVol:1,shirt:`#2BB3A3`,shorts:null,legs:null,body:`regular`,build:`default`,eye:1,glasses:!1,beard:!1,collar:!1,heightScale:1}}));function xj(e,t,n=wj){let r=Tj[e]||Tj.central;return{x:r.x*t,y:r.y*n,tint:r.tint}}function Sj(e=7){return[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#123a52`),r.addColorStop(1,`#0c2536`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3)}},{d:0,draw:(e,t,n)=>{e.strokeStyle=`rgba(255,255,255,.05)`,e.lineWidth=1;for(let r=0;r<=t;r+=t/12)e.beginPath(),e.moveTo(r,0),e.lineTo(r,n),e.stroke();for(let r=0;r<=n;r+=n/8)e.beginPath(),e.moveTo(0,r),e.lineTo(t,r),e.stroke()}},{d:0,draw:(t,n,r)=>{let i=vk(`map`+e);Ej.forEach(e=>{let a=Tj[e],o=a.x*n,s=a.y*r,c=a.r*n;t.save(),t.fillStyle=a.tint,t.globalAlpha=.94,t.beginPath();for(let e=0;e<=Math.PI*2+.01;e+=Math.PI/7){let n=c*(.8+i()*.4),r=o+Math.cos(e)*n,a=s+Math.sin(e)*n*.82;e===0?t.moveTo(r,a):t.lineTo(r,a)}t.closePath(),t.fill(),t.strokeStyle=`rgba(0,0,0,.12)`,t.lineWidth=2,t.stroke(),t.restore()})}}]}function Cj(e=7){return[{d:.1,draw:(e,t,n)=>{e.fillStyle=`#1b2230`,e.fillRect(-500,-500,t+1e3,n+1e3)}},{d:.18,draw:(e,t,n)=>{let r=e.createRadialGradient(t/2,n*.28,20,t/2,n*.28,n*.85);r.addColorStop(0,`rgba(150,180,220,.20)`),r.addColorStop(1,`rgba(150,180,220,0)`),e.fillStyle=r,e.fillRect(0,0,t,n)}},{d:.4,draw:(t,n,r,i,a)=>{t.save(),t.fillStyle=`#2a3446`,t.beginPath(),t.moveTo(n*.26,i-30*a),t.lineTo(n*.74,i-30*a),t.lineTo(n*.92,i+130*a),t.lineTo(n*.08,i+130*a),t.closePath(),t.fill(),t.fillStyle=`#39496a`,t.beginPath(),t.moveTo(n*.3,i-22*a),t.lineTo(n*.7,i-22*a),t.lineTo(n*.84,i+96*a),t.lineTo(n*.16,i+96*a),t.closePath(),t.fill();let o=vk(`wr`+e);t.fillStyle=`#c9a36a`;for(let e=0;e<5;e++)t.beginPath(),t.arc(n*(.36+o()*.28),i+(6+o()*56)*a,6*a,0,7),t.fill();t.strokeStyle=`rgba(230,200,140,.5)`,t.lineWidth=2*a,t.beginPath(),t.moveTo(n*.4,i+20*a),t.lineTo(n*.6,i+60*a),t.stroke(),t.restore()}}]}var wj,Tj,Ej,Dj=o((()=>{Tk(),wj=640,Tj={north:{x:.3,y:.3,r:.14,tint:`#8fae7a`},south:{x:.42,y:.68,r:.12,tint:`#c9a36a`},east:{x:.68,y:.4,r:.15,tint:`#7a9bb5`},west:{x:.15,y:.52,r:.11,tint:`#b58a7a`},central:{x:.5,y:.47,r:.11,tint:`#a7b98c`},isles:{x:.82,y:.66,r:.07,tint:`#8aa6b5`}},Ej=Object.keys(Tj)}));function Oj(e){let t=e===`grid`?4:e===`hero`||e===`islands`?3:e===`pin`||e===`steps`||e===`orbit`?5:3,n=[{key:`bg`,default:!0},{key:`accent`,default:!0}];for(let e=0;e<t;e++)n.push({key:`panel`+e,default:!0});n.push({key:`fgBlob`,default:!0}),e===`pin`&&n.push({key:`strings`,default:!0},{key:`boardTexture`,default:!0}),e===`steps`&&n.push({key:`path`,default:!0}),e===`orbit`&&n.push({key:`orbitLines`,default:!0}),n.push({key:`focusRing`,default:!1},{key:`hud`,default:!1});let r=e===`steps`?[4200,1600]:e===`grid`?[2600,1900]:e===`orbit`?[2600,2e3]:e===`islands`?[3200,1900]:e===`hero`?[3e3,1700]:[800+t*760,1500];return{world:r,view:[1920,1080],kind:e,manifest:n,build(n,i){let[a,o]=r,s=vk(`board`+e+n),c=kj(e,t,a,o,s),l=[],u=[],d=[],f=`pmbg_`+e,p=`<defs><linearGradient id="${f}" x1="0" x2="1" y1="0" y2="1"><stop offset="0" stop-color="${Hj[e][0]}"/><stop offset="1" stop-color="${Hj[e][1]}"/></linearGradient></defs>`;i(`bg`)?l.push(p+`<rect x="${-a}" y="${-o}" width="${3*a}" height="${3*o}" fill="url(#${f})"/>`):l.push(p),i(`accent`)&&l.push(`<circle cx="${(a*.2).toFixed(0)}" cy="${(o*.26).toFixed(0)}" r="${(o*.22).toFixed(0)}" fill="${Hj[e][2]}" opacity=".5"/><circle cx="${(a*.82).toFixed(0)}" cy="${(o*.3).toFixed(0)}" r="${(o*.28).toFixed(0)}" fill="${Hj[e][3]}" opacity=".45"/>`),e===`pin`&&i(`boardTexture`)&&l.push(Nj(a,o)),e===`steps`&&i(`path`)&&u.push(Aj(c)),e===`orbit`&&i(`orbitLines`)&&u.push(jj(c)),e===`pin`&&i(`strings`)&&u.push(Mj(c));let m=[],h=[];return c.forEach((t,n)=>{if(!i(`panel`+n))return;let r=t.depth===.24?l:t.depth===1.28?d:u,a=e===`pin`?s()*6-3:0,o=Bj(0,0,t.w,t.h)+zj(0,0,t.w,t.h,t.fill||`#fff`,t.op||.95)+(e===`pin`?`<circle cx="0" cy="${(-t.h/2+26).toFixed(0)}" r="12" fill="#c0392b"/>`:``);r.push(`<g transform="translate(${t.x.toFixed(0)} ${t.y.toFixed(0)}) rotate(${a.toFixed(1)})">${o}</g>`),m.push({id:`panel`+n,x:t.x,y:t.y,w:t.w,h:t.h,depth:t.depth}),h.push({id:`panel`+n,x:t.x,y:t.y,importance:t.importance||1})}),i(`fgBlob`)&&d.push(`<circle cx="${(a*.1).toFixed(0)}" cy="${(o*.88).toFixed(0)}" r="${(o*.12).toFixed(0)}" fill="#25155b" opacity=".3"/><circle cx="${(a*.94).toFixed(0)}" cy="${(o*.84).toFixed(0)}" r="${(o*.15).toFixed(0)}" fill="#25155b" opacity=".26"/>`),{planes:[{depth:.24,id:`bg`,svg:l.join(``)},{depth:1,id:`mid`,svg:u.join(``)},{depth:1.28,id:`fg`,svg:d.join(``)}],panels:m,subjects:h}}}}function kj(e,t,n,r,i){let a=n/2,o=r/2,s=[];if(e===`row`){let e=n/(t+.4),r=e*.72;for(let n=0;n<t;n++)s.push({x:e*(.7+n),y:o+(n%2?70:-70),w:r,h:560,depth:1})}else if(e===`grid`){let e=[n*.3,n*.7],t=[r*.32,r*.7];for(let n=0;n<4;n++)s.push({x:e[n%2],y:t[n<2?0:1],w:720,h:520,depth:1})}else if(e===`hero`)s.push({x:n*.36,y:o,w:1120,h:900,depth:1,importance:1.15}),s.push({x:n*.78,y:r*.34,w:560,h:440,depth:1}),s.push({x:n*.78,y:r*.7,w:560,h:440,depth:1});else if(e===`islands`)s.push({x:n*.22,y:r*.3,w:560,h:440,depth:.24,importance:.9}),s.push({x:n*.52,y:r*.56,w:760,h:580,depth:1,importance:1.1}),s.push({x:n*.82,y:r*.4,w:620,h:480,depth:1.28});else if(e===`pin`)for(let e=0;e<t;e++){let c=e/t*6.28;s.push({x:a+Math.cos(c)*n*.28+(i()-.5)*120,y:o+Math.sin(c)*r*.26+(i()-.5)*100,w:480,h:380,depth:1,fill:[`#fffaf0`,`#fef3e2`,`#eef7ff`][e%3]})}else if(e===`steps`)for(let e=0;e<t;e++){let i=e/(t-1);s.push({x:n*(.1+i*.8),y:o+Math.sin(i*Math.PI*1.6)*r*.26,w:560,h:460,depth:1})}else if(e===`orbit`){s.push({x:a,y:o,w:720,h:620,depth:1,importance:1.15,fill:`#fff`});for(let e=0;e<t-1;e++){let i=e/(t-1)*6.28-1.57;s.push({x:a+Math.cos(i)*n*.3,y:o+Math.sin(i)*r*.32,w:420,h:340,depth:1})}}return s}function Aj(e){return e.length<2?``:`<path d="${e.map((e,t)=>(t?`L`:`M`)+e.x.toFixed(0)+` `+e.y.toFixed(0)).join(` `)}" fill="none" stroke="#8a7a5a" stroke-width="10" stroke-dasharray="4 26" stroke-linecap="round" opacity=".7"/>`}function jj(e){if(!e.length)return``;let t=e[0];return e.slice(1).map(e=>`<line x1="${t.x.toFixed(0)}" y1="${t.y.toFixed(0)}" x2="${e.x.toFixed(0)}" y2="${e.y.toFixed(0)}" stroke="#5b6ce0" stroke-width="5" stroke-dasharray="2 14" opacity=".55"/>`).join(``)}function Mj(e){let t=``;for(let n=1;n<e.length;n++)t+=`<line x1="${e[n-1].x.toFixed(0)}" y1="${e[n-1].y.toFixed(0)}" x2="${e[n].x.toFixed(0)}" y2="${e[n].y.toFixed(0)}" stroke="#b04a3a" stroke-width="4" opacity=".6"/>`;return t}function Nj(e,t){return`<rect x="0" y="0" width="${e}" height="${t}" fill="#c8a97a" opacity=".5"/>`}function Pj(e,t={}){let n=Vj[e];if(!n)throw Error(`unknown board "${e}"`);let r={};n.manifest.forEach(e=>r[e.key]=e.default);for(let n of Object.keys(t))if(!(n in r))throw Error(`unknown element "${n}" for board "${e}" (has: ${Object.keys(r).join(`, `)})`);return{...r,...t}}function Fj(e){let t=Vj[e];return t?t.manifest:[]}function Ij(e,t=0,n={}){let r=Vj[e];if(!r)throw Error(`unknown board "${e}"`);let i=Pj(e,n),a=e=>i[e]!==!1,o=r.build(t,a);return{worldW:r.world[0],worldH:r.world[1],viewW:r.view[0],viewH:r.view[1],focusRing:a(`focusRing`),hud:a(`hud`),elements:i,...o}}function Lj(e,t,n=0){let r=175+Math.sin(n*4)*12;return`<circle cx="${e.toFixed(1)}" cy="${t.toFixed(1)}" r="155" fill="none" stroke="#fff" stroke-width="18" opacity=".78"/><circle cx="${e.toFixed(1)}" cy="${t.toFixed(1)}" r="${r.toFixed(1)}" fill="none" stroke="#f5c43e" stroke-width="6" opacity=".8"/>`}var Rj,zj,Bj,Vj,Hj,Uj,Wj,Gj=o((()=>{Tk(),Rj=44,zj=(e,t,n,r,i=`#fff`,a=.92)=>`<rect x="${(e-n/2).toFixed(0)}" y="${(t-r/2).toFixed(0)}" width="${n.toFixed(0)}" height="${r.toFixed(0)}" rx="${Rj}" fill="${i}" opacity="${a}"/>`,Bj=(e,t,n,r)=>`<ellipse cx="${e.toFixed(0)}" cy="${(t+r/2+8).toFixed(0)}" rx="${(n*.44).toFixed(0)}" ry="${Math.max(14,r*.05).toFixed(0)}" fill="#2b2140" opacity=".16"/>`,Vj={conceptTriptych:{world:[3e3,1800],view:[1920,1080],manifest:[{key:`bgGradient`,default:!0},{key:`bgCircleA`,default:!0},{key:`bgCircleB`,default:!0},{key:`roseBand`,default:!0},{key:`panelA`,default:!0},{key:`panelB`,default:!0},{key:`panelC`,default:!0},{key:`panelShadows`,default:!0},{key:`swoosh`,default:!0},{key:`fgBlobA`,default:!0},{key:`fgBlobB`,default:!0},{key:`focusRing`,default:!1},{key:`hud`,default:!1}],build(e,t){let n=`<defs><linearGradient id="pmbg_ct" x1="0" x2="1"><stop offset="0" stop-color="#f7dca7"/><stop offset="1" stop-color="#d9c5ef"/></linearGradient></defs>`;t(`bgGradient`)&&(n+=`<rect x="-500" y="-300" width="4000" height="2400" fill="url(#pmbg_ct)"/>`),t(`bgCircleA`)&&(n+=`<circle cx="350" cy="320" r="200" fill="#fff5dc" opacity=".65"/>`),t(`bgCircleB`)&&(n+=`<circle cx="2630" cy="420" r="280" fill="#8eddf1" opacity=".55"/>`),t(`roseBand`)&&(n+=`<path d="M-200 1550 Q700 1050 1450 1420 T3200 1200 L3200 2100 H-200Z" fill="#d86d82" opacity=".28"/>`);let r=``;t(`panelA`)&&(r+=`<rect x="120" y="260" width="630" height="520" rx="44" fill="#fff" opacity=".9"/>`),t(`panelB`)&&(r+=`<rect x="1840" y="290" width="720" height="560" rx="44" fill="#fff" opacity=".9"/>`),t(`panelC`)&&(r+=`<rect x="920" y="910" width="730" height="520" rx="44" fill="#fff" opacity=".92"/>`),t(`panelShadows`)&&(r+=`<ellipse cx="480" cy="710" rx="120" ry="30" fill="#2b2140" opacity=".16"/><ellipse cx="2200" cy="790" rx="160" ry="35" fill="#2b2140" opacity=".16"/><ellipse cx="1280" cy="1400" rx="220" ry="45" fill="#2b2140" opacity=".16"/>`);let i=``;return t(`swoosh`)&&(i+=`<path d="M-400 1750 Q350 1180 860 1600 T2050 1510 T3400 1310 L3400 2200 H-400Z" fill="#54379e" opacity=".72"/>`),t(`fgBlobA`)&&(i+=`<circle cx="220" cy="1440" r="150" fill="#25155b" opacity=".35"/>`),t(`fgBlobB`)&&(i+=`<circle cx="2900" cy="1360" r="220" fill="#25155b" opacity=".28"/>`),{planes:[{depth:.24,id:`bg`,svg:n},{depth:1,id:`mid`,svg:r},{depth:1.28,id:`fg`,svg:i}],panels:[{id:`panelA`,x:480,y:500,w:630,h:520},{id:`panelB`,x:2200,y:540,w:720,h:560},{id:`panelC`,x:1280,y:1180,w:730,h:520}],subjects:[{id:`panelA`,x:480,y:500,importance:1.05},{id:`panelB`,x:2200,y:540,importance:1.08},{id:`panelC`,x:1280,y:1180,importance:1.1}]}}},panelRow:Oj(`row`),panelGrid:Oj(`grid`),heroPanelSide:Oj(`hero`),floatingIslands:Oj(`islands`),pinboard:Oj(`pin`),stepsPath:Oj(`steps`),orbitBoard:Oj(`orbit`)},Hj={row:[`#f7dca7`,`#d9c5ef`,`#fff5dc`,`#8eddf1`],grid:[`#e8f0e6`,`#cfe0f0`,`#fff2d6`,`#bfe3d8`],hero:[`#fbe3cf`,`#e6d2f0`,`#ffe6c2`,`#c9d8f2`],islands:[`#dfeafc`,`#f3e2ef`,`#cfe9ff`,`#ffd9ec`],pin:[`#e8d9bf`,`#d3c0a3`,`#fff3d6`,`#d9c19a`],steps:[`#e9f2df`,`#d4e8f0`,`#fff0cf`,`#c7e6d6`],orbit:[`#1b1740`,`#2b2160`,`#5b6ce0`,`#8eddf1`]},Uj=Object.keys(Vj),Wj=e=>Object.prototype.hasOwnProperty.call(Vj,e)}));function Kj(e){return function(t=7){let n=cM[e]||cM.day,r=e+t;return[Z(0,(e,t,r)=>{let i=e.createLinearGradient(0,0,0,r);i.addColorStop(0,n.skyTop),i.addColorStop(1,n.skyBot),e.fillStyle=i,e.fillRect(-500,-500,t+1e3,r+1e3)}),dM(.14,`dfar`+r,n.far,90,150),dM(.3,`dmid`+r,n.mid,80,90),iM(n.ground),dM(.66,`dnear`+r,n.near,70,40),fM(-1,n),fM(1,n)]}}function qj(e,t){return function(n=7,r=`day`){let i=cM[r]||cM.day,a=e+r+n,o=(EM[t]||{}).bias||0;if(e===`room`)return[rM(i.skyBot),Z(.2,(e,t,n,r)=>{e.fillStyle=i.mid,e.fillRect(-500,-500,t+1e3,r+500)}),Z(.28,(e,t,n)=>{e.fillStyle=i.far,e.fillRect(t*.34,n*.15,t*.32,n*.32),e.fillStyle=i.skyTop,e.fillRect(t*.36,n*.17,t*.28,n*.28)}),iM(i.ground),Z(.66,(e,t,n,r,a)=>{e.fillStyle=i.near,e.fillRect(-500,r-14*a,t+1e3,14*a)}),...DM(t,i)];let s=bM[e]||bM.field;return[mM(i),xM(s[0],.14,`far`+a,{col:i.far,bias:o}),xM(s[1],.3,`mid`+a,{col:i.mid,bias:o}),iM(i.ground),xM(s[2],.66,`near`+a,{col:i.near,bias:o}),...DM(t,i)]}}function Jj(e,t){let n=qM[e]||qM[`center.c`];return{x:n.x*t,y:n.y,z:n.z==null?.5:n.z}}function Yj(e){let t={};return e.map((e,n)=>{let r=ZM(e.d);return t[r]=(t[r]||0)+1,{key:`l`+n,default:!0,label:r+(t[r]>1?` `+t[r]:``)}})}function Xj(e){return Wj(e)?Fj(e):Yj((tM[e]||tM.plain)(7,`day`))}function Zj(e,t={}){let n={};Xj(e).forEach(e=>n[e.key]=e.default);for(let r of Object.keys(t))if(!(r in n))throw Error(`unknown element "${r}" for setup "${e}" (has: ${Object.keys(n).join(`, `)})`);return{...n,...t}}function Qj(e,t=7,n=`2.5d`,r=`day`,i={}){let a=(tM[e]||tM.plain)(t,r),o=Zj(XM(e)?e:`plain`,i);return{name:XM(e)?e:`plain`,mode:n,seed:t,palette:r,slots:GM[e]||JM,layers:a,elements:o}}function $j(e,t,n,r,i,a={scale:0,pan:0},o=0){let s=n/eM;t&&t.layers.length&&t.layers.forEach((c,l)=>{if(t.elements&&t.elements[`l`+l]===!1)return;e.save();let u=1+a.scale*c.d,d=a.pan*c.d*s;e.translate(n/2,i),e.scale(u,u),e.translate(-n/2,-i),e.translate(d,0),c.draw(e,n,r,i,s,o),e.restore()})}var eM,tM,Z,nM,rM,iM,aM,oM,sM,cM,lM,uM,dM,fM,pM,mM,hM,gM,_M,vM,yM,bM,xM,SM,CM,wM,TM,EM,DM,OM,kM,AM,jM,MM,NM,PM,FM,IM,LM,RM,zM,BM,VM,HM,UM,WM,GM,KM,qM,JM,YM,XM,ZM,QM=o((()=>{Tk(),Dj(),Gj(),eM=960,tM={plain(){return[]},skyDay(e){let t=vk(`skyDay`+e),n=[];for(let e=0;e<6;e++)n.push({x:t()*eM,y:60+t()*200,s:.7+t()*.9});return[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#3d8fd6`),r.addColorStop(.6,`#8fc4ec`),r.addColorStop(1,`#dceffa`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3),e.fillStyle=`rgba(255,246,214,0.95)`,e.beginPath(),e.arc(t*.8,n*.22,44,0,7),e.fill()}},{d:.18,draw:(e,t,r,i,a)=>{e.fillStyle=`rgba(255,255,255,0.9)`,n.forEach(t=>{let n=t.x*a,i=t.y/540*r,o=26*t.s*a;e.beginPath(),e.arc(n,i,o,0,7),e.arc(n+o,i+4*a,o*.8,0,7),e.arc(n-o,i+4*a,o*.8,0,7),e.arc(n+o*.4,i-o*.6,o*.7,0,7),e.fill()})}}]},skyNight(e){let t=vk(`skyNight`+e),n=[];for(let e=0;e<90;e++)n.push({x:t()*eM,y:t()*480,r:.6+t()*1.8});return[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#0b1430`),r.addColorStop(1,`#26325c`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3),e.fillStyle=`rgba(240,240,220,0.9)`,e.beginPath(),e.arc(t*.24,n*.2,30,0,7),e.fill()}},{d:.12,draw:(e,t,r,i,a)=>{e.fillStyle=`#fdfbe8`,n.forEach(t=>{e.globalAlpha=.5+t.r%1*.5,e.beginPath(),e.arc(t.x*a,t.y/540*r,t.r*a,0,7),e.fill()}),e.globalAlpha=1}}]},city(e){let t=vk(`city`+e),n=[],r=[],i=[],a=-60;for(;a<1020;){let e=26+t()*30,r=80+t()*150;n.push({x:a,w:e,h:r}),a+=e+10}for(a=-80;a<1040;){let e=60+t()*70,n=120+t()*180;r.push({x:a,w:e,h:n}),a+=e+16}for(a=-100;a<1060;){let e=90+t()*80,n=90+t()*120;i.push({x:a,w:e,h:n}),a+=e+70}return[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#bfe3f2`),r.addColorStop(1,`#eaf6fb`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3),e.fillStyle=`rgba(255,255,255,0.55)`,e.beginPath(),e.arc(t*.78,n*.2,46,0,7),e.fill()}},{d:.15,draw:(e,t,r,i,a)=>{e.fillStyle=`#cdd7e6`,n.forEach(t=>e.fillRect(t.x*a,i-t.h*a,t.w*a,t.h*a+260))}},{d:.34,draw:(e,t,n,i,a)=>{r.forEach(t=>{e.fillStyle=`#7d8aa0`,e.fillRect(t.x*a,i-t.h*a,t.w*a,t.h*a),e.fillStyle=`rgba(255,235,170,0.9)`;let n=Math.floor(t.h/22);for(let r=0;r<3;r++)for(let o=0;o<n-1;o++)(r*7+o*13+(t.x|0))%3!=0&&e.fillRect((t.x+8+r*((t.w-16)/3))*a,i-(t.h-14-o*22)*a,((t.w-16)/3-7)*a,10*a)})}},{d:.46,draw:(e,t,n,r)=>{e.fillStyle=`#8e9aac`,e.fillRect(-500,r,t+1e3,n-r+500)}},{d:.78,draw:(e,t,n,r,a)=>{e.fillStyle=`#6a7689`,i.forEach(t=>e.fillRect(t.x*a,r-t.h*a,t.w*a,t.h*a))}}]},nature(e){let t=vk(`nature`+e),n=[],r=20;for(;r<eM;)n.push({x:r,h:70+t()*60}),r+=90+t()*70;return[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#bfe6ef`),r.addColorStop(1,`#eaf8f3`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3),e.fillStyle=`rgba(255,255,255,0.5)`,e.beginPath(),e.arc(t*.76,n*.22,42,0,7),e.fill()}},{d:.16,draw:(e,t,n,r,i)=>{e.fillStyle=`#bfe0a8`,e.beginPath(),e.moveTo(-500,r);for(let n=-500;n<=t+500;n+=36)e.lineTo(n,r-Math.abs(Math.sin(n*.004+1))*90*i-30*i);e.lineTo(t+500,r),e.closePath(),e.fill()}},{d:.34,draw:(e,t,n,r,i)=>{e.fillStyle=`#9fcf9a`,e.beginPath(),e.moveTo(-500,r);for(let n=-500;n<=t+500;n+=36)e.lineTo(n,r-Math.abs(Math.sin(n*.005+3))*60*i-10*i);e.lineTo(t+500,r),e.closePath(),e.fill()}},{d:.46,draw:(e,t,n,r)=>{e.fillStyle=`#7cae5a`,e.fillRect(-500,r,t+1e3,n-r+500)}},{d:.7,draw:(e,t,r,i,a)=>{n.forEach(t=>{let n=t.h;e.fillStyle=`#6b4a2e`,e.fillRect(t.x*a-3*a,i-n*.5*a,6*a,n*.5*a),e.fillStyle=`#3f8f63`,e.beginPath(),e.arc(t.x*a,i-n*.5*a,n*.42*a,0,7),e.fill()})}}]},interior(){return[{d:.1,draw:(e,t,n,r,i)=>{e.fillStyle=`#dcd2c2`,e.fillRect(-500,-500,t+1e3,r+500),e.fillStyle=`#cfc3b0`,e.fillRect(-500,r-30*i,t+1e3,30*i)}},{d:.3,draw:(e,t,n,r,i)=>{for(let r=0;r<3;r++){let a=t*(.24+r*.26),o=n*.3,s=72*i,c=60*i;e.fillStyle=`#fff`,e.fillRect(a-s/2,o-c/2,s,c),e.fillStyle=[`#d98c6a`,`#7c9fd9`,`#7cc08a`][r],e.fillRect(a-s/2+6*i,o-c/2+6*i,s-12*i,c-12*i)}}},{d:.46,draw:(e,t,n,r,i)=>{e.fillStyle=`#b9966f`,e.fillRect(-500,r,t+1e3,n-r+500),e.fillStyle=`#a8865f`;for(let t=-5;t<20;t++)e.fillRect(t*90*i,r,3*i,n-r+300)}}]},abstract(e){let t=vk(`abstract`+e),n=[];for(let e=0;e<8;e++)n.push({x:t()*eM,y:t()*540,r:50+t()*120,d:.12+t()*.72,h:t()});let r=[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#2a2350`),r.addColorStop(1,`#5b3f8f`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3)}}];return n.sort((e,t)=>e.d-t.d).forEach(e=>r.push({d:e.d,draw:(t,n,r,i,a)=>{t.globalAlpha=.82,t.fillStyle=e.h<.5?`#7c5cff`:`#ff7ab0`,t.beginPath(),t.arc(e.x*a,e.y/540*r,e.r*a,0,7),t.fill(),t.globalAlpha=1}})),r}},Z=(e,t)=>({d:e,draw:t}),nM=(e,t)=>Z(0,(n,r,i)=>{let a=n.createLinearGradient(0,0,0,i);a.addColorStop(0,e),a.addColorStop(1,t),n.fillStyle=a,n.fillRect(-500,-500,r+1e3,i+1e3)}),rM=e=>Z(0,(t,n,r)=>{t.fillStyle=e,t.fillRect(-500,-500,n+1e3,r+1e3)}),iM=(e,t=0)=>Z(.46,(n,r,i,a)=>{n.fillStyle=e,n.fillRect(-500,a+t,r+1e3,i-a+500)}),aM=(e,t,n,r,i,a)=>Z(e,(e,o,s,c,l)=>{let u=vk(t);e.fillStyle=n;for(let t=0;t<r;t++){let t=u()*eM,n=i[0]+u()*i[1],r=a[0]+u()*a[1];e.fillRect(t*l,c-r*l,n*l,r*l)}}),oM=(e,t,n,r)=>Z(e,(e,i,a,o,s)=>{let c=vk(t),l=20;for(;l<eM;){let t=60+c()*70;e.fillStyle=n,e.fillRect(l*s-3*s,o-t*.5*s,6*s,t*.5*s),e.fillStyle=r,e.beginPath(),e.arc(l*s,o-t*.5*s,t*.42*s,0,7),e.fill(),l+=80+c()*70}}),sM=e=>Z(.3,(t,n,r,i,a)=>{for(let i=0;i<3;i++){let o=n*(.22+i*.28),s=r*.28,c=66*a,l=54*a;t.fillStyle=`#fff`,t.fillRect(o-c/2,s-l/2,c,l),t.fillStyle=e[i%e.length],t.fillRect(o-c/2+6*a,s-l/2+6*a,c-12*a,l-12*a)}}),Object.assign(tM,{genericRoom(e){return tM.interior(e)},office(e){return[nM(`#dfe6ee`,`#eef2f6`),sM([`#7c9fd9`,`#3fae6b`]),Z(.34,(e,t,n,r,i)=>{e.fillStyle=`#c9d2da`;for(let t=0;t<3;t++)e.fillRect((120+t*300)*i,r-70*i,200*i,70*i)}),iM(`#c9b79a`)]},classroom(){return[rM(`#e8ede2`),Z(.28,(e,t,n)=>{e.fillStyle=`#3a6b52`,e.fillRect(t*.24,n*.16,t*.52,n*.34),e.strokeStyle=`#2c5240`,e.lineWidth=6,e.strokeRect(t*.24,n*.16,t*.52,n*.34)}),iM(`#c7b79a`)]},workshop(e){return[rM(`#d8d3c6`),aM(.3,`wk`+e,`#9a8b6f`,8,[30,40],[20,60]),iM(`#b09571`)]},kitchen(){return[rM(`#eef1eb`),Z(.34,(e,t,n,r,i)=>{e.fillStyle=`#c7cdb9`,e.fillRect(-500,r-40*i,t+1e3,12*i)}),iM(`#cdbfa4`)]},stagePodium(){return[rM(`#242a34`),Z(.2,(e,t,n)=>{let r=e.createRadialGradient(t/2,n*.3,20,t/2,n*.3,n*.7);r.addColorStop(0,`rgba(255,240,200,.35)`),r.addColorStop(1,`rgba(255,240,200,0)`),e.fillStyle=r,e.fillRect(0,0,t,n)}),iM(`#39414f`)]},corridor(){return[rM(`#dfe1e6`),Z(.3,(e,t,n)=>{e.strokeStyle=`#c3c8d0`,e.lineWidth=3;for(let r=-3;r<=3;r++)e.beginPath(),e.moveTo(t/2+r*t*.16,0),e.lineTo(t/2+r*t*.04,n),e.stroke()}),iM(`#b8bcc6`)]},storeInterior(e){return[rM(`#e9e4da`),aM(.32,`st`+e,`#b79c74`,6,[70,20],[60,40]),iM(`#c3b393`)]},labGeneric(e){return[rM(`#eef3f5`),aM(.32,`lb`+e,`#cdd7dc`,5,[40,50],[30,60]),iM(`#d3dde0`)]},controlRoom(e){return[rM(`#1d2430`),Z(.3,(t,n,r,i,a)=>{vk(`cr`+e);for(let e=0;e<8;e++)t.fillStyle=[`#2b6cb0`,`#2bb3a3`,`#c98a3a`][e%3],t.globalAlpha=.7,t.fillRect((60+e*110)*a,(120+e%2*40)*a,80*a,50*a),t.globalAlpha=1}),iM(`#2a323f`)]},street(e){return[nM(`#bfe3f2`,`#eaf6fb`),aM(.4,`str`+e,`#8e9aac`,10,[50,60],[90,150]),iM(`#7a8391`),Z(.5,(e,t,n,r,i)=>{e.fillStyle=`#5c636e`,e.fillRect(-500,r,t+1e3,n),e.strokeStyle=`#e6c34a`,e.lineWidth=3*i,e.setLineDash([20*i,18*i]),e.beginPath(),e.moveTo(-500,r+(n-r)*.5),e.lineTo(t+500,r+(n-r)*.5),e.stroke(),e.setLineDash([])})]},park(){return[nM(`#bfe6ef`,`#eaf8f3`),iM(`#7cae5a`),oM(.6,`park`,`#6b4a2e`,`#3f8f63`),Z(.5,(e,t,n,r)=>{e.fillStyle=`#cdbd8f`,e.beginPath(),e.moveTo(t*.3,n),e.lineTo(t*.46,r),e.lineTo(t*.54,r),e.lineTo(t*.7,n),e.fill()})]},forest(e){return[nM(`#cfe6d6`,`#eef7ef`),iM(`#5f8f4e`),oM(.4,`f1`+e,`#5a3e26`,`#357a4e`),oM(.7,`f2`+e,`#6b4a2e`,`#3f8f63`)]},mountain(e){return[nM(`#cfe0ef`,`#eef4f9`),Z(.2,(t,n,r,i,a)=>{let o=vk(`mt`+e);t.fillStyle=`#9fb0c4`;for(let e=0;e<5;e++){let n=e*eM/4*a,r=(160+o()*120)*a;t.beginPath(),t.moveTo(n-140*a,i),t.lineTo(n,i-r),t.lineTo(n+140*a,i),t.fill()}}),iM(`#7f9e6f`)]},desertPlain(){return[nM(`#f4dcae`,`#f8eccf`),iM(`#e4c483`),Z(.3,(e,t,n,r,i)=>{e.fillStyle=`#d9b46e`,e.beginPath(),e.moveTo(-500,r);for(let n=-500;n<=t+500;n+=40)e.lineTo(n,r-Math.abs(Math.sin(n*.003))*30*i);e.lineTo(t+500,r),e.fill()})]},coastBeach(){return[nM(`#bfe3f2`,`#e8f6fb`),Z(.34,(e,t,n,r,i)=>{e.fillStyle=`#4aa3c4`,e.fillRect(-500,r-60*i,t+1e3,60*i)}),iM(`#ead9a6`)]},farmField(){return[nM(`#c7e6f0`,`#eef9f3`),iM(`#8bab4e`),Z(.5,(e,t,n,r,i)=>{e.strokeStyle=`#79993f`,e.lineWidth=3*i;for(let n=0;n<6;n++)e.beginPath(),e.moveTo(-500,r+n*20*i),e.lineTo(t+500,r+n*20*i),e.stroke()})]},skylineWide(e){return[nM(`#bcd8ee`,`#eaf4fb`),aM(.2,`sk`+e,`#aebccd`,14,[30,40],[80,160]),aM(.42,`sk2`+e,`#8695a9`,9,[60,60],[60,120]),iM(`#79879a`)]},rooftop(e){return[nM(`#bfe3f2`,`#eaf6fb`),aM(.2,`rf`+e,`#9caabd`,10,[40,50],[60,120]),iM(`#8a8f98`),Z(.5,(e,t,n,r,i)=>{e.fillStyle=`#6f747d`,e.fillRect(-500,r-16*i,t+1e3,16*i)})]},roadHighway(){return[nM(`#bfe3f2`,`#eaf6fb`),iM(`#5c636e`),Z(.5,(e,t,n,r,i)=>{e.strokeStyle=`#eef2f4`,e.lineWidth=4*i,e.setLineDash([26*i,22*i]),[.35,.65].forEach(i=>{e.beginPath(),e.moveTo(-500,r+(n-r)*i),e.lineTo(t+500,r+(n-r)*i),e.stroke()}),e.setLineDash([])})]},oceanSurface(){return[nM(`#a9d6ec`,`#dff1fb`),Z(.4,(e,t,n,r,i)=>{e.fillStyle=`#2f8fc0`,e.fillRect(-500,r-30*i,t+1e3,n),e.strokeStyle=`rgba(255,255,255,.5)`,e.lineWidth=2*i;for(let n=0;n<5;n++){e.beginPath(),e.moveTo(-500,r+n*26*i);for(let a=-500;a<t+500;a+=30)e.lineTo(a,r+n*26*i+Math.sin(a*.03+n)*4*i);e.stroke()}})]},underwater(e){return[nM(`#1f6f9e`,`#0c3f5f`),Z(.3,(t,n,r,i,a)=>{let o=vk(`uw`+e);t.fillStyle=`rgba(255,255,255,.25)`;for(let e=0;e<30;e++)t.beginPath(),t.arc(o()*n,o()*r,(2+o()*6)*a,0,7),t.fill()}),iM(`#b79a5f`)]},skyClouds(){return tM.skyDay(3)},spacePlanet(e){return[nM(`#0a0f22`,`#161f3e`),Z(.12,(t,n,r,i,a)=>{let o=vk(`sp`+e);t.fillStyle=`#fdfbe8`;for(let e=0;e<80;e++)t.fillRect(o()*n,o()*r,2,2)}),Z(.2,(e,t,n,r,i)=>{e.fillStyle=`#c96a5e`,e.beginPath(),e.arc(t*.76,n*.3,60*i,0,7),e.fill(),e.fillStyle=`rgba(255,255,255,.12)`,e.beginPath(),e.arc(t*.72,n*.26,60*i,0,7),e.fill()})]},arcticIce(){return[nM(`#cfe6f2`,`#eef7fb`),iM(`#dfeef4`),Z(.4,(e,t,n,r,i)=>{e.fillStyle=`#bcd7e4`;for(let t=0;t<4;t++){let n=(120+t*260)*i;e.beginPath(),e.moveTo(n-90*i,r),e.lineTo(n,r-70*i),e.lineTo(n+90*i,r),e.fill()}})]},studioPlain(){return[nM(`#eef3f4`,`#dbe8ea`)]},gradientAbstract(e){let t=vk(`ga`+e),n=Math.floor(t()*360);return[Z(0,(e,t,r)=>{let i=e.createLinearGradient(0,0,t,r);i.addColorStop(0,`hsl(${n} 55% 62%)`),i.addColorStop(1,`hsl(${(n+60)%360} 55% 48%)`),e.fillStyle=i,e.fillRect(0,0,t,r)})]},gridBoard(){return[rM(`#f4f7f8`),Z(.2,(e,t,n,r,i)=>{e.strokeStyle=`#dde5e9`,e.lineWidth=1.5;for(let r=0;r<t;r+=40*i)e.beginPath(),e.moveTo(r,0),e.lineTo(r,n),e.stroke();for(let r=0;r<n;r+=40*i)e.beginPath(),e.moveTo(0,r),e.lineTo(t,r),e.stroke()})]},mapStage(e){return[rM(`#dcece2`),Z(.2,(t,n,r,i,a)=>{let o=vk(`mp`+e);t.fillStyle=`#b7d8c1`,t.beginPath(),t.moveTo(n*.2,r*.3);for(let e=0;e<10;e++)t.lineTo(n*(.2+o()*.6),r*(.2+o()*.6));t.closePath(),t.fill()})]},chartStage(){return[rM(`#f6f8f9`),Z(.2,(e,t,n,r,i)=>{e.strokeStyle=`#d7dee3`,e.lineWidth=2,e.beginPath(),e.moveTo(t*.15,n*.2),e.lineTo(t*.15,n*.8),e.lineTo(t*.85,n*.8),e.stroke()})]},timelineBand(){return[rM(`#f4f7f8`),Z(.3,(e,t,n,r,i)=>{e.fillStyle=`#e7edf1`,e.fillRect(0,n*.46,t,n*.08)})]},splitVersus(){return[Z(0,(e,t,n)=>{e.fillStyle=`#dfeaf6`,e.fillRect(0,0,t/2,n),e.fillStyle=`#f6e3df`,e.fillRect(t/2,0,t/2,n),e.strokeStyle=`#c7d0d6`,e.lineWidth=3,e.beginPath(),e.moveTo(t/2,0),e.lineTo(t/2,n),e.stroke()})]},iconField(e){return[rM(`#f2f5f6`),Z(.2,(t,n,r,i,a)=>{let o=vk(`if`+e);t.fillStyle=`#dbe4e8`;for(let e=0;e<24;e++)t.beginPath(),t.arc(o()*n,o()*r,10*a,0,7),t.fill()})]},blueprint(){return[rM(`#123a63`),Z(.2,(e,t,n,r,i)=>{e.strokeStyle=`rgba(255,255,255,.22)`,e.lineWidth=1;for(let r=0;r<t;r+=34*i)e.beginPath(),e.moveTo(r,0),e.lineTo(r,n),e.stroke();for(let r=0;r<n;r+=34*i)e.beginPath(),e.moveTo(0,r),e.lineTo(t,r),e.stroke()})]},spotlightDark(){return[rM(`#171c24`),Z(.1,(e,t,n,r)=>{let i=e.createRadialGradient(t/2,r-120,30,t/2,r-120,t*.6);i.addColorStop(0,`rgba(255,255,255,.16)`),i.addColorStop(1,`rgba(255,255,255,0)`),e.fillStyle=i,e.fillRect(0,0,t,n)}),iM(`#20262f`)]},crowdScene(e){return[nM(`#cfd8e2`,`#eaeff4`),iM(`#9aa2ad`),Z(.6,(t,n,r,i,a)=>{let o=vk(`cw`+e);for(let e=0;e<26;e++){let e=o()*eM*a,n=(50+o()*30)*a;t.fillStyle=`hsl(${Math.floor(o()*360)} 30% 55%)`,t.fillRect(e,i-n,16*a,n),t.beginPath(),t.arc(e+8*a,i-n,9*a,0,7),t.fill()}})]},marketplace(e){return[nM(`#e9d9b0`,`#f4ead0`),iM(`#c9b184`),Z(.5,(t,n,r,i,a)=>{vk(`mk`+e);for(let e=0;e<5;e++){let n=(80+e*200)*a;t.fillStyle=[`#c0563f`,`#3f7fc0`,`#3fae6b`,`#c9a13a`,`#8b5cf6`][e],t.fillRect(n,i-90*a,140*a,20*a),t.fillStyle=`#a9855c`,t.fillRect(n+6*a,i-70*a,6*a,70*a),t.fillRect(n+128*a,i-70*a,6*a,70*a)}})]},constructionSite(e){return[nM(`#cfe0ec`,`#eef4f9`),iM(`#b79a6a`),Z(.4,(e,t,n,r,i)=>{e.strokeStyle=`#e0a52e`,e.lineWidth=6*i,e.strokeRect(t*.3,r-200*i,6*i,200*i),e.beginPath(),e.moveTo(t*.3,r-200*i),e.lineTo(t*.55,r-200*i),e.stroke()})]},harborDock(e){return[nM(`#bfe3f2`,`#eaf6fb`),Z(.4,(e,t,n,r,i)=>{e.fillStyle=`#3f8fb5`,e.fillRect(-500,r-20*i,t+1e3,n)}),iM(`#8a6a45`,20),Z(.3,(e,t,n,r,i)=>{e.strokeStyle=`#c9553f`,e.lineWidth=6*i,e.strokeRect(t*.6,r-150*i,6*i,150*i)})]},weatherStorm(e){return[nM(`#4a5361`,`#6a7484`),Z(.2,(t,n,r,i,a)=>{let o=vk(`ws`+e);t.strokeStyle=`rgba(220,230,240,.4)`,t.lineWidth=2;for(let e=0;e<60;e++){let e=o()*n,i=o()*r;t.beginPath(),t.moveTo(e,i),t.lineTo(e-6*a,i+18*a),t.stroke()}}),iM(`#3c4450`)]}}),cM={day:{skyTop:`#7fb2e0`,skyBot:`#cfe6f5`,far:`#b8cdde`,mid:`#7f93a8`,ground:`#6d8196`,near:`#4f6172`,occluder:`#26323f`},goldenHour:{skyTop:`#f0a35a`,skyBot:`#f7d79a`,far:`#d8b58a`,mid:`#b5876a`,ground:`#8f6a4f`,near:`#5f4636`,occluder:`#2a1c14`},dusk:{skyTop:`#e98a5b`,skyBot:`#f4c78d`,far:`#caa088`,mid:`#9c6f6a`,ground:`#7a5b57`,near:`#513f4a`,occluder:`#241826`},night:{skyTop:`#0b1430`,skyBot:`#26325c`,far:`#33406a`,mid:`#26314f`,ground:`#1b2740`,near:`#141d33`,occluder:`#060a16`},dawn:{skyTop:`#b98db5`,skyBot:`#f3d0c9`,far:`#c9b3c4`,mid:`#9e8ba0`,ground:`#7d7085`,near:`#55495e`,occluder:`#221c2b`},overcast:{skyTop:`#b8bfc6`,skyBot:`#d8dde1`,far:`#b3bcc4`,mid:`#97a2ad`,ground:`#808b95`,near:`#5e6771`,occluder:`#333a42`},desert:{skyTop:`#e6c98a`,skyBot:`#f4ead0`,far:`#dcc59a`,mid:`#c9a56f`,ground:`#b98d5a`,near:`#9a6f45`,occluder:`#4a3520`},arctic:{skyTop:`#a9c9e0`,skyBot:`#eef7fb`,far:`#cddfe9`,mid:`#b6cdd8`,ground:`#cfe0e6`,near:`#93b0bd`,occluder:`#35505e`},underwater:{skyTop:`#1f6f8f`,skyBot:`#0d3f4f`,far:`#2f7f8a`,mid:`#266b70`,ground:`#1b4f52`,near:`#143a3a`,occluder:`#08201f`},space:{skyTop:`#05060f`,skyBot:`#10132a`,far:`#1e2340`,mid:`#191d38`,ground:`#12162c`,near:`#0c0f20`,occluder:`#04050c`},neonNight:{skyTop:`#14082a`,skyBot:`#2a1050`,far:`#7a3fb0`,mid:`#b03f8a`,ground:`#2a1a4a`,near:`#16102e`,occluder:`#080416`},sepiaPast:{skyTop:`#cdb488`,skyBot:`#e6d4ad`,far:`#c4ac82`,mid:`#a98d64`,ground:`#8a7150`,near:`#5f4c34`,occluder:`#2f2419`}},lM=Object.keys(cM),uM={day:`light`,goldenHour:`light`,dusk:`light`,night:`dark`,dawn:`light`,overcast:`light`,desert:`light`,arctic:`light`,underwater:`dark`,space:`dark`,neonNight:`dark`,sepiaPast:`light`},dM=(e,t,n,r,i,a=0)=>Z(e,(e,o,s,c,l)=>{let u=vk(t),d=[];for(let e=0;e<=16;e++)d.push((i+u()*r)*(1+a*.45*(e/8-1)));e.fillStyle=n,e.beginPath(),e.moveTo(-500,c);for(let t=0;t<=16;t++){let n=-200+t/16*(o+400);e.lineTo(n,c-d[t]*l)}e.lineTo(o+500,c),e.closePath(),e.fill()}),fM=(e,t)=>Z(.9,(n,r,i,a,o,s=0)=>{let c=1+Math.sin(s*.55+(e<0?0:1.7))*.02,l=Math.sin(s*.12+e)*22*o,u=r*.24*c,d=e<0?-60+l:r-u+60+l;n.save(),n.globalAlpha=.97,n.fillStyle=t.occluder,n.beginPath(),n.moveTo(d,-60),n.lineTo(d+u,-60),n.lineTo(d+u-26*o,i*.42),n.lineTo(d+u+10*o,i*.64),n.lineTo(d+u-34*o,i+60),n.lineTo(d-60,i+60),n.closePath(),n.fill(),n.restore()}),pM={dioramaDay:Kj(`day`),dioramaDusk:Kj(`dusk`),dioramaNight:Kj(`night`),dioramaDesert:Kj(`desert`),dioramaArctic:Kj(`arctic`)},Object.assign(tM,pM),Object.keys(pM),mM=e=>Z(0,(t,n,r)=>{let i=t.createLinearGradient(0,0,0,r);i.addColorStop(0,e.skyTop),i.addColorStop(1,e.skyBot),t.fillStyle=i,t.fillRect(-500,-500,n+1e3,r+1e3)}),hM=(e,t,n,r,i,a=0)=>Z(e,(e,o,s,c,l)=>{let u=vk(t);e.fillStyle=n,e.beginPath(),e.moveTo(-500,c);for(let t=0;t<=9;t++){let n=-200+t/9*(o+400),s=(t%2?i+u()*r:i*.28)*(1+a*.45*(t/4.5-1));e.lineTo(n,c-s*l)}e.lineTo(o+500,c),e.closePath(),e.fill()}),gM=(e,t,n,r,i,a=0)=>Z(e,(t,o,s,c,l)=>{t.fillStyle=n,t.beginPath(),t.moveTo(-500,c);for(let n=-200;n<=o+400;n+=22){let s=(n+200)/(o+400);t.lineTo(n,c-(i+Math.abs(Math.sin(n*.004+e*3))*r)*(1+a*.45*(s*2-1))*l)}t.lineTo(o+500,c),t.closePath(),t.fill()}),_M=(e,t,n,r,i,a=0)=>Z(e,(e,o,s,c,l)=>{let u=vk(t);e.fillStyle=n;let d=-80;for(;d<o+80;){let t=d/o,n=(r+u()*(i-r))*(1+a*.45*(t*2-1))*l,s=(40+u()*60)*l;e.fillRect(d,c-n,s,n+300),d+=s+(6+u()*14)*l}}),vM=(e,t,n,r,i)=>Z(e,(e,a,o,s,c)=>{let l=vk(t);e.fillStyle=n;let u=-40;for(;u<a+40;){let t=(r+l()*i)*c;e.beginPath(),e.arc(u,s-t*.5,t*.5,0,7),e.fill(),e.fillRect(u-t*.14,s-t*.5,t*.28,t*.5+200),u+=(30+l()*22)*c}}),yM=(e,t)=>Z(e,(e,n,r,i,a)=>{e.fillStyle=t,e.fillRect(-500,i-10*a,n+1e3,r),e.strokeStyle=`rgba(255,255,255,.16)`,e.lineWidth=1.5*a;for(let t=0;t<4;t++){e.beginPath();for(let r=-500;r<n+500;r+=26)e.lineTo(r,i+t*22*a+Math.sin(r*.03+t)*3*a);e.stroke()}}),bM={field:[[`rolling`,60,110],[`rolling`,48,64],[`rolling`,36,28]],hills:[[`rolling`,110,150],[`rolling`,80,88],[`rolling`,56,38]],ridge:[[`jagged`,150,150],[`jagged`,110,86],[`jagged`,78,40]],valley:[[`rolling`,120,150],[`rolling`,44,58],[`rolling`,80,44]],dunes:[[`dune`,70,110],[`dune`,54,66],[`dune`,40,30]],mesa:[[`jagged`,110,150],[`jagged`,84,84],[`jagged`,60,40]],coast:[[`rolling`,56,100],[`water`,0,0],[`rolling`,40,28]],harbor:[[`skyline`,70,140],[`water`,0,0],[`skyline`,56,86]],forest:[[`rolling`,70,110],[`tree`,64,40],[`tree`,48,30]],city:[[`skyline`,90,170],[`skyline`,110,150],[`skyline`,78,110]],plaza:[[`skyline`,80,150],[`rolling`,28,44],[`skyline`,60,84]]},xM=(e,t,n,r)=>{let[i,a,o]=e,s=r.bias||0;return i===`jagged`?hM(t,n,r.col,a,o,s):i===`dune`?gM(t,n,r.col,a,o,s):i===`skyline`?_M(t,n,r.col,o,o+a,s):i===`tree`?vM(t,n,r.col,o,a):i===`water`?yM(t,r.col):dM(t,n,r.col,a,o,s)},SM=e=>1+Math.sin(e*.55)*.02,CM=(e,t)=>Math.sin(e*.12+t)*16,wM={curtain:(e,t)=>Z(.88,(n,r,i,a,o,s=0)=>{let c=r*.15*SM(s),l=CM(s,t)*o,u=t<0?-40+l:r-c+40+l;n.save(),n.globalAlpha=.9,n.fillStyle=e.occluder,n.beginPath(),n.moveTo(u,-60),n.lineTo(u+c,-60),n.lineTo(u+c-20*o,i*.5),n.lineTo(u+c-30*o,i+60),n.lineTo(u-40,i+60),n.closePath(),n.fill(),n.restore()}),foliage:(e,t)=>Z(.9,(n,r,i,a,o,s=0)=>{let c=CM(s,t)*o,l=t<0?-16+c:r+16+c,u=t<0?1:-1;n.save(),n.globalAlpha=.9,n.fillStyle=e.occluder;for(let e=0;e<5;e++){let t=l+u*e*42*o,r=(18+e*22)*o+Math.sin(s*.5+e)*4*o;n.beginPath(),n.arc(t,r,(48-e*4)*o,0,7),n.fill()}n.restore()}),pillar:(e,t)=>Z(.88,(n,r,i,a,o,s=0)=>{let c=CM(s,t)*o*.3,l=r*.085,u=t<0?r*.05+c:r*.865+c;n.save(),n.globalAlpha=.94,n.fillStyle=e.occluder,n.fillRect(u,-40,l,i+80),n.fillStyle=yk(e.occluder,1.35),n.fillRect(u,-40,l*.32,i+80),n.restore()}),archTop:e=>Z(.9,(t,n,r,i,a,o=0)=>{let s=SM(o);t.save(),t.globalAlpha=.94,t.fillStyle=e.occluder,t.beginPath(),t.moveTo(-60,-60),t.lineTo(n+60,-60),t.lineTo(n+60,r*.2*s),t.quadraticCurveTo(n*.5,r*.44*s,-60,r*.2*s),t.closePath(),t.fill(),t.restore()}),ledge:e=>Z(.9,(t,n,r,i,a,o=0)=>{let s=SM(o);t.save(),t.globalAlpha=.94,t.fillStyle=e.occluder,t.fillRect(-60,r-58*a*s,n+120,90*a),t.restore()}),rocks:(e,t)=>Z(.9,(n,r,i,a,o)=>{let s=t<0?r*.03:r*.8;n.save(),n.globalAlpha=.94,n.fillStyle=e.occluder,n.beginPath(),n.moveTo(s-70,i+60),n.lineTo(s,i-66*o),n.lineTo(s+52*o,i-40*o),n.lineTo(s+112*o,i-92*o),n.lineTo(s+190*o,i+60),n.closePath(),n.fill(),n.restore()}),kelp:(e,t)=>Z(.9,(n,r,i,a,o,s=0)=>{let c=t<0?r*.07:r*.9;n.save(),n.globalAlpha=.78,n.strokeStyle=e.occluder,n.lineWidth=13*o,n.lineCap=`round`;for(let e=0;e<2;e++){let t=c+e*24*o;n.beginPath(),n.moveTo(t,i+40);for(let r=i;r>i*.3;r-=28)n.lineTo(t+Math.sin(r*.02+s*.6+e)*20*o,r);n.stroke()}n.restore()}),beam:(e,t)=>Z(.88,(n,r,i,a,o)=>{let s=t<0?1:-1,c=t<0?-40:r+40;n.save(),n.globalAlpha=.9,n.strokeStyle=e.occluder,n.lineWidth=22*o,n.beginPath(),n.moveTo(c,-40),n.lineTo(c+s*r*.5,i*.7),n.stroke(),n.restore()}),crowdFg:e=>Z(.92,(t,n,r,i,a,o=0)=>{t.save(),t.globalAlpha=.9,t.fillStyle=e.occluder;for(let e=0;e<7;e++){let i=(e+.5)*(n/7)+Math.sin(o*.6+e)*4*a;t.beginPath(),t.arc(i,r+34*a,44*a,Math.PI,0),t.fill(),t.beginPath(),t.arc(i,r-18*a,20*a,0,7),t.fill()}t.restore()})},TM={genericRoom:[{kind:`pillar`,side:1}],office:[{kind:`beam`,side:-1}],classroom:[{kind:`pillar`,side:-1}],workshop:[{kind:`beam`,side:1}],kitchen:[{kind:`ledge`}],stagePodium:[{kind:`curtain`,side:-1},{kind:`curtain`,side:1}],corridor:[{kind:`archTop`}],storeInterior:[{kind:`pillar`,side:1}],labGeneric:[],controlRoom:[{kind:`pillar`,side:-1}],courtroomGeneric:[{kind:`pillar`,side:1}],hospitalWard:[],throneHall:[{kind:`pillar`,side:-1},{kind:`pillar`,side:1}],street:[{kind:`curtain`,side:1}],park:[{kind:`foliage`,side:-1}],forest:[{kind:`foliage`,side:-1},{kind:`foliage`,side:1}],mountain:[{kind:`rocks`,side:-1}],desertPlain:[],coastBeach:[{kind:`rocks`,side:1}],farmField:[],skylineWide:[{kind:`curtain`,side:1}],rooftop:[{kind:`ledge`}],roadHighway:[],rooftopNight:[{kind:`ledge`}],ruins:[{kind:`rocks`,side:1}],cave:[{kind:`archTop`}],oceanSurface:[],underwater:[{kind:`kelp`,side:-1},{kind:`kelp`,side:1}],harborDock:[{kind:`beam`,side:1}],skyClouds:[],spacePlanet:[],arcticIce:[{kind:`rocks`,side:-1}],weatherStorm:[{kind:`curtain`,side:-1}],crowdScene:[{kind:`crowdFg`}],marketplace:[{kind:`crowdFg`}],marketStreetDense:[{kind:`crowdFg`}],stadium:[{kind:`crowdFg`}],constructionSite:[{kind:`beam`,side:-1}],openField:[],rollingHills:[{kind:`foliage`,side:-1}],mountainRidge:[{kind:`rocks`,side:1}],valleyStage:[],pineForest:[{kind:`foliage`,side:-1},{kind:`foliage`,side:1}],sandDunes:[],mesaFlats:[{kind:`rocks`,side:-1}],seaCoast:[{kind:`ledge`}],portHarbor:[{kind:`beam`,side:1}],cityscape:[{kind:`curtain`,side:1}],townPlaza:[{kind:`pillar`,side:-1}],interiorRoom:[{kind:`pillar`,side:1}]},[`studioPlain`,`gradientAbstract`,`gridBoard`,`mapStage`,`chartStage`,`timelineBand`,`splitVersus`,`iconField`,`blueprint`,`spotlightDark`].forEach(e=>{TM[e]=[]}),EM={genericRoom:{focal:`left`,bias:1},office:{focal:`right`,bias:-1},classroom:{focal:`right`,bias:-1},workshop:{focal:`left`,bias:1},kitchen:{focal:`center`,bias:0},stagePodium:{focal:`center`,bias:0},corridor:{focal:`center`,bias:0},storeInterior:{focal:`left`,bias:1},labGeneric:{focal:`right`,bias:-1},controlRoom:{focal:`right`,bias:-1},courtroomGeneric:{focal:`left`,bias:1},hospitalWard:{focal:`center`,bias:0},throneHall:{focal:`center`,bias:0},street:{focal:`left`,bias:1},park:{focal:`right`,bias:-1},forest:{focal:`center`,bias:0},mountain:{focal:`right`,bias:1},desertPlain:{focal:`left`,bias:1},coastBeach:{focal:`left`,bias:-1},farmField:{focal:`right`,bias:-1},skylineWide:{focal:`left`,bias:1},rooftop:{focal:`center`,bias:0},roadHighway:{focal:`center`,bias:0},rooftopNight:{focal:`right`,bias:-1},ruins:{focal:`left`,bias:1},cave:{focal:`center`,bias:0},oceanSurface:{focal:`left`,bias:1},underwater:{focal:`center`,bias:0},harborDock:{focal:`left`,bias:1},skyClouds:{focal:`center`,bias:0},spacePlanet:{focal:`right`,bias:-1},arcticIce:{focal:`right`,bias:-1},weatherStorm:{focal:`right`,bias:-1},crowdScene:{focal:`center`,bias:0},marketplace:{focal:`right`,bias:-1},marketStreetDense:{focal:`left`,bias:1},stadium:{focal:`center`,bias:0},constructionSite:{focal:`right`,bias:-1},openField:{focal:`right`,bias:-1},rollingHills:{focal:`right`,bias:-1},mountainRidge:{focal:`left`,bias:1},valleyStage:{focal:`center`,bias:0},pineForest:{focal:`center`,bias:0},sandDunes:{focal:`left`,bias:1},mesaFlats:{focal:`right`,bias:-1},seaCoast:{focal:`left`,bias:1},portHarbor:{focal:`left`,bias:1},cityscape:{focal:`left`,bias:1},townPlaza:{focal:`right`,bias:-1},interiorRoom:{focal:`left`,bias:1}},[`studioPlain`,`gradientAbstract`,`gridBoard`,`mapStage`,`chartStage`,`timelineBand`,`splitVersus`,`iconField`,`blueprint`,`spotlightDark`].forEach(e=>{EM[e]={focal:`center`,bias:0}}),DM=(e,t)=>(TM[e]||[]).map(e=>wM[e.kind]?wM[e.kind](t,e.side||-1):null).filter(Boolean),OM={openField:`field`,rollingHills:`hills`,mountainRidge:`ridge`,valleyStage:`valley`,sandDunes:`dunes`,mesaFlats:`mesa`,seaCoast:`coast`,portHarbor:`harbor`,pineForest:`forest`,cityscape:`city`,townPlaza:`plaza`,interiorRoom:`room`},kM=Object.keys(OM),Object.keys(OM).forEach(e=>{tM[e]=qj(OM[e],e)}),AM=(e,t=.18)=>Z(t,(t,n,r,i)=>{t.fillStyle=e.mid,t.fillRect(-500,-500,n+1e3,i+500)}),jM=e=>Z(.66,(t,n,r,i,a)=>{t.fillStyle=e.near,t.fillRect(-500,i-12*a,n+1e3,12*a)}),MM=(e,t,n)=>Z(0,(r,i,a)=>{let o=n?r.createLinearGradient(0,0,i,a):r.createLinearGradient(0,0,0,a);o.addColorStop(0,e),o.addColorStop(1,t),r.fillStyle=o,r.fillRect(-500,-500,i+1e3,a+1e3)}),NM=(e,t)=>[rM(e.skyBot),AM(e),Z(.3,t(e)),iM(e.ground),jM(e)],PM=(e,t,n,r,i,a,o=0)=>[mM(e),xM(n,.14,`f`+t,{col:e.far,bias:o}),xM(r,.3,`m`+t,{col:e.mid,bias:o}),Z(.46,(t,n,r,i,o,s)=>{t.fillStyle=e.ground,t.fillRect(-500,i,n+1e3,r-i+500),a&&a(e)(t,n,r,i,o,s)}),xM(i,.66,`n`+t,{col:e.near,bias:o})],FM={window:e=>(t,n,r)=>{t.fillStyle=e.far,t.fillRect(n*.34,r*.15,n*.32,r*.34),t.fillStyle=e.skyTop,t.fillRect(n*.36,r*.17,n*.28,r*.3),t.strokeStyle=e.occluder,t.lineWidth=3,t.beginPath(),t.moveTo(n*.5,r*.17),t.lineTo(n*.5,r*.49),t.moveTo(n*.36,r*.32),t.lineTo(n*.64,r*.32),t.stroke()},monitors:e=>(t,n,r)=>{for(let i=0;i<4;i++)t.fillStyle=e.near,t.fillRect(n*(.16+i*.19),r*.24,n*.13,r*.16),t.fillStyle=e.skyTop,t.fillRect(n*(.165+i*.19),r*.25,n*.12,r*.14)},board:e=>(t,n,r)=>{t.fillStyle=`#2f5240`,t.fillRect(n*.22,r*.16,n*.56,r*.34),t.strokeStyle=e.ground,t.lineWidth=6,t.strokeRect(n*.22,r*.16,n*.56,r*.34),t.strokeStyle=`rgba(255,255,255,.4)`,t.lineWidth=2,t.beginPath(),t.moveTo(n*.28,r*.3),t.lineTo(n*.5,r*.3),t.stroke()},pegboard:e=>(t,n,r)=>{t.fillStyle=e.near;for(let e=0;e<6;e++)t.fillRect(n*(.2+e*.1),r*.2,n*.03,r*.22)},counter:e=>(t,n,r,i,a)=>{t.fillStyle=e.near,t.fillRect(-500,i-60*a,n+1e3,14*a),t.fillStyle=e.far;for(let e=0;e<4;e++)t.fillRect(n*(.2+e*.16),r*.2,n*.11,r*.16)},spotlight:e=>(e,t,n,r)=>{let i=e.createRadialGradient(t/2,r-130,20,t/2,r-130,t*.55);i.addColorStop(0,`rgba(255,250,230,.28)`),i.addColorStop(1,`rgba(255,250,230,0)`),e.fillStyle=i,e.fillRect(0,0,t,n)},perspective:e=>(t,n,r)=>{t.strokeStyle=e.near,t.lineWidth=3;for(let e=-3;e<=3;e++)t.beginPath(),t.moveTo(n/2+e*n*.16,0),t.lineTo(n/2+e*n*.04,r),t.stroke()},shelves:e=>(t,n,r,i,a)=>{t.fillStyle=e.near;for(let i=0;i<3;i++){t.fillRect(n*.14,r*(.22+i*.1),n*.72,8*a);for(let o=0;o<8;o++)t.fillStyle=e.far,t.fillRect(n*(.16+o*.088),r*(.22+i*.1)-14*a,n*.05,14*a),t.fillStyle=e.near}},panels:e=>(t,n,r)=>{for(let i=0;i<6;i++)t.fillStyle=i%2?e.far:e.near,t.globalAlpha=.8,t.fillRect(n*(.15+i*.12),r*(.2+i%2*.05),n*.09,r*.14),t.globalAlpha=1},screens:e=>(t,n,r)=>{for(let i=0;i<8;i++)t.fillStyle=[e.skyTop,e.far,e.mid][i%3],t.globalAlpha=.8,t.fillRect(n*(.1+i%4*.21),r*(.18+Math.floor(i/4)*.16),n*.17,r*.12),t.globalAlpha=1},bench:e=>(t,n,r,i,a)=>{t.fillStyle=e.near,t.fillRect(n*.3,i-90*a,n*.4,60*a),t.fillStyle=e.far,t.fillRect(n*.44,r*.2,n*.12,r*.2)},beds:e=>(t,n,r,i,a)=>{for(let r=0;r<3;r++)t.fillStyle=e.near,t.fillRect(n*(.14+r*.28),i-44*a,n*.2,44*a),t.fillStyle=`#e8edf1`,t.fillRect(n*(.14+r*.28),i-44*a,n*.2,16*a)},columns:e=>(t,n,r,i,a)=>{for(let a=0;a<5;a++)t.fillStyle=e.far,t.fillRect(n*(.1+a*.2),r*.1,n*.05,i-r*.1);t.fillStyle=e.near,t.fillRect(n*.42,i-80*a,n*.16,80*a)}},IM=bM,LM=(e,t)=>Z(.16,(n,r,i,a,o,s=0)=>{let c=vk(`cl`+t);n.fillStyle=e.far;for(let e=0;e<6;e++){let t=c()*r+Math.sin(s*.1+e)*10,a=i*(.12+c()*.3),l=(24+c()*26)*o;n.globalAlpha=.85,n.beginPath(),n.arc(t,a,l,0,7),n.arc(t+l,a+4,l*.8,0,7),n.arc(t-l,a+4,l*.8,0,7),n.fill()}n.globalAlpha=1}),RM=(e,t)=>Z(.1,(n,r,i)=>{let a=vk(`st`+t);n.fillStyle=`#fdfbe8`;for(let e=0;e<90;e++)n.globalAlpha=.4+a()*.6,n.fillRect(a()*r,a()*i*.8,2,2);n.globalAlpha=1,n.fillStyle=e.near,n.beginPath(),n.arc(r*.76,i*.3,54,0,7),n.fill(),n.fillStyle=e.far,n.globalAlpha=.5,n.beginPath(),n.arc(r*.72,i*.26,54,0,7),n.fill(),n.globalAlpha=1}),zM=(e,t,n,r,i)=>Z(e,(e,t,a,o,s,c=0)=>{let l=vk(`cw`+n);e.fillStyle=r;for(let n=0;n<22;n++){let r=l()*(t+80)-40,a=(i+l()*20)*s,u=Math.sin(c*1.2+n)*2;e.fillRect(r+u,o-a,15*s,a),e.beginPath(),e.arc(r+u+7.5*s,o-a,9*s,0,7),e.fill()}}),BM=(e,t,n,r)=>Z(e,(e,i,a,o,s)=>{vk(`mk`+n);for(let n=0;n<r;n++){let a=40+i/r*n;e.fillStyle=[t.far,t.mid,t.near][n%3],e.fillRect(a,o-80*s,i/r*.7,18*s),e.fillStyle=t.near,e.fillRect(a+4*s,o-62*s,6*s,62*s),e.fillRect(a+i/r*.7-10*s,o-62*s,6*s,62*s)}}),VM={genericRoom:e=>NM(e,FM.window),office:e=>NM(e,FM.monitors),classroom:e=>NM(e,FM.board),workshop:e=>NM(e,FM.pegboard),kitchen:e=>NM(e,FM.counter),stagePodium:e=>NM(e,FM.spotlight),corridor:e=>NM(e,FM.perspective),storeInterior:e=>NM(e,FM.shelves),labGeneric:e=>NM(e,FM.panels),controlRoom:e=>NM(e,FM.screens),street:(e,t,n)=>PM(e,t,IM.city[0],IM.city[1],[`skyline`,60,90],e=>(e,t,n,r,i)=>{e.strokeStyle=`#e6c34a`,e.lineWidth=3*i,e.setLineDash([20*i,18*i]),e.beginPath(),e.moveTo(-500,r+(n-r)*.5),e.lineTo(t+500,r+(n-r)*.5),e.stroke(),e.setLineDash([])},n),park:(e,t,n)=>PM(e,t,IM.field[0],[`tree`,60,40],[`tree`,46,30],null,n),forest:(e,t,n)=>PM(e,t,[`tree`,70,50],[`tree`,60,44],[`tree`,50,34],null,n),mountain:(e,t,n)=>PM(e,t,IM.ridge[0],IM.ridge[1],IM.ridge[2],null,n),desertPlain:(e,t,n)=>PM(e,t,IM.dunes[0],IM.dunes[1],IM.dunes[2],null,n),coastBeach:(e,t,n)=>PM(e,t,IM.coast[0],[`water`,0,0],IM.coast[2],null,n),farmField:(e,t,n)=>PM(e,t,IM.field[0],IM.field[1],IM.field[2],e=>(t,n,r,i,a)=>{t.strokeStyle=e.near,t.lineWidth=2*a;for(let e=0;e<6;e++)t.beginPath(),t.moveTo(-500,i+e*18*a),t.lineTo(n+500,i+e*18*a),t.stroke()},n),skylineWide:(e,t,n)=>PM(e,t,[`skyline`,90,150],[`skyline`,110,130],[`skyline`,70,100],null,n),rooftop:(e,t,n)=>PM(e,t,[`skyline`,80,140],[`skyline`,100,120],[`skyline`,60,90],null,n),roadHighway:(e,t,n)=>PM(e,t,IM.field[0],[`rolling`,30,40],IM.field[2],e=>(e,t,n,r,i)=>{e.fillStyle=`#5c636e`,e.beginPath(),e.moveTo(t*.38,r),e.lineTo(t*.5,n),e.lineTo(t*.62,r),e.fill(),e.strokeStyle=`#eef2f4`,e.lineWidth=3*i,e.setLineDash([26*i,22*i]),e.beginPath(),e.moveTo(t*.5,r),e.lineTo(t*.5,n),e.stroke(),e.setLineDash([])},n),oceanSurface:(e,t,n)=>[mM(e),xM(IM.coast[0],.14,`f`+t,{col:e.far,bias:n}),yM(.4,e.mid),iM(e.ground)],underwater:(e,t)=>[MM(e.skyTop,e.occluder),Z(.2,(e,n,r)=>{let i=vk(`uw`+t);e.fillStyle=`rgba(255,255,255,.16)`;for(let t=0;t<26;t++)e.beginPath(),e.arc(i()*n,i()*r,2+i()*6,0,7),e.fill()}),iM(e.ground)],skyClouds:(e,t)=>[mM(e),LM(e,t),LM(e,t+`b`)],spacePlanet:(e,t)=>[MM(e.skyTop,e.skyBot),RM(e,t)],arcticIce:(e,t,n)=>PM(e,t,[`jagged`,90,120],[`jagged`,70,80],[`jagged`,50,40],null,n),studioPlain:e=>[MM(e.skyBot,yk(e.skyBot,.92))],gradientAbstract:e=>[MM(e.skyTop,e.mid,!0)],gridBoard:e=>[rM(e.skyBot),Z(.2,(e,t,n,r,i)=>{e.strokeStyle=`rgba(0,0,0,.08)`,e.lineWidth=1;for(let r=0;r<t;r+=40*i)e.beginPath(),e.moveTo(r,0),e.lineTo(r,n),e.stroke();for(let r=0;r<n;r+=40*i)e.beginPath(),e.moveTo(0,r),e.lineTo(t,r),e.stroke()})],mapStage:(e,t)=>[rM(e.skyBot),Z(.2,(n,r,i)=>{let a=vk(`mp`+t);n.fillStyle=e.mid,n.globalAlpha=.8,n.beginPath(),n.moveTo(r*.2,i*.3);for(let e=0;e<10;e++)n.lineTo(r*(.2+a()*.6),i*(.2+a()*.6));n.closePath(),n.fill(),n.globalAlpha=1})],chartStage:e=>[rM(e.skyBot),Z(.2,(t,n,r)=>{t.strokeStyle=e.near,t.lineWidth=2,t.beginPath(),t.moveTo(n*.15,r*.2),t.lineTo(n*.15,r*.8),t.lineTo(n*.85,r*.8),t.stroke()})],timelineBand:e=>[rM(e.skyBot),Z(.3,(t,n,r)=>{t.fillStyle=e.mid,t.globalAlpha=.5,t.fillRect(0,r*.46,n,r*.08),t.globalAlpha=1})],splitVersus:e=>[Z(0,(t,n,r)=>{t.fillStyle=e.skyTop,t.fillRect(0,0,n/2,r),t.fillStyle=e.mid,t.fillRect(n/2,0,n/2,r),t.strokeStyle=e.near,t.lineWidth=3,t.beginPath(),t.moveTo(n/2,0),t.lineTo(n/2,r),t.stroke()})],iconField:(e,t)=>[rM(e.skyBot),Z(.2,(n,r,i)=>{let a=vk(`if`+t);n.fillStyle=e.mid,n.globalAlpha=.4;for(let e=0;e<24;e++)n.beginPath(),n.arc(a()*r,a()*i,10,0,7),n.fill();n.globalAlpha=1})],blueprint:e=>[rM(e.occluder),Z(.2,(e,t,n,r,i)=>{e.strokeStyle=`rgba(255,255,255,.22)`,e.lineWidth=1;for(let r=0;r<t;r+=34*i)e.beginPath(),e.moveTo(r,0),e.lineTo(r,n),e.stroke();for(let r=0;r<n;r+=34*i)e.beginPath(),e.moveTo(0,r),e.lineTo(t,r),e.stroke()})],spotlightDark:e=>[rM(e.occluder),Z(.1,(e,t,n,r)=>{let i=e.createRadialGradient(t/2,r-120,30,t/2,r-120,t*.6);i.addColorStop(0,`rgba(255,255,255,.16)`),i.addColorStop(1,`rgba(255,255,255,0)`),e.fillStyle=i,e.fillRect(0,0,t,n)}),iM(e.near)],crowdScene:(e,t)=>[mM(e),zM(.2,e,t+`a`,e.far,40),iM(e.ground),zM(.55,e,t+`b`,e.near,54)],marketplace:(e,t,n)=>[mM(e),xM([`skyline`,60,80],.14,`f`+t,{col:e.far,bias:n}),iM(e.ground),BM(.5,e,t,5)],constructionSite:(e,t,n)=>[mM(e),xM([`skyline`,70,110],.14,`f`+t,{col:e.far,bias:n}),iM(e.ground),Z(.5,(e,t,n,r,i)=>{e.strokeStyle=`#e0a52e`,e.lineWidth=6*i,e.strokeRect(t*.3,r-200*i,6*i,200*i),e.beginPath(),e.moveTo(t*.3,r-200*i),e.lineTo(t*.58,r-200*i),e.stroke(),e.beginPath(),e.moveTo(t*.55,r-200*i),e.lineTo(t*.55,r-120*i),e.stroke()})],harborDock:(e,t,n)=>[mM(e),xM([`skyline`,60,90],.14,`f`+t,{col:e.far,bias:n}),yM(.4,e.mid),iM(e.ground)],weatherStorm:(e,t)=>[MM(e.occluder,e.mid),Z(.2,(e,n,r)=>{let i=vk(`ws`+t);e.strokeStyle=`rgba(220,230,240,.35)`,e.lineWidth=2;for(let t=0;t<50;t++){let t=i()*n,a=i()*r;e.beginPath(),e.moveTo(t,a),e.lineTo(t-6,a+18),e.stroke()}}),iM(e.near)],stadium:(e,t)=>[mM(e),Z(.14,(t,n,r,i,a)=>{t.fillStyle=e.far;for(let e=0;e<4;e++)t.fillRect(-500,i-(140-e*30)*a,n+1e3,26*a)}),zM(.3,e,t,e.mid,18),iM(e.ground)],courtroomGeneric:e=>NM(e,FM.bench),hospitalWard:e=>NM(e,FM.beds),throneHall:e=>NM(e,FM.columns),cave:e=>[rM(e.occluder),Z(.2,(t,n,r,i)=>{let a=t.createRadialGradient(n/2,i-80,40,n/2,i-80,n*.5);a.addColorStop(0,e.skyBot),a.addColorStop(1,e.occluder),t.fillStyle=a,t.beginPath(),t.ellipse(n/2,i-40,n*.3,r*.4,0,0,7),t.fill()}),iM(e.near)],ruins:(e,t,n)=>[mM(e),xM([`rolling`,50,90],.14,`f`+t,{col:e.far,bias:n}),Z(.4,(n,r,i,a,o)=>{let s=vk(`ru`+t);n.fillStyle=e.mid;for(let e=0;e<5;e++){let t=(60+s()*90)*o;n.fillRect(r*(.12+e*.19),a-t,20*o,t)}}),iM(e.ground)],rooftopNight:(e,t,n)=>PM(e,t,[`skyline`,100,160],[`skyline`,120,140],[`skyline`,70,100],null,n),marketStreetDense:(e,t)=>[mM(e),xM([`skyline`,70,110],.14,`f`+t,{col:e.far}),BM(.3,e,t+`a`,6),iM(e.ground),BM(.58,e,t+`b`,4)]},HM=Object.keys(VM),Object.keys(VM).forEach(e=>{let t=VM[e];tM[e]=(n=7,r=`day`)=>{let i=cM[r]||cM.day,a=(EM[e]||{}).bias||0;return[...t(i,`:`+r+n,a),...DM(e,i)]}}),UM=e=>Object.prototype.hasOwnProperty.call(VM,e)||Object.prototype.hasOwnProperty.call(OM,e),Object.assign(tM,{mapBoard:Sj,warRoomTable:Cj}),WM=[`groundL`,`groundC`,`groundR`,`midL`,`midR`,`skyL`,`skyR`,`skyBand`],GM={plain:[`center.c`],skyDay:[`sky.c`,`ground.c`],skyNight:[`sky.c`,`ground.c`],city:[`ground.c`,`wall.a`,`wall.b`],nature:[`ground.c`,`tree.a`],interior:[`wall.a`,`wall.b`,`wall.c`,`table.c`],abstract:[`center.c`],dioramaDay:WM,dioramaDusk:WM,dioramaNight:WM,dioramaDesert:WM,dioramaArctic:WM,mapBoard:[`center.c`],warRoomTable:[`tableFrontL`,`tableFrontR`,`tableBack`,`tableMap`]},kM.forEach(e=>{GM[e]=WM}),HM.forEach(e=>{GM[e]=WM}),KM={plain:`light`,skyDay:`light`,skyNight:`dark`,city:`light`,nature:`light`,interior:`light`,abstract:`dark`,stagePodium:`dark`,controlRoom:`dark`,underwater:`dark`,spacePlanet:`dark`,blueprint:`dark`,spotlightDark:`dark`,weatherStorm:`dark`,gradientAbstract:`dark`,dioramaDay:`light`,dioramaDusk:`light`,dioramaNight:`dark`,dioramaDesert:`light`,dioramaArctic:`light`,mapBoard:`dark`,warRoomTable:`dark`},qM={"center.c":{x:.5,y:300,z:.5},"ground.c":{x:.5,y:520,z:.5},"table.c":{x:.5,y:470,z:.42},"wall.a":{x:.28,y:180,z:.62},"wall.b":{x:.5,y:168,z:.62},"wall.c":{x:.72,y:180,z:.62},"sky.c":{x:.5,y:120,z:.85},"tree.a":{x:.72,y:430,z:.55},left:{x:.2,y:300,z:.5},right:{x:.8,y:300,z:.5},hover:{x:.5,y:250,z:.5},lowerThird:{x:.5,y:500,z:.5},skyBand:{x:.5,y:110,z:.9},groundL:{x:.22,y:500,z:.45},groundC:{x:.5,y:500,z:.45},groundR:{x:.78,y:500,z:.45},midL:{x:.3,y:430,z:.62},midR:{x:.7,y:430,z:.62},skyL:{x:.28,y:150,z:.82},skyR:{x:.72,y:150,z:.82},tableFrontL:{x:.4,y:560,z:.42},tableFrontR:{x:.6,y:560,z:.42},tableBack:{x:.5,y:470,z:.6},tableMap:{x:.5,y:500,z:.45}},JM=[`center.c`,`ground.c`,`left`,`right`],YM=Object.keys(tM),XM=e=>Object.prototype.hasOwnProperty.call(tM,e)||Wj(e),ZM=e=>e<=.12?`sky`:e<=.3?`back`:e<=.5?`mid`:`near`}));function $M(e,t,n){let r=typeof e==`string`?e:e&&e.type,i=sN[r];return i?i(typeof e==`object`?e:{type:r},t,n):``}var eN,tN,nN,rN,iN,aN,oN,sN,cN=o((()=>{Tk(),eN=640,tN=Math.sin,nN=Math.cos,rN=Math.floor,iN=e=>{let t=tN(e*127.1)*43758.5453;return t-rN(t)},aN=[`rain`,`snow`,`wind`,`fog`,`heatShimmer`,`lightning`],oN=e=>e.intensity===`storm`||typeof e.intensity==`number`&&e.intensity>.6,sN={rain(e,t,n){let r=oN(e),i=r?92:54,a=r?34:24,o=r?1180:820,s=r?9:4,c=``;for(let e=0;e<i;e++){let r=iN(e)*(n+80)-40,i=(iN(e+9)*700+t*o)%700-30,l=r+i/eN*s*3;c+=`M${l.toFixed(1)} ${i.toFixed(1)} l${s} ${a} `}let l=``;for(let e=0;e<(r?16:9);e++){let r=iN(e+40)*n,i=(t*3+iN(e+40)*5)%1,a=i*11;l+=`<circle cx="${r.toFixed(1)}" cy="598" r="${a.toFixed(1)}" fill="none" stroke="rgba(200,220,235,${(.5*(1-i)).toFixed(2)})" stroke-width="1.5"/>`}return`${r?`<rect x="0" y="0" width="${n}" height="${eN}" fill="#20303f" opacity="0.16"/>`:``}<path d="${c}" stroke="rgba(190,214,232,${r?.52:.4})" stroke-width="${r?2:1.5}" stroke-linecap="round"/>${l}`},snow(e,t,n){let r=oN(e)?96:68,i=``;for(let e=0;e<r;e++){let r=(iN(e+3)*680+t*(56+iN(e)*64))%680-20,a=iN(e+7)*n+tN(t*(.6+iN(e))+e)*18,o=1.5+iN(e+5)*2.4;i+=`<circle cx="${a.toFixed(1)}" cy="${r.toFixed(1)}" r="${o.toFixed(1)}" fill="rgba(255,255,255,${(.55+iN(e+1)*.4).toFixed(2)})"/>`}return`<rect x="0" y="0" width="${n}" height="${eN}" fill="#dfeaf2" opacity="0.10"/><rect x="0" y="614" width="${n}" height="26" fill="#f2f7fb" opacity="0.5"/>${i}`},wind(e,t,n){let r=n+140,i=``;for(let e=0;e<28;e++){let n=(iN(e+2)*r+t*(250+iN(e)*180))%r-70,a=110+iN(e+4)*410+tN(t*3+e)*16,o=(t*200+e*63)%360;i+=`<g transform="translate(${n.toFixed(1)} ${a.toFixed(1)}) rotate(${o.toFixed(0)})"><path d="M0 0 q6 -5 12 0 q-6 5 -12 0Z" fill="${[`#c98b52`,`#9bb06a`,`#b9863f`][e%3]}" opacity="0.85"/></g>`}let a=``;for(let e=0;e<6;e++){let r=90+eN/7*e,i=(t*420+e*210)%(n+320)-160;a+=`<path d="M${i.toFixed(1)} ${r.toFixed(1)} q60 -8 140 0" stroke="rgba(232,237,242,0.22)" stroke-width="2" fill="none"/>`}return a+i},fog(e,t,n){let r=tN(t*.3)*34,i=nN(t*.22)*44,a=oN(e)?.4:.28;return`<rect x="0" y="0" width="${n}" height="${eN}" fill="#c9d4dc" opacity="${a.toFixed(2)}"/><ellipse cx="${(n*.35+r).toFixed(1)}" cy="${eN*.72}" rx="${(n*.6).toFixed(0)}" ry="120" fill="#dde5eb" opacity="0.35"/><ellipse cx="${(n*.7+i).toFixed(1)}" cy="${eN*.86}" rx="${(n*.7).toFixed(0)}" ry="150" fill="#eef3f6" opacity="0.4"/>`},heatShimmer(e,t,n){let r=``;for(let e=0;e<9;e++){let i=eN*.48+e*18,a=tN(t*3+e*.7)*7;r+=`<rect x="${a.toFixed(1)}" y="${i.toFixed(0)}" width="${n}" height="11" fill="rgba(255,246,214,0.06)"/>`}return r},lightning(e,t,n){let r=3.2,i=t%r/r;if(i>.16)return``;let a=Y(i<.05?i/.05:1-(i-.05)/.11,0,1),o=``;if(i<.09){let e=n*(.3+iN(rN(t/r))*.4),i=`M${e.toFixed(1)} 0`,s=0,c=e;for(;s<eN*.62;)s+=40+iN(s)*30,c+=(iN(s+1)-.5)*64,i+=` L${c.toFixed(1)} ${s.toFixed(1)}`;o=`<path d="${i}" stroke="#fdfbef" stroke-width="3" fill="none" opacity="${a.toFixed(2)}"/>`}return`<rect x="0" y="0" width="${n}" height="${eN}" fill="#f4f2e2" opacity="${(a*.5).toFixed(2)}"/>${o}`}}}));function lN(e){let t=e>>>0;return function(){t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function uN(e,t,n,r,i){let a=i*i,o=a*i;return .5*(2*t+(-e+n)*i+(2*e-5*t+4*n-r)*a+(-e+3*t-3*n+r)*o)}function dN(e,t,n,r){let i=e[Math.max(0,t-1)][r],a=e[t][r],o=e[Math.min(e.length-1,t+1)][r],s=e[Math.min(e.length-1,t+2)][r];return uN(i,a,o,s,n)}function fN(e,t){let n=[...e].sort((e,t)=>e.time-t.time);if(!n.length)throw Error(`PanMaster requires at least one camera point.`);return n[0].time>0&&n.unshift({...n[0],time:0}),n[n.length-1].time<t&&n.push({...n[n.length-1],time:t}),n.map((e,t)=>({time:e.time,x:e.x??0,y:e.y??0,scale:e.scale??1,rotation:e.rotation??0,subjectId:e.subjectId??null,ease:e.ease||`smoother`,index:t}))}function pN({duration:e=5,subjects:t=[],seed:n=1,viewW:r=1920,viewH:i=1080,worldW:a=2800,worldH:o=1700,style:s=`editorial`,styleCustom:c=null}={}){let l=lN(n),u=r*.22,d=i*.2,f={editorial:{zoom:[1,1.22],rot:[-1.2,1.2],wander:150},calm:{zoom:[1.02,1.14],rot:[-.6,.6],wander:90},energetic:{zoom:[1.04,1.32],rot:[-2.2,2.2],wander:210},dramatic:{zoom:[1.08,1.42],rot:[-2.8,2.8],wander:170}},p=s===`custom`&&c?{zoom:c.zoom,rot:c.rot,wander:c.wander}:f[s]||f.editorial,m=t.length?t:[{id:`center`,x:a/2,y:o/2,importance:1}],h=Math.max(4,Math.min(7,Math.round(e*1.05))),g=[];for(let t=0;t<h;t++){let n=t/(h-1),r=m[t%m.length],i=t%2==0?1:-1,s=Math.sin(n*Math.PI*1.7)*p.wander*i,c=(l()-.5)*p.wander*.55,f=(l()-.5)*p.wander*.38,_=yN(r.x+s+c,u,a-u),v=yN(r.y+Math.cos(n*Math.PI*1.6)*p.wander*.42+f,d,o-d),y=Math.sin(n*Math.PI*2.1)*.5+.5,b=bN(p.zoom[0],p.zoom[1],.28+.72*y)*(r.importance||1),x=bN(p.rot[0],p.rot[1],l());g.push({time:n*e,x:_,y:v,scale:b,rotation:x,subjectId:r.id})}return g[0].scale=Math.min(g[0].scale,1.08),g[g.length-1].rotation*=.25,{duration:e,points:fN(g,e),viewW:r,viewH:i,worldW:a,worldH:o,seed:n,style:s}}function mN(e,t){let n=e.points,r=e.duration,i=yN(t,0,r),a=0;for(;a<n.length-2&&i>n[a+1].time;)a++;let o=n[a],s=n[Math.min(a+1,n.length-1)],c=Math.max(1e-4,s.time-o.time),l=yN((i-o.time)/c);return l=o.ease===`linear`?l:o.ease===`smooth`?xN(l):SN(l),{x:dN(n,a,l,`x`),y:dN(n,a,l,`y`),scale:dN(n,a,l,`scale`),rotation:dN(n,a,l,`rotation`),subjectId:l<.5?o.subjectId:s.subjectId,progress:i/r}}function hN(e,t=1,n=1920,r=1080){let i=yN(t,0,1.6),a=1+(e.scale-1)*i,o=bN(n/2,e.x,i),s=bN(r/2,e.y,i),c=e.rotation*i*.55;return`translate(${n/2} ${r/2}) rotate(${-c}) scale(${a}) translate(${-o} ${-s})`}function gN({duration:e,points:t=[],viewW:n=1920,viewH:r=1080,worldW:i=2800,worldH:a=1700,zoomMin:o=CN,zoomMax:s=3}){let c=[];for(let e of t){let t=yN(e.zoom==null?e.scale==null?1:e.scale:e.zoom,o,s),n={time:e.time,x:e.x,y:e.y,scale:t,rotation:e.rotation||0,ease:e.ease||`smoother`,subjectId:e.subjectId??null};c.push(n),e.hold&&c.push({...n,time:e.time+e.hold})}let l=e??Math.max(...c.map(e=>e.time),.001);return{duration:l,points:fN(c,l),viewW:n,viewH:r,worldW:i,worldH:a,mode:`manual`}}function _N(e,t=[]){let n=pN(e),r=n.points.map(e=>({time:e.time,x:e.x,y:e.y,zoom:e.scale,rotation:e.rotation,ease:e.ease,subjectId:e.subjectId}));return t.forEach(e=>{e.index!=null&&r[e.index]&&Object.assign(r[e.index],e)}),gN({duration:n.duration,points:r,viewW:n.viewW,viewH:n.viewH,worldW:n.worldW,worldH:n.worldH})}function vN(e,t={}){let n=t.worldW==null?e.worldW||2800:t.worldW,r=t.worldH==null?e.worldH||1700:t.worldH,i=t.viewW==null?e.viewW||1920:t.viewW,a=t.viewH==null?e.viewH||1080:t.viewH,o=e.duration==null?t.duration:e.duration;return e.mode===`manual`?gN({duration:o,points:e.points||[],viewW:i,viewH:a,worldW:n,worldH:r,zoomMin:e.zoomMin,zoomMax:e.zoomMax}):e.mode===`hybrid`?_N({duration:o,subjects:e.subjects||t.subjects||[],seed:e.seed||1,viewW:i,viewH:a,worldW:n,worldH:r,style:e.style||`editorial`,styleCustom:e.styleCustom},e.edits||[]):pN({duration:o,subjects:e.subjects||t.subjects||[],seed:e.seed||1,viewW:i,viewH:a,worldW:n,worldH:r,style:e.style||`editorial`,styleCustom:e.styleCustom})}var yN,bN,xN,SN,CN,wN=o((()=>{yN=(e,t=0,n=1)=>Math.max(t,Math.min(n,e)),bN=(e,t,n)=>e+(t-e)*n,xN=e=>e*e*(3-2*e),SN=e=>e*e*e*(e*(e*6-15)+10),CN=.5}));function TN(e){let t=e.type,n=WN.includes(t)?null:e.swapWindow||YN[t]||[.45,.55];return{type:t,durationMs:e.durationMs==null?1200:e.durationMs,ease:GN.includes(e.ease)?e.ease:`smoother`,direction:e.direction||XN[t]||`L2R`,colorMode:e.colorMode||`bridge`,colors:e.colors||[],swapWindow:n,carrySubject:e.carrySubject||null,params:{...JN[t]||{},...e.params||{}}}}function EN(e,t,n=0){let r=t.bridge&&t.bridge[0]||`#141c24`,i=t.bridge&&t.bridge[1]||`#0d1220`;return e.colorMode===`custom`&&e.colors.length?e.colors[IN(n,e.colors.length-1)]:e.colorMode===`token`?`#0d1220`:e.colorMode===`incoming`?i:bk(r,i,.5)}function DN(e,t,n){let r=t>0?Y(e/t,0,1):1,i=n<1?Y((e-n)/(1-n),0,1):0;return IN(r,1-i)}function ON(e,t,n,r,i,a=1){return`<rect x="${e.toFixed(1)}" y="${t.toFixed(1)}" width="${n.toFixed(1)}" height="${r.toFixed(1)}" fill="${i}" opacity="${a}"/>`}function kN(e,t,n,r){if(!e.carrySubject)return null;let i=n.subjectFrom||{x:r*.5,y:jN*.6},a=n.subjectTo||{x:r*.5,y:jN*.6};return{x:xk(i.x,a.x,t),y:xk(i.y,a.y,t)}}function AN(e,t,n={}){let r=TN(e),i=n.VBW||1138,a=Y(t,0,1),o=qN[r.ease](a),s=ZN[r.type],c=s?s(r,o,a,n,i):{svg:``,alpha:0},l,u,d=1,f=1,p=null,m=null,h=null,g=null;if(r.swapWindow)h=r.swapWindow[0],l=a<h,u=a>=h;else if(r.type===`fade`)l=!0,u=!0,d=1-o,f=o;else{l=!0,u=!0;let e=r.direction===`R2L`||r.direction===`B2T`?-1:1,t=(tP[r.type]||tP.carryTravel)(o,e,i,jN,r.params,n.subject);p=t.fromT,m=t.toT,g={blur:t.blur||0,flip:!!t.flip,split:t.split,axis:t.axis,over:!!t.over,shadow:!!t.shadow,dir:e},t.flip&&(l=a<.5,u=a>=.5)}return{resolved:r,cover:c.svg,coverAlpha:c.alpha,fromShown:l,toShown:u,fromOpacity:d,toOpacity:f,fromTransform:p,toTransform:m,motion:g,swapWindow:r.swapWindow,swapAt:h,subject:kN(r,o,n,i)}}var jN,MN,NN,PN,FN,IN,LN,RN,zN,BN,VN,HN,UN,WN,GN,KN,qN,JN,YN,XN,ZN,QN,$N,eP,tP,nP=o((()=>{Tk(),jN=640,MN=Math.sin,NN=Math.cos,PN=Math.PI,FN=Math.hypot,IN=Math.min,LN=Math.max,RN=.1,zN=[`fade`,`irisObject`,`strokeSweep`,`slabWipe`,`curtainFall`,`lightWash`,`bandWipe`,`carryTravel`],BN=[`blindsFlip`,`checkerFlip`,`inkBlot`,`smokeConceal`,`particleStorm`,`paperTear`,`shapeStampede`,`typeMask`,`silhouetteWalkWipe`,`pushOff`,`slideOver`,`splitBarn`,`whipPan`,`spinCard`,`zoomThrough`,`pullBackReveal`,`elevatorRise`],VN=[`flashImpact`,`dipToColor`,`silhouettePass`,`dayNightSweep`,`spotlightShift`,`matchMorph`,`pixelMosaic`,`lineArtRebuild`,`stackShuffle`,`ripplePortal`,`doorPass`,`waveCrash`,`pageFlip`,`lightSpeedStreak`,`glitchCut`],HN=[...zN,...BN,...VN],UN=[`carryTravel`,`pushOff`,`slideOver`,`splitBarn`,`whipPan`,`spinCard`,`zoomThrough`,`pullBackReveal`,`elevatorRise`,`stackShuffle`],WN=[`fade`,...UN],GN=[`linear`,`smooth`,`smoother`],KN=e=>HN.includes(e),qN={linear:e=>e,smooth:e=>e*e*(3-2*e),smoother:e=>e*e*e*(e*(e*6-15)+10)},JN={fade:{mode:`direct`},irisObject:{shape:`circle`,origin:`center`,grow:`out`},strokeSweep:{pathPreset:`arc`,glow:!0},slabWipe:{edge:`straight`},curtainFall:{pairedPaletteShift:!0},lightWash:{mode:`radial`,origin:`center`},bandWipe:{bands:3,staggerPct:.08,slantDeg:14,edgeProfile:`straight`},carryTravel:{vector:`L2R`,ms:1200},blindsFlip:{slats:8,axis:`h`},checkerFlip:{grid:6,order:`sweep`},inkBlot:{blobs:3,wobble:.25},smokeConceal:{density:1},particleStorm:{particleType:`confetti`},paperTear:{tearJaggedness:22},shapeStampede:{iconRef:`coin`,count:40},typeMask:{text:`NEXT`},silhouetteWalkWipe:{castRef:null,scale:1,action:`walk`},pushOff:{},slideOver:{shadowEdge:!0},splitBarn:{axis:`v`},whipPan:{blurPx:9},spinCard:{axis:`y`,perspectiveFake:!0},zoomThrough:{targetElement:null,overshoot:1},pullBackReveal:{frameElement:null},elevatorRise:{},flashImpact:{tint:`#ffffff`},dipToColor:{color:null,holdMs:200},silhouettePass:{holdMs:200},dayNightSweep:{},spotlightShift:{origin:`subject`},matchMorph:{fromRef:null,toRef:null},pixelMosaic:{blockPx:48,order:`random`},lineArtRebuild:{strokeColor:`#243038`},stackShuffle:{cardShadow:!0},ripplePortal:{origin:`center`,rings:5},doorPass:{portalElement:null},waveCrash:{foam:!0},pageFlip:{corner:`tr`},lightSpeedStreak:{streakColor:`#bcd4ff`},glitchCut:{intensity:1}},YN={irisObject:[.42,.58],strokeSweep:[.44,.56],slabWipe:[.46,.56],curtainFall:[.46,.56],lightWash:[.42,.58],bandWipe:[.48,.62]},XN={curtainFall:`T2B`,bandWipe:`L2R`,slabWipe:`L2R`,carryTravel:`L2R`},ZN={fade(e,t,n,r,i){if(e.params.mode===`toColor`){let t=MN(Y(n,0,1)*PN),a=i*RN;return{svg:ON(-a,-64,i+2*a,768,e.colors[0]||EN(e,r),t),alpha:t}}return{svg:``,alpha:0}},irisObject(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=DN(n,a,o),c=EN(e,r),l=e.params.origin===`subject`&&r.subject?r.subject:{x:i/2,y:jN/2},u=FN(i,jN)*.5*1.2,d=(e.params.grow===`in`?1-s:s)*u;if(e.params.shape!==`circle`){let e=d/120;return{svg:`<path transform="translate(${l.x.toFixed(1)} ${l.y.toFixed(1)}) scale(${e.toFixed(3)})" d="M0 -120 C70 -120 120 -60 120 10 C120 80 60 120 0 120 C-60 120 -120 80 -120 10 C-120 -60 -70 -120 0 -120 Z" fill="${c}"/>`,alpha:s}}return{svg:`<circle cx="${l.x.toFixed(1)}" cy="${l.y.toFixed(1)}" r="${d.toFixed(1)}" fill="${c}"/>`,alpha:s}},strokeSweep(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=DN(n,a,o),c=EN(e,r),l=s*FN(i,jN)*1.15,u=e.params.pathPreset,d=u===`S`?`M -60 ${jN*.2} C ${i*.4} 0, ${i*.6} ${jN} , ${i+60} ${jN*.8}`:u===`bolt`?`M -60 ${jN*.1} L ${i*.45} ${jN*.5} L ${i*.35} ${jN*.55} L ${i+60} ${jN*.95}`:u===`wave`?`M -60 ${jN/2} Q ${i*.25} ${jN*.1}, ${i*.5} ${jN/2} T ${i+60} ${jN/2}`:`M -60 ${jN*.85} Q ${i/2} -224, ${i+60} ${jN*.85}`;return{svg:(e.params.glow?`<path d="${d}" fill="none" stroke="${c}" stroke-width="${(l*1.25).toFixed(1)}" stroke-linecap="round" opacity="0.35"/>`:``)+`<path d="${d}" fill="none" stroke="${c}" stroke-width="${l.toFixed(1)}" stroke-linecap="round"/>`,alpha:s}},slabWipe(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=EN(e,r),u=e.direction!==`T2B`&&e.direction!==`B2T`,d=e.direction===`R2L`||e.direction===`B2T`,f=s,p=c,m=d?1-f:p,h=d?1-p:f,g=e.params.edge===`rounded`?26:0,_=i*RN,v=f-p;if(u){let e=m<=1e-6?-_:m*i,t=h>=1-1e-6?i+_:h*i;return{svg:`<rect x="${e.toFixed(1)}" y="${(-64).toFixed(1)}" width="${(t-e).toFixed(1)}" height="${768 .toFixed(1)}" rx="${g}" fill="${l}"/>`,alpha:v}}let y=m<=1e-6?-64:m*jN,b=h>=1-1e-6?704:h*jN;return{svg:`<rect x="${(-_).toFixed(1)}" y="${y.toFixed(1)}" width="${(i+2*_).toFixed(1)}" height="${(b-y).toFixed(1)}" rx="${g}" fill="${l}"/>`,alpha:v}},curtainFall(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=e.direction===`B2T`,u=e.params.pairedPaletteShift?bk(EN(e,r),`#0a1020`,.4):EN(e,r),d=s,f=c,p=l?1-d:f,m=l?1-f:d,h=i*RN,g=p<=1e-6?-64:p*jN,_=m>=1-1e-6?704:m*jN;return{svg:`<rect x="${(-h).toFixed(1)}" y="${IN(g,_).toFixed(1)}" width="${(i+2*h).toFixed(1)}" height="${Math.abs(_-g).toFixed(1)}" fill="${u}"/>`,alpha:s-c}},lightWash(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=DN(n,a,o),c=e.colors[0]||EN(e,r),l=i*RN;if(e.params.mode===`linear`)return{svg:ON(-l,-64,i+2*l,768,c,s),alpha:s};let u=e.params.origin===`subject`&&r.subject?r.subject:{x:i/2,y:jN/2},d=FN(i,jN)*(.34+.75*s);return{svg:`<defs><radialGradient id="lw" cx="${(u.x/i).toFixed(3)}" cy="${(u.y/jN).toFixed(3)}" r="0.8"><stop offset="0" stop-color="${c}" stop-opacity="${s.toFixed(3)}"/><stop offset="1" stop-color="${c}" stop-opacity="${(s*s).toFixed(3)}"/></radialGradient></defs><circle cx="${u.x.toFixed(1)}" cy="${u.y.toFixed(1)}" r="${d.toFixed(1)}" fill="url(#lw)"/>${ON(-l,-64,i+2*l,768,c,s*s*.9)}`,alpha:s}},bandWipe(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=Y(e.params.bands|0||3,2,5),c=e.params.staggerPct||.08,l=(e.params.slantDeg||0)*PN/180,u=Math.tan(l)*jN,d=o<1?Y((n-o)/(1-o),0,1):0,f=r.bridge&&r.bridge[0]||`#141c24`,p=r.bridge&&r.bridge[1]||`#0d1220`,m=i*RN,h=768/s,g=``,_=1;for(let t=0;t<s;t++){let r=t*c,o=a-r>0?Y((n-r)/(a-r),0,1):1,l=IN(o,1-d);_=IN(_,l);let v=e.direction===`R2L`?-1:1,y=l*(i+2*m+Math.abs(u)),b=bk(f,p,s>1?t/(s-1):.5),x=v>0?-m-Math.abs(u):i+m-y+Math.abs(u),S=-64+t*h;g+=`<path d="M ${x.toFixed(1)} ${S.toFixed(1)} l ${y.toFixed(1)} 0 l ${u.toFixed(1)} ${h.toFixed(1)} l ${(-y).toFixed(1)} 0 Z" fill="${b}"/>`}return{svg:g,alpha:_}},carryTravel(e,t,n,r,i){return{svg:``,alpha:0}}},QN=e=>{let t=MN(e*91.7)*43758.5453;return t-Math.floor(t)},$N=(e,t,n,r,i,a=1,o=0)=>`<rect x="${e.toFixed(1)}" y="${t.toFixed(1)}" width="${n.toFixed(1)}" height="${r.toFixed(1)}" rx="${o}" fill="${i}" opacity="${a}"/>`,Object.assign(ZN,{blindsFlip(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=Y(e.params.slats||8,4,16),c=(e.params.axis||`h`)!==`v`,l=i*RN,u=``,d=(c?768:i+2*l)/s;for(let e=0;e<s;e++){let t=d*a;u+=c?$N(-l,-64+e*d+d/2-t/2,i+2*l,t,o):$N(-l+e*d+d/2-t/2,-64,t,768,o)}return{svg:u,alpha:a}},checkerFlip(e,t,n,r,i){let a=EN(e,r),o=Y(e.params.grid||6,3,10),s=i/o,c=jN/o,l=DN(n,e.swapWindow[0],e.swapWindow[1]),u=``,d=1;for(let t=0;t<o;t++)for(let n=0;n<o;n++){let r=e.params.order===`spiral`?(Math.abs(n-(o-1)/2)+Math.abs(t-(o-1)/2))/o:e.params.order===`random`?QN(n*7+t*13+1):(n+t)/(2*o),i=Y(l*1.7-r*.7,0,1);d=IN(d,i),u+=$N(n*s+s/2-s*i/2,t*c+c/2-c*i/2,s*i,c*i,a)}return{svg:u,alpha:d}},inkBlot(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=Y(e.params.blobs||3,1,6),c=e.params.wobble==null?.25:e.params.wobble,l=$N(-i*RN,-640*RN,i*1.2,jN*1.2,o,a*a*.5);for(let e=0;e<s;e++){let t=i*(.2+.6*QN(e+1)),n=jN*(.25+.5*QN(e+5)),r=a*FN(i,jN)*.5,s=`M ${(t+r).toFixed(1)} ${n.toFixed(1)}`;for(let i=1;i<=12;i++){let a=i/12*2*PN,o=r*(1+c*(QN(e*20+i)-.5));s+=` L ${(t+NN(a)*o).toFixed(1)} ${(n+MN(a)*o).toFixed(1)}`}l+=`<path d="${s} Z" fill="${o}"/>`}return{svg:l,alpha:a}},smokeConceal(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=``;for(let e=0;e<14;e++){let t=i*QN(e+2),n=jN*QN(e+8),r=a*FN(i,jN)*(.24+.14*QN(e));s+=`<circle cx="${t.toFixed(1)}" cy="${n.toFixed(1)}" r="${r.toFixed(1)}" fill="${o}" opacity="${(.5+.5*a).toFixed(2)}"/>`}return{svg:s+$N(-i*RN,-640*RN,i*1.2,jN*1.2,o,a*a),alpha:a}},particleStorm(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=Math.round(120*a),s=e.params.particleType===`snow`?[`#fff`,`#e8eef4`]:e.params.particleType===`debris`?[`#6b5a44`,`#413424`]:[EN(e,r),`#f2b134`,`#ff6b5e`,`#5b6ce0`],c=$N(-i*RN,-640*RN,i*1.2,jN*1.2,EN(e,r),a*a*.85);for(let e=0;e<o;e++){let t=i*QN(e+1),n=jN*QN(e*3+2),r=4+5*QN(e);c+=$N(t,n,r,r,s[e%s.length],.9,2)}return{svg:c,alpha:a}},paperTear(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=EN(e,r),u=e.params.tearJaggedness==null?22:e.params.tearJaggedness,d=e.direction===`R2L`,f=(d?1-s:s)*i,p=d?`M ${i+i*RN} ${-640*RN} L ${f} ${-640*RN}`:`M ${-i*RN} ${-640*RN} L ${f} ${-640*RN}`;for(let e=0;e<=jN;e+=24)p+=` L ${(f+(QN(e)-.5)*u).toFixed(1)} ${e}`;return p+=d?` L ${i+i*RN} 704 Z`:` L ${-i*RN} 704 Z`,{svg:`<path d="${p}" fill="${l}"/>`,alpha:s-c}},shapeStampede(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=e.params.iconRef||`coin`,c=Math.round((e.params.count||40)*a),l=$N(-i*RN,-640*RN,i*1.2,jN*1.2,o,a*a*.7);for(let e=0;e<c;e++){let t=i*QN(e+1),n=jN*QN(e*5+3),r=14+8*QN(e);l+=s===`star`?`<path transform="translate(${t.toFixed(0)} ${n.toFixed(0)})" d="M0 -${r} L${r*.3} -${r*.3} L${r} 0 L${r*.3} ${r*.3} L0 ${r} L-${r*.3} ${r*.3} L-${r} 0 L-${r*.3} -${r*.3} Z" fill="#f2b134"/>`:`<circle cx="${t.toFixed(0)}" cy="${n.toFixed(0)}" r="${r.toFixed(0)}" fill="#f2b134" stroke="${eP(o)}" stroke-width="2"/>`}return{svg:l,alpha:a}},typeMask(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=e.params.text||`NEXT`,c=e.direction===`R2L`?-1:1,l=i/2+c*(1-a)*i*.7;return{svg:$N(-i*RN,-640*RN,i*1.2,jN*1.2,o,a*a)+`<text x="${l.toFixed(1)}" y="${(jN*.62).toFixed(0)}" text-anchor="middle" font-family="Nunito,system-ui" font-weight="900" font-size="${(jN*.7*(.6+.4*a)).toFixed(0)}" fill="${o}">${s}</text>`,alpha:a}},silhouetteWalkWipe(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=EN(e,r),u=(e.direction===`R2L`?-1:1)>0?-i*.4+s*i*1.4:i*1.4-s*i*1.4,d=i*.9;return{svg:(s>=1&&c<1?$N(-i*RN,-640*RN,i*1.2,jN*1.2,l,1-c):``)+`<g transform="translate(${u.toFixed(1)} 0)"><ellipse cx="0" cy="${jN*.28}" rx="${d*.28}" ry="${d*.3}" fill="${l}"/><rect x="${-d*.32}" y="${jN*.42}" width="${d*.64}" height="${jN*.7}" rx="${d*.2}" fill="${l}"/></g>`,alpha:LN(DN(n,a,o),s*.7)}},flashImpact(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]);return{svg:$N(-i*RN,-640*RN,i*1.2,jN*1.2,e.params.tint||`#ffffff`,a**.5),alpha:a}},dipToColor(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]);return{svg:$N(-i*RN,-640*RN,i*1.2,jN*1.2,e.params.color||e.colors[0]||EN(e,r),a),alpha:a}},silhouettePass(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]);return{svg:$N(-i*RN,-640*RN,i*1.2,jN*1.2,`#1b2230`,a),alpha:a}},dayNightSweep(e,t,n,r,i){let a=EN(e,r),o=e.swapWindow[0],s=e.swapWindow[1],c=o>0?Y(n/o,0,1):1,l=s<1?Y((n-s)/(1-s),0,1):0,u=l*i,d=c*i;return{svg:`<defs><linearGradient id="dns"><stop offset="0" stop-color="${a}"/><stop offset="1" stop-color="${bk(a,`#0a1020`,.5)}"/></linearGradient></defs>`+$N(u,-640*RN,d-u,jN*1.2,`url(#dns)`),alpha:c-l}},spotlightShift(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=e.params.origin===`subject`&&r.subject?r.subject:{x:i/2,y:jN*.45},s=(1-a)*FN(i,jN)*.4+30;return{svg:`<defs><radialGradient id="sp" cx="${(o.x/i).toFixed(3)}" cy="${(o.y/jN).toFixed(3)}" r="${(s/i+.001).toFixed(3)}" gradientUnits="userSpaceOnUse" fx="${o.x}" fy="${o.y}" r="${s}"><stop offset="0.7" stop-color="#000" stop-opacity="0"/><stop offset="1" stop-color="#050810" stop-opacity="${(.4+.6*a).toFixed(2)}"/></radialGradient></defs><rect x="${-i*RN}" y="${-640*RN}" width="${i*1.2}" height="${jN*1.2}" fill="#050810" opacity="${(a*a).toFixed(2)}"/>`,alpha:a}},matchMorph(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=i/2,c=jN/2,l=40+a*FN(i,jN)*.55,u=a>.5?l*(1-(a-.5)*1.2):l;return{svg:`<rect x="${(s-l).toFixed(1)}" y="${(c-l).toFixed(1)}" width="${(2*l).toFixed(1)}" height="${(2*l).toFixed(1)}" rx="${Math.max(0,u).toFixed(1)}" fill="${o}"/>`,alpha:a}},pixelMosaic(e,t,n,r,i){let a=EN(e,r),o=Y(e.params.blockPx||48,20,120),s=Math.ceil(i/o),c=Math.ceil(jN/o),l=DN(n,e.swapWindow[0],e.swapWindow[1]),u=``,d=1;for(let e=0;e<c;e++)for(let t=0;t<s;t++){let n=QN(t*3+e*7+1),r=+(l*1.5-n*.5>=.5);d=IN(d,l>=.99?1:r),r&&(u+=$N(t*o,e*o,o+1,o+1,a))}return{svg:u,alpha:l}},lineArtRebuild(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=e.params.strokeColor||`#243038`,c=$N(-i*RN,-640*RN,i*1.2,jN*1.2,o,a*a);for(let e=0;e<8;e++){let t=jN*(e+.5)/8,n=i*a;c+=`<line x1="0" y1="${t.toFixed(1)}" x2="${n.toFixed(1)}" y2="${t.toFixed(1)}" stroke="${s}" stroke-width="2" opacity="${(.5+.5*(1-a)).toFixed(2)}"/>`}return{svg:c,alpha:a}},ripplePortal(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=e.params.origin&&r.subject?r.subject:{x:i/2,y:jN/2},c=Y(e.params.rings||5,2,8),l=`<circle cx="${s.x}" cy="${s.y}" r="${(a*FN(i,jN)*.6).toFixed(1)}" fill="${o}"/>`;for(let e=0;e<c;e++){let t=a*FN(i,jN)*.6+e*26;l+=`<circle cx="${s.x}" cy="${s.y}" r="${t.toFixed(1)}" fill="none" stroke="${bk(o,`#fff`,.3)}" stroke-width="3" opacity="${(.6*(1-a)).toFixed(2)}"/>`}return{svg:l,alpha:a}},doorPass(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=EN(e,r);i/2*(1-c)*s;let u=i/2*c;return{svg:$N(-i*RN,-640*RN,i/2*s+i*RN-u,jN*1.2,l)+$N(i/2+u,-640*RN,i/2*s+i*RN-u,jN*1.2,l),alpha:s-c}},waveCrash(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=bk(EN(e,r),`#2b6cb0`,.5),u=s*760-60,d=c*760-60,f=`M ${-i*RN} ${d.toFixed(1)}`;for(let e=0;e<=i;e+=40)f+=` L ${e} ${(u+MN(e/i*6+n*6)*26).toFixed(1)}`;f+=` L ${i+i*RN} ${d.toFixed(1)} Z`;let p=e.params.foam===!1?``:`<path d="${f.replace(/Z$/,``)}" fill="none" stroke="#eaf4ff" stroke-width="6" opacity="0.6"/>`;return{svg:`<path d="${f}" fill="${l}"/>${p}`,alpha:s-c}},pageFlip(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=a*(i+jN);return{svg:`<path d="M ${i} 0 L ${(i-s).toFixed(1)} 0 L ${i} ${s.toFixed(1)} Z" fill="${o}"/><path d="M ${(i-s).toFixed(1)} 0 L ${i} ${s.toFixed(1)} L ${(i-s*.7).toFixed(1)} ${(s*.7).toFixed(1)} Z" fill="${bk(o,`#fff`,.25)}"/>`,alpha:a}},lightSpeedStreak(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=e.params.streakColor||`#bcd4ff`,s=i/2,c=jN/2,l=$N(-i*RN,-640*RN,i*1.2,jN*1.2,`#050813`,a*a);for(let e=0;e<40;e++){let t=QN(e+1)*2*PN,n=20+QN(e)*40,r=n+a*FN(i,jN)*.7;l+=`<line x1="${(s+NN(t)*n).toFixed(1)}" y1="${(c+MN(t)*n).toFixed(1)}" x2="${(s+NN(t)*r).toFixed(1)}" y2="${(c+MN(t)*r).toFixed(1)}" stroke="${o}" stroke-width="2" opacity="${(.4+.6*a).toFixed(2)}"/>`}return{svg:l,alpha:a}},glitchCut(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=e.params.intensity||1,s=(QN(Math.floor(n*30))-.5)*20*o,c=$N(-i*RN,-640*RN,i*1.2,jN*1.2,EN(e,r),a*(.4+.6*QN(Math.floor(n*40))));for(let e=0;e<6;e++){let t=jN*QN(e*3+1),n=8+30*QN(e);c+=$N(s,t,i,n,e%2?`#ff2d6a`:`#2dffea`,.35*a)}return{svg:c,alpha:a}}}),eP=e=>bk(e,`#000`,.4),tP={carryTravel:(e,t,n,r)=>({fromT:`translate(${(-t*e*n).toFixed(1)} 0)`,toT:`translate(${(t*(1-e)*n).toFixed(1)} 0)`}),pushOff:(e,t,n,r)=>({fromT:`translate(${(-t*e*n).toFixed(1)} 0)`,toT:`translate(${(t*(1-e)*n).toFixed(1)} 0)`}),slideOver:(e,t,n,r)=>({fromT:``,toT:`translate(${(t*(1-e)*n).toFixed(1)} 0)`,over:!0}),whipPan:(e,t,n,r,i)=>({fromT:`translate(${(-t*e*n*1.25).toFixed(1)} 0)`,toT:`translate(${(t*(1-e)*n*1.25).toFixed(1)} 0)`,blur:MN(e*PN)*(i.blurPx||9)}),spinCard:(e,t,n,r)=>{let i=NN(e*PN);return{fromT:`translate(${n/2} ${r/2}) scale(${e<.5?Math.max(.001,i).toFixed(3):.001} 1) translate(${-n/2} ${-r/2})`,toT:`translate(${n/2} ${r/2}) scale(${e>=.5?Math.max(.001,-i).toFixed(3):.001} 1) translate(${-n/2} ${-r/2})`,flip:!0}},zoomThrough:(e,t,n,r,i,a)=>{let o=a?a.x:n/2,s=a?a.y:r*.42;return{fromT:`translate(${o} ${s}) scale(${(1+e*5).toFixed(3)}) translate(${-o} ${-s})`,toT:`translate(${n/2} ${r/2}) scale(${(.15+.85*e).toFixed(3)}) translate(${-n/2} ${-r/2})`,flip:!0}},pullBackReveal:(e,t,n,r)=>({fromT:`translate(${n/2} ${r/2}) scale(${(1-e*.86).toFixed(3)}) translate(${-n/2} ${-r/2})`,toT:`translate(${n/2} ${r/2}) scale(${(1.7-.7*e).toFixed(3)}) translate(${-n/2} ${-r/2})`,flip:!0}),elevatorRise:(e,t,n,r)=>({fromT:`translate(0 ${(t*e*r).toFixed(1)})`,toT:`translate(0 ${(t*(1-e)*r-t*r).toFixed(1)})`}),stackShuffle:(e,t,n,r,i)=>({fromT:`translate(${(t*e*n).toFixed(1)} ${(e*40).toFixed(1)}) rotate(${(t*e*4).toFixed(1)} ${n/2} 200)`,toT:``,shadow:i.cardShadow!==!1}),splitBarn:(e,t,n,r,i)=>({split:e,axis:i.axis||`v`})}}));function rP(e){e=Y(e,0,1);for(let t=0;t<aP.length-1;t++)if(e<=aP[t+1]){let n=(e-aP[t])/(aP[t+1]-aP[t]);return xk(oP[t],oP[t+1],n)}return oP[oP.length-1]}function iP(e,t){return t===`2d`?{scale:1,yShift:0,opacity:1,blur:0,w:rP(.5)}:{scale:sP(e),yShift:cP(e),opacity:lP(e),blur:uP(e),w:rP(e)}}var aP,oP,sP,cP,lP,uP,dP=o((()=>{Tk(),aP=[0,.25,.5,.75,1],oP=[1.45,1.28,1,.24,.15],sP=e=>1+(.5-e)*.72,cP=e=>-(e-.5)*165,lP=e=>1-Y(e-.42,0,.58)*.78,uP=e=>Y(e-.55,0,.45)*6}));function fP(e,t){let n=t/2/Math.max(.001,e.zoom);return n>=t/2?{...e,cx:t/2}:{...e,cx:Y(e.cx,n,t-n)}}function pP(e,t,n,r,i){let a=i*i,o=a*i;return .5*(2*t+(-e+n)*i+(2*e-5*t+4*n-r)*a+(-e+3*t-3*n+r)*o)}function mP(e,t){if(e.length===1)return e[0];let n=Y(Math.floor(t),0,e.length-2),r=t-n,i=e[Math.max(0,n-1)],a=e[n],o=e[n+1],s=e[Math.min(e.length-1,n+2)];return pP(i,a,o,s,r)}function hP(e,t,n,r,i,a,o){let s=EP[o]||EP.editorial,c=t.zoom;if(e===`locked`)return{...t};if(e===`drift`)return{cx:t.cx+40*s.amp*Math.sin(n*.25*s.speed),cy:t.cy,zoom:c};let l=vk(i+`:cam`),u=a&&a.length?a:[{rigX:t.cx}],d=[t.cx],f=[c],p=Math.max(3,Math.min(6,u.length+2));for(let e=0;e<p;e++){let e=u[Math.floor(l()*u.length)];d.push(t.cx+(e.rigX-t.cx)*s.amp+(l()-.5)*60*s.amp),f.push(c+l()*.08*s.amp)}d.push(t.cx),f.push(c);let m=n/Math.max(.001,r)*(d.length-1)*s.speed%(d.length-1);return{cx:mP(d,m),cy:t.cy-6,zoom:mP(f,m)}}function gP(e,t){let n=TP(t.VBW,t.frame),r=(e||[]).find(e=>e.idle)||{idle:`focusFlow`},i=[],a=n,o=(e||[]).filter(e=>e.directive&&(e.atPhrase!=null||e.atMs!=null)).map(e=>({d:e,t:e.atMs==null?t.phrases[e.atPhrase].t:e.atMs/1e3})).sort((e,t)=>e.t-t.t),s=t.frame&&t.frame.cy>350;return o.forEach((e,r)=>{let c=e.d,l=e.t,u=r+1<o.length?o[r+1].t:t.sceneT1,d=(c.ms||(c.directive===`snapZoom`?280:c.directive===`punchTo`?620:1100))/1e3,f=SP[c.ease]||(s?wk:Ck),p=(c.hold||0)/1e3,m=a,h={...n};if(c.directive===`panTo`){let e=t.resolveTarget(c.target);h={cx:e.x+(c.offset&&c.offset.x||0),cy:e.y+(c.offset&&c.offset.y||0),zoom:c.zoom||1.3}}else if(c.directive===`punchTo`){let e=t.resolveTarget(c.target);h={cx:e.x+(c.offset&&c.offset.x||0),cy:e.y+(c.offset&&c.offset.y||0),zoom:c.zoom||1.55}}else if(c.directive===`snapZoom`){let e=t.resolveTarget(c.target);h={cx:e.x+(c.offset&&c.offset.x||0),cy:e.y+(c.offset&&c.offset.y||0),zoom:c.zoom||1.75}}else if(c.directive===`orbitLite`){let e=t.resolveTarget(c.target);h={cx:e.x,cy:e.y,zoom:c.zoom||1.2}}else if(c.directive===`zoomOut`||c.directive===`establish`)h=TP(t.VBW,t.frame);else if(c.directive===`follow`)h=m;else if(c.directive===`travel`)h={cx:m.cx+(c.viewportWidths||1)*t.VBW*.6,cy:m.cy,zoom:c.zoom||m.zoom||1};else if(c.directive===`hop`){let e=t.resolveTarget((c.targets||[])[0]);e&&(h={cx:e.x,cy:e.y,zoom:c.zoom||1.3})}i.push({d:c,t0:l,tNext:u,ms:d,ease:f,hold:p,from:m,to:h}),a=c.then===`return`?n:h}),{base:n,idle:r,shots:i}}function _P(e,t,n){n={...n,frame:n.frame||wP(e)};let r=gP(e.camera,n),i=null;for(let e of r.shots)t>=e.t0-1e-9&&t<e.tNext&&(i=e);let a;if(i){let e=i.d,o=t-i.t0;if(i._dir=e.directive,e.directive===`follow`){let t=n.resolveTarget(e.target),i=Y(e.tightness==null?.6:e.tightness,.05,1),o=e.leadRoom?40:0;a={cx:xk(r.base.cx,t.x+o,i),cy:r.base.cy,zoom:e.zoom||1.15,active:!0}}else if(e.directive===`hop`&&e.targets&&e.targets.length){let t=(e.dwell||900)/1e3,r=e.targets.length*t,i=Y(Math.floor(o%r/t),0,e.targets.length-1),s=(o%r-i*t)/t,c=n.resolveTarget(e.targets[i]),l=n.resolveTarget(e.targets[Math.min(i+1,e.targets.length-1)]),u=Ck(Y(s*2,0,1));a={cx:xk(c.x,l.x,u),cy:xk(c.y,l.y,u),zoom:e.zoom||1.3,active:!0}}else if(e.directive===`orbitLite`){let t=n.resolveTarget(e.target),i=(e.deg||8)/8*n.VBW*.06,s=Math.sin(o*(e.speed||.8));a={cx:t.x+s*i,cy:r.base.cy,zoom:e.zoom||1.2,active:!0}}else{let t=i.ease(Y(o/i.ms,0,1)),n=xk(i.from.cx,i.to.cx,t),s=xk(i.from.cy,i.to.cy,t),c=xk(i.from.zoom,i.to.zoom,t);if(e.then===`return`){let e=i.tNext-i.t0,t=Math.min(i.ms,e*.5),a=Math.max(i.ms,e-t);if(o>=a){let e=i.ease(Y((o-a)/t,0,1));n=xk(i.to.cx,r.base.cx,e),s=xk(i.to.cy,r.base.cy,e),c=xk(i.to.zoom,r.base.zoom,e)}}a={cx:n,cy:s,zoom:c,active:!0},e.directive===`snapZoom`&&(a.whip=Y(1-o/.28,0,1))}}else{let e=r.base;for(let n of r.shots)t>=n.t0&&(e=n.d.then===`return`?r.base:n.to);a={...hP(r.idle.idle||`focusFlow`,e,t-n.sceneT0,n.sceneT1-n.sceneT0,n.seed,n.cast,r.idle.stylePreset),active:!1}}return a.directive=i?i.d.directive:`idle`,fP(a,n.VBW)}function vP(e,t){let n=gP(e.camera,t),r=new Set(n.shots.map(e=>e.d.directive)),i=n.shots.map(e=>e.to.zoom).concat([1]),a=Math.max(...i)-Math.min(...i);return Y(r.size*.22+n.shots.length*.1+a*.6,0,1)}function yP(e,t){let n=e.rotation?` rotate(${(-e.rotation).toFixed(3)})`:``;return`translate(${(t/2).toFixed(2)} 300)${n} scale(${e.zoom.toFixed(4)}) translate(${(-e.cx).toFixed(2)} ${(-e.cy+300).toFixed(2)})`}function bP(e,t){return{pan:(t/2-e.cx)*(960/t),scale:e.zoom-1}}function xP(e,t){let n=gP(e.camera,t),r=Math.max(.001,t.sceneT1-t.sceneT0),i=0;return n.shots.forEach(e=>{let t=Math.min(e.tNext,e.t0+e.ms+e.hold);i+=Math.max(0,t-e.t0)}),Y(i/r,0,1)}var SP,CP,wP,TP,EP,DP=o((()=>{Tk(),SP={linear:Sk,smooth:Ck,smoother:wk},CP={default:{cy:300,zoom:1},warfilm:{cy:560,zoom:1}},wP=e=>{let t=null;return(e&&e.camera||[]).forEach(e=>{e.stylePreset&&(t=e.stylePreset)}),CP[t]||CP.default},TP=(e,t=CP.default)=>({cx:e/2,cy:t.cy,zoom:t.zoom}),EP={editorial:{amp:1,zoom:1.06,speed:1},energetic:{amp:1.7,zoom:1.13,speed:1.6},calm:{amp:.5,zoom:1.03,speed:.6},doc:{amp:.8,zoom:1.05,speed:.8},documentary:{amp:.8,zoom:1.05,speed:.8},dramatic:{amp:1.2,zoom:1.18,speed:.7},warfilm:{amp:1.5,zoom:1.02,speed:1.4}}}));function OP(e,t,n){let r=LP[e.type];return r?r(e,Y(t,0,1),n):``}var kP,AP,jP,MP,NP,PP,FP,IP,Q,LP,RP,zP,BP=o((()=>{Tk(),kP=`#243038`,AP=`#2BB3A3`,jP=`#FF6B5E`,MP=`#8794a0`,NP=`#F2B134`,PP=`#5B6CE0`,FP=(e,t,n=`#fff`)=>`<rect x="${-e/2}" y="${-t/2}" width="${e}" height="${t}" rx="${t/2}" fill="${n}" stroke="rgba(20,40,50,.08)"/>`,IP=(e,t)=>`<rect x="${-e/2}" y="${-t/2}" width="${e}" height="${t}" rx="14" fill="#fff" stroke="rgba(20,40,50,.08)"/>`,Q=(e,t,n,r,i=kP,a=800,o=`middle`)=>`<text x="${e}" y="${t}" font-family="Nunito,system-ui,sans-serif" font-size="${n}" font-weight="${a}" text-anchor="${o}" fill="${i}">${r}</text>`,LP={counter(e,t){let n=wk(t),r=e.value==null?0:e.value,i=(Number.isInteger(r)?Math.round(r*n):(r*n).toFixed(1))+(e.unit||``);return e.variant===`chip`?`${FP(Math.max(90,i.length*22+40),56)}${Q(0,9,30,(e.label?e.label+` `:``)+i,kP,900)}`:`${Q(0,6,62,i,AP,900)}${e.label?Q(0,40,20,e.label,MP,800):``}`},proportionFill(e,t){let n=Y(e.value||0,0,100),r=n/100*260*wk(t);return`${IP(296,74)}${e.label?Q(0,-18,20,e.label,kP,800):``}<rect x="-130" y="2" width="260" height="18" rx="9" fill="#e7edf1"/><rect x="-130" y="2" width="${r}" height="18" rx="9" fill="${AP}"/>${Q(134,17,18,Math.round(n*wk(t))+`%`,kP,900,800,`start`)}`},barsCompare(e,t){let n=e.values||[40,70,55],r=e.labels||[],i=[AP,PP,jP,NP],a=Math.max(...n,1),o=n.length*60,s=wk(t),c=n.map((e,t)=>{let n=e/a*120*s,c=-o/2+t*60+10;return`<rect x="${c}" y="${-n}" width="40" height="${n}" rx="6" fill="${i[t%4]}"/>${r[t]?Q(c+20,22,15,r[t],MP,800):``}`}).join(``);return`<line x1="${-o/2-6}" y1="0" x2="${o/2+6}" y2="0" stroke="#d7dee3" stroke-width="2"/>${c}`},trendLine(e,t){let n=e.points||[30,42,38,58,74,68,90],r=wk(t),i=n.length,a=Math.max(...n,1),o=n.map((e,t)=>[-130+t/(i-1)*260,-(e/a)*90]),s=Math.max(2,Math.round(2+(i-2)*r)),c=o.slice(0,s).map((e,t)=>(t?`L`:`M`)+e[0].toFixed(1)+` `+e[1].toFixed(1)).join(` `),l=o[s-1];return`${IP(300,150)}<polyline points="${o.map(e=>e.join(`,`)).join(` `)}" fill="none" stroke="#e7edf1" stroke-width="2"/><path d="${c}" fill="none" stroke="${AP}" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><circle cx="${l[0].toFixed(1)}" cy="${l[1].toFixed(1)}" r="5" fill="${AP}"/>${e.label?Q(0,67,18,e.label,kP,800):``}`},labelChip(e,t){let n=.6+.4*wk(t),r=(e.text||`label`).length*12+34;return`<g transform="scale(${n})" opacity="${t.toFixed(2)}">${FP(r,44,e.tone===`accent`?jP:`#fff`)}${Q(0,7,20,e.text||`label`,e.tone===`accent`?`#fff`:kP,900)}</g>`},mapLite(e,t){let n=(1-wk(t))*40;return`<path d="M-70 20 Q-80 -30 -30 -40 Q10 -60 50 -34 Q86 -20 70 20 Q30 44 -20 40 Q-56 40 -70 20 Z" fill="#cfe3d3" stroke="#a9c6ad" stroke-width="2"/><g transform="translate(${e.px||20} ${-10-n})" opacity="${Y(t*1.4,0,1).toFixed(2)}"><path d="M0 0 C-14 -18 -10 -34 0 -34 C10 -34 14 -18 0 0 Z" fill="${jP}"/><circle cx="0" cy="-24" r="5" fill="#fff"/></g>`},timelineStrip(e,t){let n=e.count||5,r=wk(t),i=Math.round(n*r),a=`<line x1="-130" y1="0" x2="130" y2="0" stroke="#d7dee3" stroke-width="3"/><line x1="-130" y1="0" x2="${-130+260*r}" y2="0" stroke="${AP}" stroke-width="3"/>`;for(let e=0;e<n;e++){let t=-130+e/(n-1)*260;a+=`<circle cx="${t}" cy="0" r="7" fill="${e<i?AP:`#e7edf1`}" stroke="#fff" stroke-width="2"/>`}return a},iconBurst(e,t){let n=wk(t),r=``;for(let e=0;e<8;e++){let t=e/8*Math.PI*2,i=20+34*n;r+=`<circle cx="${(Math.cos(t)*i).toFixed(1)}" cy="${(Math.sin(t)*i).toFixed(1)}" r="${(5*n+2).toFixed(1)}" fill="${[AP,NP,jP,PP][e%4]}" opacity="${(1-n*.5).toFixed(2)}"/>`}return`<circle cx="0" cy="0" r="16" fill="${NP}"/>${r}`},gauge(e,t){let n=Y(e.value||0,0,100),r=wk(t),i=Math.PI,a=Math.PI-n/100*Math.PI*r,o=(e,t,n,r)=>{let i=Math.cos(e)*70,a=-Math.sin(e)*70,o=Math.cos(t)*70,s=-Math.sin(t)*70;return`<path d="M${i.toFixed(1)} ${a.toFixed(1)} A70 70 0 0 1 ${o.toFixed(1)} ${s.toFixed(1)}" fill="none" stroke="${n}" stroke-width="${r}" stroke-linecap="round"/>`};return`${o(i,0,`#e7edf1`,14)}${o(i,a,AP,14)}${Q(0,-6,40,Math.round(n*r)+(e.unit||``),kP,900)}${e.label?Q(0,24,18,e.label,MP,800):``}`},quoteCard(e,t){return`<g opacity="${t.toFixed(2)}">${IP(300,110)}${Q(-132,-15,44,`“`,AP,900,800,`start`)}<foreignObject x="-110" y="-41" width="240" height="86"><div xmlns="http://www.w3.org/1999/xhtml" style="font:800 17px Nunito,system-ui;color:${kP};line-height:1.25">${e.text||``}</div></foreignObject></g>`},xOut(e,t){let n=wk(t);return`<circle cx="0" cy="0" r="34" fill="none" stroke="${jP}" stroke-width="6"/><line x1="${-34*.7*n}" y1="${-34*.7*n}" x2="${34*.7*n}" y2="${34*.7*n}" stroke="${jP}" stroke-width="7" stroke-linecap="round"/><line x1="${34*.7*n}" y1="${-34*.7*n}" x2="${-34*.7*n}" y2="${34*.7*n}" stroke="${jP}" stroke-width="7" stroke-linecap="round"/>`},connectionLink(e,t){let n=-110+220*wk(t);return`<circle cx="-110" cy="0" r="9" fill="${AP}"/><line x1="-110" y1="0" x2="${n}" y2="0" stroke="${AP}" stroke-width="4" stroke-dasharray="2 8" stroke-linecap="round"/><circle cx="110" cy="0" r="9" fill="${t>.9?AP:`#e7edf1`}"/>`},morph(e,t){return`<rect x="-40" y="-40" width="80" height="80" rx="${(40-32*wk(t)).toFixed(1)}" fill="${AP}"/>`},pieSlice(e,t){let n=Y(e.value==null?60:e.value,0,100)/100*wk(t),r=n*2*Math.PI,i=Math.sin(r)*40,a=-Math.cos(r)*40;return`<circle cx="0" cy="0" r="40" fill="#e7edf1"/><path d="M0 0 L0 -40 A40 40 0 ${+(n>.5)} 1 ${i.toFixed(1)} ${a.toFixed(1)} Z" fill="${AP}"/>${Q(0,6,20,Math.round(n*100)+`%`,kP,900)}`},statCallout(e,t){let n=e.value==null?``:Math.round(e.value*wk(t));return`${Q(0,-2,52,n+(e.unit||``),AP,900)}${e.label?Q(0,30,18,e.label,MP,800):``}`},checklist(e,t){let n=e.count||3,r=Math.round(n*wk(t)),i=``;for(let t=0;t<n;t++){let a=-n*15+t*30;i+=`<rect x="-96" y="${a-13}" width="192" height="26" rx="7" fill="#fff" stroke="rgba(20,40,50,.08)"/><circle cx="-78" cy="${a}" r="9" fill="${t<r?AP:`#e7edf1`}"/>${t<r?`<path d="M-82 ${a} l3 4 l7 -8" stroke="#fff" stroke-width="2.5" fill="none"/>`:``}${Q(-60,a+5,15,e.labels&&e.labels[t]||`item `+(t+1),kP,800,800,`start`)}`}return i},arrow(e,t){let n=wk(t),r=-70+140*n;return`<line x1="-70" y1="0" x2="${r.toFixed(1)}" y2="0" stroke="${jP}" stroke-width="6" stroke-linecap="round"/><path d="M${r.toFixed(1)} 0 l-14 -9 M${r.toFixed(1)} 0 l-14 9" stroke="${jP}" stroke-width="6" fill="none" stroke-linecap="round" opacity="${n.toFixed(2)}"/>`},highlightRing(e,t){return`<circle cx="0" cy="0" r="${(30+8*Math.sin(t*Math.PI)).toFixed(1)}" fill="none" stroke="${NP}" stroke-width="5"/>`},badge(e,t){return`<g transform="scale(${(.7+.3*wk(t)).toFixed(2)})"><path d="M0 -44 L38 -30 L38 6 Q38 34 0 46 Q-38 34 -38 6 L-38 -30 Z" fill="${AP}"/>${Q(0,6,22,e.text||`A+`,`#fff`,900)}</g>`},ratingStars(e,t){let n=Y(e.value==null?4:e.value,0,5)*wk(t),r=(e,t)=>`<path transform="translate(${e} 0) scale(0.85)" d="M0 -16 L5 -5 L17 -4 L8 4 L11 16 L0 9 L-11 16 L-8 4 L-17 -4 L-5 -5 Z" fill="${t}"/>`,i=``;for(let e=0;e<5;e++)i+=r(-88+e*44,e<n?NP:`#e7edf1`);return i},deltaBadge(e,t){let n=(e.value||0)>=0,r=Math.abs(Math.round((e.value||0)*wk(t)));return`${FP(130,52,n?`#e6f7f0`:`#fdecea`)}${Q(-32,8,24,n?`▲`:`▼`,n?AP:jP,900)}${Q(20,8,24,r+(e.unit||``),n?AP:jP,900)}`},keyValue(e,t){return`${IP(230,60)}${Q(-100,7,18,e.label||`key`,MP,800,800,`start`)}${Q(100,7,22,(e.text==null?e.value||``:e.text)+(e.unit||``),kP,900,800,`end`)}`},progressRing(e,t){let n=Y(e.value||0,0,100)/100*wk(t),r=2*Math.PI*40;return`<circle cx="0" cy="0" r="40" fill="none" stroke="#e7edf1" stroke-width="10"/><circle cx="0" cy="0" r="40" fill="none" stroke="${AP}" stroke-width="10" stroke-linecap="round" stroke-dasharray="${r.toFixed(1)}" stroke-dashoffset="${(r*(1-n)).toFixed(1)}" transform="rotate(-90)"/>${Q(0,7,24,Math.round(n*100)+`%`,kP,900)}`},flowStep(e,t){let n=Math.min(2,Math.floor(wk(t)*3)),r=``;for(let t=0;t<3;t++){let i=-100+t*100;r+=`<rect x="${i-34}" y="-22" width="68" height="44" rx="8" fill="${t<=n?AP:`#e7edf1`}"/>${Q(i,7,16,e.labels&&e.labels[t]||`step `+(t+1),t<=n?`#fff`:MP,800)}${t<2?`<path d="M${i+40} 0 l16 0 M${i+52} -5 l6 5 l-6 5" stroke="#c7d0d6" stroke-width="3" fill="none"/>`:``}`}return r},tally(e,t){let n=Math.round((e.value||7)*wk(t)),r=``;for(let e=0;e<n;e++){let t=Math.floor(e/5),n=e%5,i=-90+t*46+n*8;r+=n===4?`<line x1="${i-34}" y1="-16" x2="${i-2}" y2="16" stroke="${kP}" stroke-width="3"/>`:`<line x1="${i}" y1="-16" x2="${i}" y2="16" stroke="${kP}" stroke-width="3"/>`}return r},thermometer(e,t){let n=Y(e.value||0,0,100)/100*wk(t);return`<rect x="-12" y="-110" width="24" height="110" rx="12" fill="#e7edf1"/><rect x="-12" y="${(-110*n).toFixed(1)}" width="24" height="${(110*n).toFixed(1)}" rx="12" fill="${jP}"/><circle cx="0" cy="14" r="18" fill="${jP}"/>${Q(30,-110*n+6,18,Math.round(n*100)+`%`,kP,900,800,`start`)}`},sparkbars(e,t){let n=e.points||[3,6,4,8,5,9,7],r=wk(t),i=Math.max(...n,1),a=``;return n.forEach((e,t)=>{let o=e/i*60*r,s=-n.length*15/2+t*15;a+=`<rect x="${s}" y="${-o}" width="12" height="${o}" rx="3" fill="${AP}"/>`}),a},ribbon(e,t){return`<g transform="scale(${(.7+.3*wk(t)).toFixed(2)})"><circle cx="0" cy="-20" r="26" fill="${NP}"/><circle cx="0" cy="-20" r="18" fill="#fff" opacity=".85"/>${Q(0,-13,22,e.text||`1`,kP,900)}<path d="M-14 0 L-20 40 L-6 30 L0 42 L6 30 L20 40 L14 0 Z" fill="${jP}"/></g>`},calloutBox(e,t){return`<g opacity="${t.toFixed(2)}">${IP(220,70)}<path d="M-14 35 l14 18 l14 -18 Z" fill="#fff"/>${Q(0,6,18,e.text||``,kP,800)}</g>`},comparisonBar(e,t){let n=Y(e.value==null?60:e.value,0,100),r=wk(t),i=n/100*260*r;return`<rect x="-130" y="-12" width="260" height="24" rx="12" fill="${PP}"/><rect x="-130" y="-12" width="${i.toFixed(1)}" height="24" rx="12" fill="${AP}"/>${Q(-122,7,16,Math.round(n*r)+`%`,`#fff`,900,800,`start`)}${Q(122,7,16,100-Math.round(n*r)+`%`,`#fff`,900,800,`end`)}`}},LP.highlightRegion=function(e,t,n){let r=wk(t),i=e.tint||NP,a=(26+18*(.5+.5*Math.sin((n||0)*3)))*r,o=e.label?`<g transform="translate(0 -50)">${FP(e.label.length*12+30,38)}${Q(0,6,18,e.label,kP,900)}</g>`:``;return`<circle r="${a.toFixed(1)}" fill="none" stroke="${i}" stroke-width="3" opacity="${(.7*r).toFixed(2)}"/><circle r="${(12*r).toFixed(1)}" fill="${i}" opacity="0.9"/>${o}`},LP.sweepArrow=function(e,t){let n=e.bx==null?160:e.bx,r=e.by==null?-60:e.by,i=wk(t),a=e.tint||jP,o=n*.5,s=Math.min(0,r)-90,c=2*(1-i)*i*o+i*i*n,l=2*(1-i)*i*s+i*i*r,u=`<path d="M 0 0 Q ${o.toFixed(1)} ${s.toFixed(1)} ${c.toFixed(1)} ${l.toFixed(1)}" fill="none" stroke="${a}" stroke-width="5" stroke-linecap="round"/>`,d=``;if(i>.82){let e=Math.atan2(l-s,c-o);d=`<path d="M ${c.toFixed(1)} ${l.toFixed(1)} L ${(c+Math.cos(e+2.6)*18).toFixed(1)} ${(l+Math.sin(e+2.6)*18).toFixed(1)} M ${c.toFixed(1)} ${l.toFixed(1)} L ${(c+Math.cos(e-2.6)*18).toFixed(1)} ${(l+Math.sin(e-2.6)*18).toFixed(1)}" stroke="${a}" stroke-width="5" stroke-linecap="round" fill="none"/>`}return u+d},LP.dropPlate=function(e,t){let n=(1-wk(t))*-24,r=e.label||e.text||`REGION`,i=r.length*14+78;return`<g transform="translate(0 ${n.toFixed(1)})" opacity="${t.toFixed(2)}"><rect x="${(-i/2).toFixed(1)}" y="-26" width="${i.toFixed(1)}" height="52" rx="12" fill="#fff" stroke="rgba(20,40,50,.1)"/><circle cx="${(-i/2+28).toFixed(1)}" cy="0" r="16" fill="${e.tint||jP}"/><circle cx="${(-i/2+28).toFixed(1)}" cy="0" r="16" fill="none" stroke="rgba(0,0,0,.14)"/>${Q((-i/2+52).toFixed(1),7,21,r,kP,900,800,`start`)}</g>`},LP.entrantPlate=function(e,t){let n=(1-wk(t))*-140,r=e.label||e.text||`ENTRANT`,i=r.length*20+116;return`<g transform="translate(${n.toFixed(1)} 0)" opacity="${t.toFixed(2)}"><rect x="${(-i/2).toFixed(1)}" y="-34" width="${i.toFixed(1)}" height="68" rx="14" fill="#1b2432" stroke="rgba(255,255,255,.14)"/><circle cx="${(-i/2+36).toFixed(1)}" cy="0" r="22" fill="${e.tint||jP}"/><circle cx="${(-i/2+36).toFixed(1)}" cy="0" r="22" fill="none" stroke="rgba(255,255,255,.22)"/>`+Q((-i/2+68).toFixed(1),e.value==null?8:-4,26,r,`#fff`,900,800,`start`)+(e.value==null?``:Q((-i/2+68).toFixed(1),20,15,e.value+(e.unit||``),`#9fb0c4`,800,800,`start`))+`</g>`},LP.vsCard=function(e,t){let n=wk(t),r=e.labels||[`A`,`B`],i=70*n,a=r[0].length*16+54,o=r[1].length*16+54;return`<g opacity="${t.toFixed(2)}"><g transform="translate(${(-70-i).toFixed(1)} 0)">${FP(a,62,`#dfeaf6`)}${Q(0,8,24,r[0],kP,900)}</g><g transform="translate(${(70+i).toFixed(1)} 0)">${FP(o,62,`#f6e3df`)}${Q(0,8,24,r[1],kP,900)}</g><circle r="26" fill="${jP}"/><circle r="26" fill="none" stroke="#fff" stroke-width="2"/>${Q(0,9,24,`VS`,`#fff`,900)}</g>`},LP.rangeBand=function(e,t){let n=wk(t),r=e.min==null?0:e.min,i=e.max==null?100:e.max,a=Y(e.value==null?(r+i)/2:e.value,r,i),o=-140+280*((a-r)/(i-r||1));return`${e.label?Q(0,-30,20,e.label,kP,800):``}<rect x="-140" y="-8" width="280" height="16" rx="8" fill="#e7edf1"/><rect x="${(-50.39999999999999).toFixed(1)}" y="-8" width="${100.8.toFixed(1)}" height="16" rx="8" fill="#cdeee7"/><g transform="translate(${(-140+(o+140)*n).toFixed(1)} 0)"><line x1="0" y1="-20" x2="0" y2="20" stroke="${AP}" stroke-width="4" stroke-linecap="round"/><circle cx="0" cy="0" r="7" fill="${AP}"/></g>`+Q(-140,34,14,``+r,MP,800)+Q(140,34,14,``+i,MP,800,`middle`)+Q(0,34,15,Math.round(a*n)+(e.unit||``),kP,900)},LP.podium=function(e,t){let n=wk(t),r=e.labels||[`1st`,`2nd`,`3rd`],i=e.values||[],a=r.map((e,t)=>({label:e,val:i[t]}));i.length&&(a=a.slice().sort((e,t)=>(t.val||0)-(e.val||0))),a=a.slice(0,3);let o=[1,0,2],s=[130,96,74],c=[NP,MP,`#c98b52`];return a.map((t,r)=>{let i=o[r],a=s[r]*n,l=-66+i*66,u=r+1;return`<rect x="${l}" y="${-a}" width="62" height="${a}" rx="6" fill="${c[r]}"/>${Q(l+31,-a+30,26,``+u,`#fff`,900)}`+(t.label?Q(l+31,24,14,t.label,kP,800):``)+(t.val==null?``:Q(l+31,-a-10,16,t.val+(e.unit||``),kP,900))}).join(``)},LP.rankBadge=function(e,t){let n=.7+.3*wk(t),r=e.value==null?1:e.value,i=r===1?NP:r===2?`#b8c0c8`:r===3?`#c98b52`:AP;return`<g transform="scale(${n.toFixed(2)})"><circle cx="0" cy="0" r="34" fill="${i}"/><circle cx="0" cy="0" r="27" fill="#fff" opacity=".9"/>${Q(0,3,30,`#`+r,kP,900)}<path d="M-16 26 L-22 58 L-8 48 L0 60 L8 48 L22 58 L16 26 Z" fill="${i}"/>${e.label?Q(0,-46,16,e.label,MP,800):``}</g>`},LP.progressRail=function(e,t){let n=wk(t),r=e.count||(e.labels?e.labels.length:4),i=e.value==null?n:Y(e.value,0,100)/100,a=-140+280*i,o=`<rect x="-140" y="-4" width="280" height="8" rx="4" fill="#e7edf1"/><rect x="-140" y="-4" width="${(280*i).toFixed(1)}" height="8" rx="4" fill="${AP}"/>`;for(let t=0;t<r;t++){let n=-140+t/(r-1)*280,i=n<=a+1;o+=`<circle cx="${n.toFixed(1)}" cy="0" r="6" fill="${i?AP:`#fff`}" stroke="${i?AP:`#d7dee3`}" stroke-width="2"/>${e.labels&&e.labels[t]?Q(n,26,13,e.labels[t],i?kP:MP,800):``}`}return o+`<g transform="translate(${a.toFixed(1)} 0)"><circle cx="0" cy="0" r="11" fill="${AP}" stroke="#fff" stroke-width="3"/></g>`},LP.ticker=function(e,t,n){let r=(e.labels||[e.text||`BREAKING`]).join(` • `)+` • `,i=r.length*9.2,a=-((n||0)*70%i),o=e.label||`LIVE`;return`<clipPath id="tk"><rect x="-160" y="-20" width="320" height="40" rx="8"/></clipPath><rect x="-160" y="-20" width="320" height="40" rx="8" fill="#1b2432"/><g clip-path="url(#tk)"><text x="${(-148+a).toFixed(1)}" y="6" font-family="Nunito,system-ui" font-size="18" font-weight="800" fill="#fff">${r}${r}</text></g><rect x="-160" y="-20" width="74" height="40" rx="8" fill="${jP}"/>${Q(-123,6,16,o,`#fff`,900)}<g opacity="${t.toFixed(2)}"></g>`},LP.scoreboard=function(e,t){let n=e.labels||[`HOME`,`AWAY`],r=e.values||[0,0],i=wk(t),a=Math.round(r[0]*i),o=Math.round(r[1]*i);return`<g opacity="${t.toFixed(2)}"><rect x="-150" y="-42" width="300" height="84" rx="12" fill="#1b2432"/><rect x="-150" y="-42" width="8" height="84" fill="${AP}"/><rect x="142" y="-42" width="8" height="84" fill="${jP}"/>`+Q(-90,-12,18,n[0],`#9fb0c4`,900)+Q(-90,24,40,``+a,`#fff`,900)+Q(90,-12,18,n[1],`#9fb0c4`,900)+Q(90,24,40,``+o,`#fff`,900)+`<line x1="0" y1="-30" x2="0" y2="30" stroke="rgba(255,255,255,.14)" stroke-width="2"/>`+(e.text?Q(0,-8,16,e.text,NP,900):Q(0,8,26,`:`,`#fff`,900))+`</g>`},LP.checkmark=function(e,t){let n=wk(t),r=46*(1-n);return`<circle cx="0" cy="0" r="30" fill="${AP}" opacity="${(.15+.85*n).toFixed(2)}"/><path d="M-14 1 l9 11 l19 -22" fill="none" stroke="#fff" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="46" stroke-dashoffset="${r.toFixed(1)}"/>${e.label?Q(0,54,18,e.label,kP,900):``}`},LP.bracketSync=function(e,t){let n=wk(t),r=e.labels||[`Seed A`,`Seed B`,`Winner`],i=Y(n*1.4,0,1),a=(e,t,n,r)=>`<g transform="translate(${e} ${t})">${FP(96,40,r?`#dfeff6`:`#fff`)}${Q(0,6,16,n,kP,900)}</g>`;return a(-96,-40,r[0],!0)+a(-96,40,r[1],!0)+`<path d="M-48 -40 H-20 V40 H-48 M-20 0 H48" fill="none" stroke="${AP}" stroke-width="3" stroke-dasharray="220" stroke-dashoffset="${(220*(1-n)).toFixed(1)}"/><g opacity="${i.toFixed(2)}">${a(96,0,r[2],!0)}</g>`},LP.lowerThird=function(e,t){let n=(1-wk(t))*-260,r=e.text||`Name`,i=e.label||``,a=Math.max(r.length,i.length)*13+90;return`<g transform="translate(${n.toFixed(1)} 0)" opacity="${Y(t*1.4,0,1).toFixed(2)}"><rect x="${-a/2}" y="-30" width="${a}" height="60" rx="8" fill="#1b2432"/><rect x="${-a/2}" y="-30" width="7" height="60" fill="${AP}"/>`+Q(-a/2+22,-2,24,r,`#fff`,900,800,`start`)+(i?Q(-a/2+22,20,15,i,AP,800,800,`start`):``)+`</g>`},LP.annotationArrow=function(e,t){let n=wk(t),r=e.dir||`up`,i={up:[0,-96],down:[0,96],left:[-120,0],right:[120,0]}[r]||[0,-96],a=i[0]*.6+(r===`up`||r===`down`?40:0),o=i[1]*.6+(r===`left`||r===`right`?-34:0),s=2*(1-n)*n*a+n*n*i[0],c=2*(1-n)*n*o+n*n*i[1],l=``;if(n>.85){let e=Math.atan2(c-o,s-a);l=`<path d="M${s.toFixed(1)} ${c.toFixed(1)} L${(s+Math.cos(e+2.6)*16).toFixed(1)} ${(c+Math.sin(e+2.6)*16).toFixed(1)} M${s.toFixed(1)} ${c.toFixed(1)} L${(s+Math.cos(e-2.6)*16).toFixed(1)} ${(c+Math.sin(e-2.6)*16).toFixed(1)}" stroke="${jP}" stroke-width="5" stroke-linecap="round" fill="none"/>`}let u=e.text?`<g transform="translate(${(-i[0]*.1).toFixed(1)} ${(-i[1]*.1).toFixed(1)})">${FP(e.text.length*11+28,38,`#fff`)}${Q(0,6,17,e.text,kP,900)}</g>`:``;return`<path d="M0 0 Q${a.toFixed(1)} ${o.toFixed(1)} ${s.toFixed(1)} ${c.toFixed(1)}" fill="none" stroke="${jP}" stroke-width="5" stroke-linecap="round"/>${l}${u}`},LP.circleHighlight=function(e,t,n){let r=wk(t),i=e.value==null?52:e.value,a=i*.74,o=300*(1-r);return`<g transform="rotate(-8) scale(${(1+.02*Math.sin((n||0)*4)).toFixed(3)})"><path d="M${i} -6 C${i} ${-a*1.1} ${-i*.4} ${-a*1.25} ${-i} ${-a*.3} C${-i*1.3} ${a*.7} ${-i*.3} ${a*1.25} ${i*.5} ${a} C${i*1.25} ${a*.75} ${i*1.05} ${-a*.2} ${i*.9} ${-a*.9}" fill="none" stroke="${e.tint||NP}" stroke-width="5" stroke-linecap="round" stroke-dasharray="300" stroke-dashoffset="${o.toFixed(1)}"/></g>${e.label?Q(0,a+30,18,e.label,kP,900):``}`},LP.floorPlanBoard=function(e,t){let n=(1-wk(t))*28,r=`<g transform="translate(${e.px==null?0:e.px} ${((e.py==null?-30:e.py)-20-n).toFixed(1)})" opacity="${Y(t*1.4,0,1).toFixed(2)}"><path d="M0 0 C-13 -17 -9 -32 0 -32 C9 -32 13 -17 0 0 Z" fill="${e.tint||jP}"/><circle cx="0" cy="-22" r="5" fill="#fff"/></g>`,i=e.label?`<g transform="translate(0 -110)">${FP(e.label.length*12+28,38)}${Q(0,6,18,e.label,kP,900)}</g>`:``;return`<g opacity="${t.toFixed(2)}"><rect x="-140" y="-90" width="280" height="180" rx="10" fill="#f4f7f8" stroke="#c7d3d9" stroke-width="3"/><line x1="0" y1="-90" x2="0" y2="50" stroke="#c7d3d9" stroke-width="3"/><line x1="-140" y1="10" x2="0" y2="10" stroke="#c7d3d9" stroke-width="3"/><line x1="0" y1="-20" x2="140" y2="-20" stroke="#c7d3d9" stroke-width="3"/><rect x="-8" y="86" width="16" height="8" fill="#f4f7f8" stroke="none"/>${i}</g>${r}`},LP.titleCard=function(e,t){return`<g transform="translate(0 ${((1-wk(t))*22).toFixed(1)})" opacity="${Y(t*1.3,0,1).toFixed(2)}"><line x1="-290" y1="-56" x2="290" y2="-56" stroke="${AP}" stroke-width="3"/>`+Q(0,6,62,e.text||`Title`,kP,900)+(e.label?Q(0,52,24,e.label,MP,800):``)+`<line x1="-290" y1="86" x2="290" y2="86" stroke="${AP}" stroke-width="3"/></g>`},LP.chapterCard=function(e,t){let n=wk(t),r=Y(n*1.2,0,1),i=e.value==null?1:e.value;return`<g opacity="${t.toFixed(2)}"><rect x="-280" y="-58" width="${(560*r).toFixed(1)}" height="116" rx="12" fill="#1b2432"/>`+Q(-234,18,68,``+i,AP,900,800,`start`)+(r>.6?Q(-160,-6,20,`CHAPTER`,`#9fb0c4`,900,800,`start`)+Q(-160,26,30,e.text||``,`#fff`,900,800,`start`):``)+`</g>`},LP.ctaCard=function(e,t,n){let r=wk(t),i=1+.03*Math.sin((n||0)*4),a=Math.max(320,(e.text||`Get started`).length*20+120);return`<g transform="scale(${(r*i).toFixed(3)})" opacity="${t.toFixed(2)}">`+(e.label?Q(0,-58,24,e.label,kP,800):``)+`<rect x="${-a/2}" y="-34" width="${a}" height="68" rx="34" fill="${jP}"/>${Q(0,9,28,e.text||`Get started`,`#fff`,900)}<path d="M${a/2-44} -8 l16 8 l-16 8" stroke="#fff" stroke-width="4" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g>`},LP.endCard=function(e,t){let n=wk(t);return`<g opacity="${Y(t*1.3,0,1).toFixed(2)}"><circle cx="0" cy="-64" r="${(30*n).toFixed(1)}" fill="${AP}"/>${n>.5?`<path d="M-11 -64 l7 8 l14 -16" stroke="#fff" stroke-width="5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`:``}`+Q(0,8,52,e.text||`The End`,kP,900)+(e.label?Q(0,48,22,e.label,MP,800):``)+`<line x1="-220" y1="76" x2="220" y2="76" stroke="#e7edf1" stroke-width="2"/></g>`},LP.recapCarousel=function(e,t){let n=e.labels||[`One`,`Two`,`Three`],r=Math.min(n.length,4),i=wk(t),a=r*150+(r-1)*18,o=e.label?Q(0,-96,24,e.label,kP,900):``;for(let e=0;e<r;e++){let t=Y(i*r-e,0,1),s=-a/2+75+e*168,c=(1-t)*16;o+=`<g transform="translate(${s.toFixed(1)} ${c.toFixed(1)})" opacity="${t.toFixed(2)}"><rect x="-75" y="-56" width="150" height="112" rx="12" fill="#fff" stroke="rgba(20,40,50,.1)"/><circle cx="0" cy="-22" r="16" fill="${[AP,NP,jP,PP][e%4]}"/>${Q(0,-15,18,``+(e+1),`#fff`,900)}`+Q(0,30,16,n[e],kP,800)+`</g>`}return o},RP=Object.keys(LP),zP=[`titleCard`,`chapterCard`,`ctaCard`,`endCard`,`recapCarousel`]}));function VP(e){return eF[(e||``).toLowerCase()]||eF.default}function HP(e,t){return{dx:Math.sin(e*.18+t)*26,dy:Math.sin(e*.9+t)*6}}function UP(e){let[t,n]=QP[e.size]||QP.M,r=e.depthScale==null?1:e.depthScale,i=t*r,a=n*r,o=e.tint||VP(e.label),s=e.silhouette==null?e.z!=null&&e.z>.72:e.silhouette,c=Math.min(16*r,a*.18),l=s?0:Math.min(12*r,a*.16),u=e.shadow===!1?``:`<ellipse cx="0" cy="4" rx="${(i*.56).toFixed(1)}" ry="${(9*r).toFixed(1)}" fill="#000" opacity="${s?.1:.16}"/>`,d=`<rect x="${(-i/2).toFixed(1)}" y="${(-a).toFixed(1)}" width="${i.toFixed(1)}" height="${a.toFixed(1)}" rx="${c.toFixed(1)}" fill="${s?yk(o,.42):o}"/>`,f=l?`<rect x="${(-i/2+3).toFixed(1)}" y="${(-a+2).toFixed(1)}" width="${(i-6).toFixed(1)}" height="${l.toFixed(1)}" rx="${(c*.5).toFixed(1)}" fill="${yk(o,1.24)}" opacity="0.85"/>`:``,p=s?``:`<rect x="${(-i/2).toFixed(1)}" y="${(-a*.28).toFixed(1)}" width="${i.toFixed(1)}" height="${(a*.28).toFixed(1)}" rx="${c.toFixed(1)}" fill="${yk(o,.78)}" opacity="0.5"/>`,m=Y(Math.round(15*r),8,22);return`${u}${d}${p}${f}${s?``:`<text x="0" y="${(-a/2).toFixed(1)}" text-anchor="middle" dominant-baseline="central" font-family="Nunito,system-ui,sans-serif" font-weight="800" font-size="${m}" fill="#f2f5f8" opacity="0.92" letter-spacing="0.5">${(e.label||``).toString().slice(0,12).toUpperCase()}</text>`}`}function WP(e,t){let[n,r]=QP[e.size]||QP.M,i=e.depthScale==null?1:e.depthScale,a=n*i,o=r*i,s=e.silhouette==null?e.z!=null&&e.z>.72:e.silhouette,c=e.shadow===!1?``:`<ellipse cx="0" cy="4" rx="${(a*.56).toFixed(1)}" ry="${(9*i).toFixed(1)}" fill="#000" opacity="${s?.1:.16}"/>`,l=`0 0 ${t.w||100} ${t.h||100}`,u=s?` style="filter:brightness(0.28) saturate(0.4)"`:``;return`${c}${`<svg x="${(-a/2).toFixed(1)}" y="${(-o).toFixed(1)}" width="${a.toFixed(1)}" height="${o.toFixed(1)}" viewBox="${l}" preserveAspectRatio="xMidYMax meet" overflow="visible"${u}>${t.inner}</svg>`}`}function GP(e){let[t,n]=QP[e.size]||QP.M,r=e.depthScale==null?1:e.depthScale,i=t*r,a=n*r;return{muzzle:{dx:i*.5,dy:-a*.62},smoke:{dx:0,dy:-a},center:{dx:0,dy:-a*.5}}}function KP(e){let t=e.depthScale||1,n=(rF[e.size]||94)*t/2,r=e.tint||VP(e.label),i=e.silhouette,a=(e.label||``).toString().slice(0,5).toUpperCase();return oF(t,n*.9,e.shadow)+`<circle cx="0" cy="${-n}" r="${n.toFixed(1)}" fill="${i?yk(r,.45):r}"/><circle cx="0" cy="${-n}" r="${n.toFixed(1)}" fill="none" stroke="rgba(0,0,0,.16)"/>`+(i?``:`<text x="0" y="${(-n+aF(t)*.36).toFixed(1)}" text-anchor="middle" dominant-baseline="middle" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${aF(t,16)}" fill="#fff">${a}</text>`)}function qP(e){let t=e.depthScale||1,n=(rF[e.size]||94)*t/2,r=e.tint||`#8aa0b5`,i=e.silhouette,a=iF(e.label);return oF(t,n*.9,e.shadow)+`<circle cx="0" cy="${-n}" r="${(n+3*t).toFixed(1)}" fill="none" stroke="${i?yk(r,.5):r}" stroke-width="${(3.5*t).toFixed(1)}"/><circle cx="0" cy="${-n}" r="${n.toFixed(1)}" fill="${i?yk(`#c9b7a6`,.5):`#d9c7b6`}"/>`+(i?``:`<text x="0" y="${(-n+aF(t)*.36).toFixed(1)}" text-anchor="middle" dominant-baseline="middle" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${aF(t,18)}" fill="${r}">${a}</text>`)}function JP(e){let[t,n]=QP[e.size]||QP.M,r=e.depthScale||1,i=t*r,a=n*r,o=e.tint||`#7a8794`,s=e.silhouette,c=(e.label||`IMAGE`).toString().slice(0,12).toUpperCase(),l=`<rect x="${-i/2}" y="${-a}" width="${i.toFixed(1)}" height="${a.toFixed(1)}" rx="6" fill="${s?yk(o,.42):`#eef1f4`}" stroke="${s?yk(o,.3):o}" stroke-width="${(3*r).toFixed(1)}"/>`,u=s?``:`<line x1="${-i/2+6}" y1="-6" x2="${i/2-6}" y2="${-a+8}" stroke="${o}" stroke-width="1.5" opacity="0.5"/><line x1="${-i/2+6}" y1="${-a+8}" x2="${i/2-6}" y2="-6" stroke="${o}" stroke-width="1.5" opacity="0.5"/><rect x="${-i/2}" y="${-a*.26}" width="${i.toFixed(1)}" height="${(a*.26).toFixed(1)}" rx="0" fill="${o}" opacity="0.9"/><text x="0" y="${(-a*.1).toFixed(1)}" text-anchor="middle" font-family="Nunito,system-ui,sans-serif" font-weight="800" font-size="${aF(r,13)}" fill="#fff">${c}</text>`;return oF(r,i*.5,e.shadow)+l+u}function YP(e){let t=e.depthScale||1,n=(rF[e.size]||94)*.7*t,r=e.tint||VP(e.label),i=e.silhouette,a=iF(e.label).slice(0,1)||`A`;return oF(t,n*.6,e.shadow)+`<rect x="${-n/2}" y="${-n}" width="${n.toFixed(1)}" height="${n.toFixed(1)}" rx="${(n*.22).toFixed(1)}" fill="${i?yk(r,.45):r}"/>`+(i?``:`<text x="0" y="${(-n/2+aF(t)*.36).toFixed(1)}" text-anchor="middle" dominant-baseline="middle" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${aF(t,22)}" fill="#fff">${a}</text>`)}function XP(e){switch(e.face){case`flagRoundel`:return KP(e);case`portraitCircle`:return qP(e);case`imageFrame`:return JP(e);case`logoTile`:return YP(e);default:return UP(e)}}function ZP(e){if(!e.face||e.face===`assetBox`)return GP(e);let t=e.depthScale==null?1:e.depthScale;if(e.face===`imageFrame`){let[n,r]=QP[e.size]||QP.M,i=n*t,a=r*t;return{muzzle:{dx:i*.5,dy:-a*.5},smoke:{dx:0,dy:-a},center:{dx:0,dy:-a*.5}}}let n=(rF[e.size]||94)*t,r=n/2;return{muzzle:{dx:r*.8,dy:-r},smoke:{dx:0,dy:-n},center:{dx:0,dy:-r}}}var QP,$P,eF,tF,nF,rF,iF,aF,oF,sF=o((()=>{Tk(),QP={S:[78,54],M:[128,88],L:[198,134]},$P=[`ground`,`hover`,`mounted`],eF={default:`#4a5a6b`,tank:`#59636f`,jet:`#6b7686`,hq:`#6a5a72`,monument:`#7a6a54`,ship:`#496072`,arty:`#6b5a4a`,wall:`#5c5750`,truck:`#5a6a5a`},tF=[`assetBox`,`flagRoundel`,`portraitCircle`,`imageFrame`,`logoTile`],nF=e=>tF.includes(e),rF={S:64,M:94,L:132},iF=e=>(e||``).toString().trim().split(/\s+/).map(e=>e[0]||``).join(``).slice(0,3).toUpperCase()||(e||`?`).slice(0,2).toUpperCase(),aF=(e,t=15,n=8,r=22)=>Y(Math.round(t*e),n,r),oF=(e,t,n)=>n===!1?``:`<ellipse cx="0" cy="4" rx="${t.toFixed(1)}" ry="${(8*e).toFixed(1)}" fill="#000" opacity="0.14"/>`}));function cF(e,t,n){let r=hF[e.type];return r?r(e,t,n):``}var lF,uF,dF,fF,pF,mF,hF,gF=o((()=>{lF=[`flashImpact`,`smokeColumn`,`emberField`,`tracerArc`,`burst`,`speedLines`,`muzzleFlash`,`dustPuff`,`splash`,`ripple`,`glowPulse`,`shockwaveRing`,`confetti`,`sparkleGlint`,`coinBurst`,`heartsPuff`,`steamWisp`],uF=[`burst`,`flashImpact`,`shockwaveRing`],dF={flashImpact:`screen`,speedLines:`screen`},fF={flashImpact:.16,muzzleFlash:.22,burst:.75,tracerArc:.7,smokeColumn:4,emberField:4,speedLines:1.5,dustPuff:.6,splash:.6,ripple:.9,glowPulse:2,shockwaveRing:.5,confetti:1.8,sparkleGlint:.7,coinBurst:.9,heartsPuff:1.6,steamWisp:3},pF=e=>dF[e]||`world`,mF=(e,t=.12,n=.25)=>Math.max(0,Math.min(1,e/t,(1-e)/n)),hF={smokeColumn(e,t,n){let r=e.tint||`#8b909a`,i=e.scale||1,a=mF(t,.15,.35),o=``;for(let e=0;e<6;e++){let t=(n*.4+e/6)%1,s=-t*160*i,c=(10+t*34)*i,l=a*(1-t)*.5;o+=`<circle cx="${(Math.sin(t*3+e)*10*i).toFixed(1)}" cy="${s.toFixed(1)}" r="${c.toFixed(1)}" fill="${r}" opacity="${l.toFixed(3)}"/>`}return o},emberField(e,t,n){let r=e.scale||1,i=mF(t,.2,.4),a=``;for(let e=0;e<14;e++){let t=(n*.6+e*.137)%1,o=(Math.sin(e*2.3)*40+Math.sin(n+e)*6)*r,s=-t*180*r,c=i*(1-t);a+=`<circle cx="${o.toFixed(1)}" cy="${s.toFixed(1)}" r="${((2+Math.sin(e)*1)*r).toFixed(1)}" fill="#ffb24a" opacity="${c.toFixed(3)}"/>`}return a},tracerArc(e,t){let n=e.bx==null?120:e.bx,r=e.by==null?-40:e.by,i=Math.min(1,t/.6),a=n*.5,o=Math.min(0,r)-70,s=2*(1-i)*i*a+i*i*n,c=2*(1-i)*i*o+i*i*r,l=1-Math.max(0,(t-.6)/.4);return`<path d="M 0 0 Q ${a.toFixed(1)} ${o.toFixed(1)} ${s.toFixed(1)} ${c.toFixed(1)}" stroke="#ffe07a" stroke-width="3" fill="none" opacity="${l.toFixed(3)}" stroke-linecap="round"/>`+(t>.6?`<circle cx="${n.toFixed(1)}" cy="${r.toFixed(1)}" r="${(6+(t-.6)*44).toFixed(1)}" fill="#fff6c8" opacity="${(1-(t-.6)/.4).toFixed(3)}"/>`:``)},burst(e,t){let n=1-t,r=e.scale||1,i=`<circle r="${((6+t*70)*r).toFixed(1)}" fill="none" stroke="#ffcaa0" stroke-width="${(4*n).toFixed(1)}" opacity="${(n*.8).toFixed(3)}"/>`;for(let e=0;e<10;e++){let a=e/10*6.283,o=(20+t*90)*r;i+=`<line x1="${(Math.cos(a)*10*r).toFixed(1)}" y1="${(Math.sin(a)*10*r).toFixed(1)}" x2="${(Math.cos(a)*o).toFixed(1)}" y2="${(Math.sin(a)*o).toFixed(1)}" stroke="#ffd85e" stroke-width="${(3*n).toFixed(1)}" opacity="${n.toFixed(3)}"/>`}return i},muzzleFlash(e,t){let n=Math.max(0,1-t*3),r=e.scale||1;return n<=0?``:`<circle r="${((10+t*6)*r).toFixed(1)}" fill="#fff2b0" opacity="${n.toFixed(3)}"/><path d="M0 0 L ${(28*r).toFixed(1)} ${(-4*r).toFixed(1)} L ${(30*r).toFixed(1)} ${(4*r).toFixed(1)} Z" fill="#ffd85e" opacity="${n.toFixed(3)}"/>`},flashImpact(e,t){let n=Math.max(0,1-t*1.4);return`<rect x="-80" y="-80" width="${(e.VBW||1138)+160}" height="800" fill="${e.tint||`#ffffff`}" opacity="${(n*(e.intensity||.9)).toFixed(3)}"/>`},speedLines(e,t,n){let r=mF(t,.1,.3),i=e.VBW||1138,a=``;for(let e=0;e<9;e++){let t=e/9*640+20,o=(n*320+e*61)%(i+200);a+=`<line x1="${(o-180).toFixed(1)}" y1="${t.toFixed(1)}" x2="${o.toFixed(1)}" y2="${t.toFixed(1)}" stroke="#ffffff" stroke-width="2" opacity="${(r*.32).toFixed(3)}"/>`}return a}},Object.assign(hF,{dustPuff(e,t){let n=1-t,r=e.scale||1,i=``;for(let e=0;e<5;e++){let a=e/5*6.283,o=(10+t*46)*r;i+=`<circle cx="${(Math.cos(a)*o).toFixed(1)}" cy="${(-Math.sin(a)*o*.5).toFixed(1)}" r="${((10+t*16)*r).toFixed(1)}" fill="#b9ad97" opacity="${(n*.5).toFixed(2)}"/>`}return i},splash(e,t){let n=e.scale||1,r=1-t,i=`<path d="M ${(-24*n).toFixed(1)} 0 Q 0 ${(-30*(1-Math.abs(t-.4))*n).toFixed(1)} ${(24*n).toFixed(1)} 0" fill="none" stroke="#8fd0e0" stroke-width="${(3*r).toFixed(1)}" opacity="${r.toFixed(2)}"/>`;for(let e=0;e<6;e++){let a=e/6*Math.PI,o=(14+t*40)*n;i+=`<circle cx="${(Math.cos(a)*o).toFixed(1)}" cy="${(-Math.sin(a)*o).toFixed(1)}" r="${(3*r).toFixed(1)}" fill="#7fb2e0" opacity="${r.toFixed(2)}"/>`}return i},ripple(e,t){let n=e.scale||1,r=``;for(let e=0;e<3;e++){let i=t-e*.18;i<=0||(r+=`<ellipse cx="0" cy="0" rx="${(i*70*n).toFixed(1)}" ry="${(i*24*n).toFixed(1)}" fill="none" stroke="#9fd0e8" stroke-width="2" opacity="${((1-i)*.7).toFixed(2)}"/>`)}return r},glowPulse(e,t){let n=.5+.5*Math.sin(t*Math.PI*4),r=(26+n*14)*(e.scale||1),i=e.tint||`#ffe07a`;return`<circle r="${r.toFixed(1)}" fill="${i}" opacity="${(.18+n*.16).toFixed(2)}"/><circle r="${(r*.5).toFixed(1)}" fill="${i}" opacity="${(.2+n*.2).toFixed(2)}"/>`},shockwaveRing(e,t){let n=e.scale||1,r=1-t;return`<circle r="${(t*130*n).toFixed(1)}" fill="none" stroke="#ffffff" stroke-width="${(8*r).toFixed(1)}" opacity="${(r*.8).toFixed(2)}"/>`},confetti(e,t,n){let r=e.scale||1,i=[`#ff6b5e`,`#2bb3a3`,`#f2b134`,`#5b6ce0`,`#ff7ab0`],a=``;for(let e=0;e<16;e++){let o=(e*37%100-50)*r,s=(-40+t*120+e%5*8)*r,c=(n*6+e)%6.283;a+=`<rect x="${o.toFixed(1)}" y="${s.toFixed(1)}" width="${(7*r).toFixed(1)}" height="${(11*r).toFixed(1)}" fill="${i[e%5]}" transform="rotate(${(c*57).toFixed(0)} ${o.toFixed(1)} ${s.toFixed(1)})" opacity="${(1-t*.6).toFixed(2)}"/>`}return a},sparkleGlint(e,t,n){let r=e.scale||1,i=``;for(let e=0;e<4;e++){let a=e/4*6.283,o=22*r,s=.5+.5*Math.sin(n*8+e*2),c=(5+s*5)*r,l=Math.cos(a)*o,u=Math.sin(a)*o;i+=`<path transform="translate(${l.toFixed(1)} ${u.toFixed(1)})" d="M0 ${-c} L ${c*.3} ${-c*.3} L ${c} 0 L ${c*.3} ${c*.3} L 0 ${c} L ${-c*.3} ${c*.3} L ${-c} 0 L ${-c*.3} ${-c*.3} Z" fill="#fff2b0" opacity="${(s*(1-t)).toFixed(2)}"/>`}return i},coinBurst(e,t,n){let r=e.scale||1,i=``;for(let e=0;e<8;e++){let a=e/8*6.283,o=Math.sin(t*Math.PI),s=Math.cos(a)*t*60*r,c=(-o*70+t*40)*r;i+=`<ellipse cx="${s.toFixed(1)}" cy="${c.toFixed(1)}" rx="${((7+3*Math.sin(n*8+e))*r).toFixed(1)}" ry="${(9*r).toFixed(1)}" fill="#f2b134" stroke="#c98a3a" stroke-width="1" opacity="${(1-t*.7).toFixed(2)}"/>`}return i},heartsPuff(e,t,n){let r=e.scale||1,i=``;for(let e=0;e<5;e++){let a=(t+e*.18)%1,o=(Math.sin(n+e*2)*20+(e-2)*12)*r,s=-a*90*r;i+=`<path transform="translate(${o.toFixed(1)} ${s.toFixed(1)}) scale(${((.5+(1-a)*.5)*r).toFixed(2)})" d="M0 3 C -7 -8 -20 0 0 14 C 20 0 7 -8 0 3 Z" fill="#ff6b8a" opacity="${(1-a).toFixed(2)}"/>`}return i},steamWisp(e,t,n){let r=e.scale||1,i=mF(t,.2,.4),a=``;for(let e=0;e<2;e++){let t=(e?12:-12)*r;a+=`<path d="M ${t} 0 ${[0,1,2,3].map(i=>`Q ${(t+Math.sin(n*1.2+i+e)*14*r).toFixed(1)} ${(-20*(i+.5)*r).toFixed(1)} ${(t+Math.sin(n*1.2+i+1+e)*10*r).toFixed(1)} ${(-20*(i+1)*r).toFixed(1)}`).join(` `)}" fill="none" stroke="#dfeaf2" stroke-width="${(6*r).toFixed(1)}" stroke-linecap="round" opacity="${(i*.4).toFixed(2)}"/>`}return a}})}));function _F(e,t){let n=[],r=Math.max(1,t|0);if(e===`column`){for(let e=0;e<r;e++)n.push({nx:e%2?.16:-.16,row:e,depthRank:r>1?e/(r-1):0});return n}if(e===`line`){for(let e=0;e<r;e++)n.push({nx:r>1?e/(r-1)*2-1:0,row:0,depthRank:0});return n}if(e===`wedge`){let e=0,t=0;for(;e<r;){let i=t*2+1;for(let a=0;a<i&&e<r;a++)n.push({nx:i>1?a/(i-1)*2-1:0,row:t,depthRank:0}),e++;t++}let i=t-1;return n.forEach(e=>e.depthRank=i>0?e.row/i:0),n}let i=Math.ceil(Math.sqrt(r)),a=Math.ceil(r/i);for(let e=0;e<r;e++){let t=e%i,r=Math.floor(e/i);n.push({nx:i>1?t/(i-1)*2-1:0,row:r,depthRank:a>1?r/(a-1):0})}return n}function vF(e,t){let n=e.depthScale||1,r=e.tier===`far`,i=e.cycle||`march`,a=t*(i===`run`||i===`flee`?8:i===`idle`?1.5:5)+(e.phase||0),o=i===`idle`?2:i===`cheer`?1:i===`run`||i===`flee`?20:13,s=Math.sin(a)*o,c=Math.sin(a+Math.PI)*o,l=i===`cheer`,u=i===`flee`?22:i===`idle`?3:9,d=Math.sin(a+Math.PI)*u,f=Math.sin(a)*u,p=i===`run`||i===`flee`?6:0,m=i===`flee`?-3*n:0,h=108*n,g=-h*.42,_=-h*.72,v=-h*.86,y=6*n,b=r?`#2b333f`:yF(`#5c6b52`,e.tone||0),x=r?b:yF(`#c99a6a`,(e.tone||0)*.5),S=Math.max(2,7*n),C=Math.max(2,5.5*n),w=(e,t)=>`<line x1="${e.toFixed(1)}" y1="${g.toFixed(1)}" x2="${(e+t*n+p*n).toFixed(1)}" y2="0" stroke="${b}" stroke-width="${S.toFixed(1)}" stroke-linecap="round"/>`,T=(e,t)=>l?`<line x1="${e.toFixed(1)}" y1="${(_+3*n).toFixed(1)}" x2="${(e+Math.sign(e)*10*n).toFixed(1)}" y2="${(_-20*n).toFixed(1)}" stroke="${b}" stroke-width="${C.toFixed(1)}" stroke-linecap="round"/>`:`<line x1="${e.toFixed(1)}" y1="${(_+3*n).toFixed(1)}" x2="${(e+t*n).toFixed(1)}" y2="${(_+24*n).toFixed(1)}" stroke="${b}" stroke-width="${C.toFixed(1)}" stroke-linecap="round"/>`,E=`<ellipse cx="0" cy="2" rx="${(15*n).toFixed(1)}" ry="${(4*n).toFixed(1)}" fill="#000" opacity="0.12"/>`,D=`<rect x="${(-9*n).toFixed(1)}" y="${_.toFixed(1)}" width="${(18*n).toFixed(1)}" height="${(g-_+4*n).toFixed(1)}" rx="${(6*n).toFixed(1)}" fill="${b}"/>`,O=`<circle cx="${m.toFixed(1)}" cy="${v.toFixed(1)}" r="${(9*n).toFixed(1)}" fill="${x}"/>`+(r?``:`<path d="M ${(m-10*n).toFixed(1)} ${(v-3*n).toFixed(1)} q ${(10*n).toFixed(1)} ${(-12*n).toFixed(1)} ${(20*n).toFixed(1)} 0 z" fill="${b}"/>`);return`<g opacity="${(e.opacity==null?1:e.opacity).toFixed(3)}">${E}${w(-y,s)}${w(y,c)}${D}${T(-10*n,d)}${T(10*n,f)}${O}</g>`}var yF,bF=o((()=>{Tk(),yF=(e,t)=>yk(e,1+t)}));function xF(e,t){return(e||[]).map(e=>DF[e]?DF[e](t):``).join(``)}var SF,CF,wF,TF,EF,DF,OF=o((()=>{SF=[`wet`,`cold`,`hot`,`dirty`,`sleepy`,`inLove`,`confused`,`injured`],CF=(e,t=1)=>e.toFixed(t),wF=(e,t,n,r,i=`#ff6b8a`)=>`<path transform="translate(${CF(e)} ${CF(t)}) scale(${CF(n,3)})" d="M0 3 C -7 -8 -20 0 0 14 C 20 0 7 -8 0 3 Z" fill="${i}" opacity="${CF(r,2)}"/>`,TF=(e,t,n,r,i)=>`<line x1="${CF(e)}" y1="${CF(t)}" x2="${CF(e)}" y2="${CF(t+n)}" stroke="${r}" stroke-width="3" stroke-linecap="round" opacity="${CF(i,2)}"/>`,EF=(e,t,n,r,i,a=1)=>`<text x="${CF(e)}" y="${CF(t)}" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${CF(n)}" text-anchor="middle" fill="${i}" opacity="${CF(a,2)}">${r}</text>`,DF={wet:e=>{let t=``;for(let n=0;n<5;n++){let r=(e*.8+n*.2)%1,i=-34+n*17;t+=TF(i,30+r*70,8,`#7fb2e0`,1-r)}return t},cold:e=>{let t=e*.55%1;return`<ellipse cx="20" cy="6" rx="${CF(5+t*12)}" ry="${CF(3+t*7)}" fill="#e6eef4" opacity="${CF(.55*(1-t),2)}"/>`+TF(-24,-34,6,`#bcd7e4`,.8)+TF(24,-30,6,`#bcd7e4`,.8)},hot:e=>{let t=``;for(let n=0;n<2;n++){let r=(e*.7+n*.5)%1;t+=`<path transform="translate(${CF(n?26:-26)} ${CF(-24+r*30)})" d="M0 -6 C 5 0 5 8 0 8 C -5 8 -5 0 0 -6 Z" fill="#8fd0e0" opacity="${CF(1-r,2)}"/>`}return t},dirty:()=>{let e=``;return[[-20,34,10],[16,46,8],[-6,60,7],[24,30,6]].forEach(([t,n,r])=>e+=`<circle cx="${t}" cy="${n}" r="${r}" fill="#6b5a45" opacity="0.5"/>`),e},sleepy:e=>{let t=``;for(let n=0;n<3;n++){let r=(e*.5+n*.33)%1;t+=EF(18+r*30,-30-r*40,12+r*10,`Z`,`#5b6ce0`,1-r)}return t},inLove:e=>{let t=``;for(let n=0;n<3;n++){let r=(e*.6+n*.34)%1;t+=wF(-14+n*16+Math.sin(e*2+n)*6,-26-r*50,.7+(1-r)*.5,1-r)}return t},confused:e=>EF(0,-38+Math.sin(e*2.5)*4,30,`?`,`#c98a3a`)+`<circle cx="14" cy="-14" r="3" fill="#c98a3a" opacity="${CF(.5+.5*Math.sin(e*4),2)}"/>`,injured:()=>`<rect x="-18" y="-16" width="36" height="12" rx="3" fill="#e8dcc0" transform="rotate(-16)"/><rect x="-3" y="-22" width="6" height="12" fill="#c05050" transform="rotate(-16)"/><rect x="-9" y="-16" width="12" height="4" fill="#c05050" transform="rotate(-16)"/>`}}));function kF(e,t,n,r){let i=e.enter;if(!i||i.type===`carryOver`)return{};let a=i.type,o=i.atPhrase==null?n:t[i.atPhrase].t,s=o+YF,c=e.pos&&e.pos.x||.5,l=a===`walkIn`||a===`runIn`;if(r<o)return l?{opacity:1,xOverride:XF(i.from),forceWalk:a===`walkIn`,forceRun:a===`runIn`}:a===`dropIn`?{opacity:0,yOverride:-280}:a===`riseFrom`?{opacity:0,yOverride:220}:{opacity:0};if(r>=s)return{};let u=Ck((r-o)/YF);if(l)return{opacity:1,xOverride:xk(XF(i.from),c,u),forceWalk:a===`walkIn`,forceRun:a===`runIn`};if(a===`popIn`){let e=Ck(Y((r-o)/.3,0,1));return{opacity:e,scaleMul:.55+.45*e+Math.max(0,Math.sin(e*Math.PI))*.15}}return a===`dropIn`?{opacity:Y(u*2,0,1),yOverride:xk(-280,0,u)}:a===`riseFrom`?{opacity:Y(u*2,0,1),yOverride:xk(220,0,u)}:{opacity:u}}function AF(e,t){let n=_k(e||`x`),r=7+n%5,i=.5+.5*Math.sin(t*(2.3+n%3)),a=Y(i*(.55+.45*Math.sin(t*r))*(Math.sin(t*1.9+n%7)>-.4?1:.15),0,1);return{mOpen:1+a*14,mWidth:12+a*16,mCurve:2+Math.sin(t*4.6)*5}}function jF(e){if(!e||!Array.isArray(e.phrases))throw new nI(`audio.phrases must be an array`);let t=e.phrases.map((e,t)=>{if(typeof e==`string`){let n=e.match(/^(\d+):(\d+(?:\.\d+)?)\s+(.*)$/);if(!n)throw new nI(`phrase ${t} is not "M:SS.d text": ${JSON.stringify(e)}`);return{t:n[1]*60+parseFloat(n[2]),text:n[3]}}if(e&&typeof e==`object`&&typeof e.t==`number`&&typeof e.text==`string`)return{t:e.t,text:e.text};throw new nI(`phrase ${t} must be "M:SS.d text" or {t:Number,text:String}`)});if(t.sort((e,t)=>e.t-t.t),!t.length)throw new nI(`audio.phrases is empty`);return t}function MF(e,t){return e.meta&&typeof e.meta.durationMs==`number`?e.meta.durationMs/1e3:t[t.length-1].t+tI}function NF(e,t){let n=0;for(let r=0;r<e.length;r++)e[r].t<=t+1e-9&&(n=r);return n}function PF(e,t,n){let r=e.map((e,t)=>({s:e,i:t})).sort((e,t)=>e.s.startPhrase-t.s.startPhrase);return r.map((e,i)=>{let a=t[e.s.startPhrase].t,o=i+1<r.length?t[r[i+1].s.startPhrase].t:n;return{scene:e.s,t0:a,t1:o}})}function FF(e,t){let n=vk(e),r=1.2+n()*2;for(;r<=t+.14;){if(t>=r&&t<r+.14)return Math.sin(Math.PI*(t-r)/.14);r+=2.64+n()*3}return 0}function IF(e,t,n,r){let i=`idle`,a=r,o=`idle`,s=r,c=null,l=(e.track||[]).filter(e=>e.action).sort((e,t)=>e.atPhrase-t.atPhrase);for(let e of l)e.atPhrase<=n&&(o=i,s=a,i=e.action,a=t[e.atPhrase].t,c=e);let u={};return c&&(c.speed&&(u.speed=c.speed),c.intensity&&(u.intensity=c.intensity),c.target!=null&&(u.target=c.target)),{action:i,start:a,prevAction:o,prevStart:s,opts:u}}function LF(e,t,n,r){let i=e.facing||`front`,a=-99,o=(e.track||[]).slice().sort((e,t)=>e.atPhrase-t.atPhrase);for(let e of o)if(e.atPhrase<=n&&(e.facing||e.action===`turn`)){let n=e.facing||i;(n!==i||e.action===`turn`)&&(n!==i&&(i=n),a=t[e.atPhrase].t)}let s=Math.abs(r-a),c=a>=0&&s<QF?.15+s/QF*.85:1;return{facing:i,squash:c}}function RF(e,t,n,r,i){let a=nF(e.face)?e.face:`assetBox`,o=e.plane==null?.5:e.plane,s=iP(o,r),c=e.x==null?.5:e.x,l=$P.includes(e.placement)?e.placement:`ground`,u=c*n,d;if(l===`hover`){let n=HP(t,_k(e.label||`x`)%20*.31);u+=n.dx,d=205+s.yShift*.35+n.dy}else d=l===`mounted`?480+s.yShift:GF+s.yShift;let f={kind:`placeholder`,face:a,id:e.id||null,label:e.label||``,size:e.size||`M`,placement:l,source:e.source||`placeholder`,z:o,x:u,y:d,depthScale:s.scale,opacity:s.opacity,blur:s.blur,tint:e.tint||(a===`assetBox`||a===`flagRoundel`||a===`logoTile`?VP(e.label):null),silhouette:o>.72},p=ZP({face:a,size:f.size,depthScale:f.depthScale});return f.anchors={muzzle:{x:u+p.muzzle.dx,y:d+p.muzzle.dy},smoke:{x:u+p.smoke.dx,y:d+p.smoke.dy},center:{x:u+p.center.dx,y:d+p.center.dy}},f.emits=e.emits||[],f}function zF(e,t,n,r,i){let a=Y(e.count|0,1,60),o=KF.includes(e.shape)?e.shape:`grid`,s=qF.includes(e.cycle)?e.cycle:`march`,c=e.plane==null?.6:e.plane,l=e.x==null?.5:e.x,u=(e.width==null?.55:e.width)*n,d=vk(i+`:form:`+(e.id||e.ref||`s`)),f=_F(o,a).map(e=>{let t=Y(c+e.depthRank*.16,0,.98),i=iP(t,r),a=1+(d()-.5)*.08,o=(d()-.5)*.16,f=l*n+e.nx*u*.5*(1-e.depthRank*.14)+(d()-.5)*12,p=GF+i.yShift-e.depthRank*6,m=t>.72?`far`:t>.52?`mid`:`near`;return{x:f,y:p,z:t,depthScale:i.scale*a,opacity:i.opacity,phase:d()*6.283,cycle:s,tone:o,tier:m}}).sort((e,t)=>t.z-e.z);return{kind:`formation`,z:f.reduce((e,t)=>e+t.z,0)/Math.max(1,f.length),id:e.id||null,count:f.length,cycle:s,units:f}}function BF(e,t,n,r,i){let a=Y(e.count|0,1,50),o=e.plane==null?.62:e.plane,s=e.dir===`left`?-1:1,c=(e.speed||1)*42,l=n*1.3,u=-n*.15,d=qF.includes(e.cycle)?e.cycle:`march`,f=vk(i+`:flow:`+(e.id||e.ref||`f`)),p=[];for(let e=0;e<a;e++){let e=((f()*l+t*c*s)%l+l)%l,n=u+e,i=Y(Math.min(e/(l*.08),(l-e)/(l*.08),1),0,1),a=Y(o+(f()-.5)*.08,0,.98),m=iP(a,r);p.push({x:n,y:GF+m.yShift,z:a,depthScale:m.scale*(1+(f()-.5)*.06),opacity:m.opacity*i,phase:f()*6.283,cycle:d,tone:(f()-.5)*.16,tier:a>.72?`far`:a>.52?`mid`:`near`})}return p.sort((e,t)=>t.z-e.z),{kind:`formation`,z:o,id:e.id||null,count:a,cycle:d,units:p}}function VF(e,t,n,r){let i=e.pos&&typeof e.pos.x==`number`?e.pos.x:.5,a=(e.track||[]).filter(e=>e.action===`walk`&&e.to&&typeof e.to.x==`number`).sort((e,t)=>e.atPhrase-t.atPhrase);for(let e=0;e<a.length;e++){let o=a[e],s=t[o.atPhrase].t,c=a[e+1]?t[a[e+1].atPhrase].t:Math.min(s+2.2,n),l=o.to.x;if(r>=c)i=l;else if(r>=s){i=xk(i,l,Ck((r-s)/Math.max(.001,c-s)));break}else break}return i}function HF(e,t){let n=jF(e.audio),r=MF(e,n),i=Y(t,0,r),a=e.meta&&e.meta.aspect||`16:9`,o=Ek(a),s=e.meta&&e.meta.seed||42,c=e.meta&&e.meta.style||{},l=c.bob!==!1,u=c.shadow!==!1,d=NF(n,i),f=PF(e.scenes,n,r),p=f[0];for(let e of f)i>=e.t0-1e-9&&(p=e);let m=null,h=1;if(i<p.t0+eI){let e=f[f.indexOf(p)-1];e&&(m=UF(e.scene),h=Y((i-p.t0)/eI,0,1))}let g=UF(p.scene),_=e.meta&&e.meta.palette||`auto`,v={};e.cast.forEach(e=>v[e.id]=sj(e.params||{},_));let y=p.scene,b={},x=[],S=[],C=UM(y.setup.name)?uM[y.setup.palette||`day`]||`light`:KM[y.setup.name]||`light`;(y.dialogue||[]).forEach(e=>{e.phrase===d&&(e.style===`narrationCard`?S.push({text:e.text||n[e.phrase].text,anchor:e.anchor||`skyBand`,tone:C}):e.style===`fullCard`?S.push({text:e.text||n[e.phrase].text,tone:C,full:!0}):(b[e.speaker]=!0,x.push({ref:e.speaker,text:e.text||n[e.phrase].text,tStart:n[e.phrase].t})))});let w=y.cast||[],T={};w.forEach(e=>{let t=kF(e,n,p.t0,i),a=t.xOverride==null?VF(e,n,r,i):t.xOverride,s=e.pos&&typeof e.pos.z==`number`?e.pos.z:.5,{facing:c,squash:l}=LF(e,n,d,i);T[e.ref]={xn:a,rigX:a*o,z:s,facing:c,squash:l,enterOpacity:t.opacity,forceWalk:t.forceWalk,forceRun:t.forceRun,yOverride:t.yOverride,scaleMul:t.scaleMul}});let E=(e,t)=>{let n=T[e];if(!n)return{aimDX:0,aimDY:0};let r=n.rigX,i=n.z;if(t&&typeof t==`object`&&typeof t.x==`number`)r=t.x*o,typeof t.z==`number`&&(i=t.z);else if(typeof t==`string`){let e=T[t.replace(/^cast:/,``)];e&&(r=e.rigX,i=e.z)}return{aimDX:Y((r-n.rigX)/(o*.35),-1,1),aimDY:Y((n.z-i)*1.4,-1,1)}},D=w.map(e=>{let t=T[e.ref],r=IF(e,n,d,p.t0),a=t.forceRun?`run`:t.forceWalk?`walk`:r.action,o=t.forceWalk||t.forceRun?{speed:t.forceRun?1.5:1.15}:r.opts,u=t.forceWalk||t.forceRun?p.t0:r.start,f={...o};if(eA.includes(a)&&o.target!=null){let t=E(e.ref,o.target);f.aimDX=t.aimDX,f.aimDY=t.aimDY}let m=WF(Wk(a,i,f)),h=WF(Wk(r.prevAction,r.prevStart,r.opts)),g=Ck(Y((i-u)/$F,0,1)),_={};for(let e of Object.keys(Nk))_[e]=xk(h[e],m[e],g);_.blink=FF(s+`:`+e.ref,i);let S=!!b[e.ref];if(S){_=qk(_,Kk(i));let t=x.find(t=>t.ref===e.ref);Object.assign(_,c.mouth===`amplitude`&&t?AF(t.text,i-t.tStart):Gk(i))}!l&&ZF.includes(a)&&(_.bob=0);let C=iP(t.z,y.setup.mode);return{ref:e.ref,params:v[e.ref]||{},pose:_,states:e.state||[],xNorm:t.xn,rigX:t.rigX,z:t.z,facing:t.facing,squash:t.squash,depthScale:C.scale*(t.scaleMul||1),yShift:C.yShift+(t.yOverride||0),opacity:C.opacity*(t.enterOpacity==null?1:t.enterOpacity),blur:C.blur,action:a,speaking:S}}).sort((e,t)=>t.z-e.z);x.forEach(e=>{let t=T[e.ref];e.z=t?t.z:.5,e.facing=t?t.facing:`front`});let O={};(e.props||[]).forEach(e=>O[e.id]=e);let k=(y.setup&&y.setup.dress||[]).map(e=>{let t=O[e.ref]||{id:e.ref,source:`coded`,ref:e.ref},n=e.presentation||`onSurface`,r,i,a;if(n===`heldBy`){let t=(e.slot||``).replace(/^(cast:|hand:)/,``),n=T[t];if(n)r=n.rigX+(n.facing===`left`?-46:46),i=344,a=n.z;else{let t=Jj(e.slot,o);r=t.x,i=t.y,a=t.z}}else{let t=Jj(e.slot,o);r=t.x,i=t.y,a=t.z}return{id:e.ref,spec:t,slot:e.slot,x:r,y:i,z:a,presentation:n,depthScale:iP(a,y.setup.mode).scale}}),A=[];(y.entities||[]).forEach(e=>{e.type===`assetBox`?A.push(RF({...e,face:`assetBox`},i,o,y.setup.mode,s)):e.type===`placeholder`?A.push(RF(e,i,o,y.setup.mode,s)):e.type===`formation`?A.push(zF(e,i,o,y.setup.mode,s)):e.type===`crowdFlow`&&A.push(BF(e,i,o,y.setup.mode,s))});let j=e=>{if(e&&typeof e==`object`&&typeof e.x==`number`)return{x:e.x*o,y:e.y==null?300:e.y};if(typeof e==`string`){if(e.startsWith(`region:`)){let t=xj(e.slice(7),o);return{x:t.x,y:t.y,tint:t.tint}}if(e.startsWith(`prop:`)){let t=k.find(t=>t.id===e.slice(5));if(t)return{x:t.x,y:t.y-40}}if(e.includes(`.`)){let t=Jj(e,o);return{x:t.x,y:t.y}}let t=T[e.replace(/^cast:/,``)];if(t)return{x:t.rigX,y:240};let n=Jj(e,o);return{x:n.x,y:n.y}}return{x:o/2,y:300}},M=(y.overlays||[]).map(e=>{let t=e.atMs==null?n[e.atPhrase==null?d:e.atPhrase].t:e.atMs/1e3,r=(e.hold==null?4:e.hold/1e3)+.6;if(i<t||i>t+r)return null;let a,s={};if(e.region){let t=xj(e.region,o);a={x:t.x,y:t.y},s.tint=e.tint||t.tint}else a=j(e.anchor||`skyBand`);if(e.from&&e.to){let t=j(e.from),n=j(e.to);a=t,s.bx=n.x-t.x,s.by=n.y-t.y,s.tint=e.tint||t.tint||n.tint}return{...e,...s,p:Y((i-t)/.5,0,1),x:a.x,y:a.y}}).filter(Boolean),N=(y.sfx||[]).map(e=>{let t=e.atMs==null?n[e.atPhrase==null?d:e.atPhrase].t:e.atMs/1e3;return{name:e.name,t0:t,gain:e.gain==null?1:e.gain,firing:i>=t&&i<t+.12}}),P=(y.extras||[]).map((e,t)=>{let n=e.z==null?.78:e.z,r=iP(n,y.setup.mode);return{x:(e.x==null?.5:e.x)*o,z:n,depthScale:r.scale,yShift:r.yShift,opacity:r.opacity,shirt:e.shirt||`#98a4b0`,phase:t*1.7%6.28}}),F=null;{let e=f[f.indexOf(p)-1],t=e&&e.scene.transitionOut,n=e=>{let t=cM[e.setup&&e.setup.palette||`day`];return t&&t.ground||`#3a4657`};if(t&&t.type===`flash`)i<p.t0+JF&&(F={type:`flash`,p:Y((i-p.t0)/JF,0,1),tint:t.tint||`#ffffff`});else if(t&&KN(t.type)&&t.type!==`fade`){let r=Math.max(.3,(t.durationMs||1200)/1e3),a=Y((i-p.t0)/r,0,1);if(i<p.t0+r){let r=t.carrySubject?T[t.carrySubject]:null;F={harness:!0,spec:t,p:a,bridge:[n(e.scene),n(p.scene)],subjectFrom:r?{x:r.rigX,y:400}:{x:o*.3,y:420},subjectTo:r?{x:r.rigX,y:400}:{x:o*.7,y:420}}}}else m&&t&&t.type!==`carry`&&(F={type:t.type||`fade`,bands:t.bands||4,direction:t.direction||`left`,p:Y((i-p.t0)/eI,0,1)})}let I=[];(y.effects||[]).forEach(e=>{let t=e.atMs==null?n[e.atPhrase==null?d:e.atPhrase].t:e.atMs/1e3,r=e.hold==null?fF[e.type]||1:e.hold/1e3;if(i<t||i>t+r)return;let a=Y((i-t)/r,0,1),s=e.at?j(e.at):{x:o/2,y:300},c={type:e.type,space:pF(e.type),p:a,t0:t,tint:e.tint,intensity:e.intensity,scale:e.scale,shake:e.shake,VBW:o};if(e.type===`tracerArc`){let t=e.from?j(e.from):s,n=e.to?j(e.to):{x:t.x+120,y:t.y-40};I.push({...c,x:t.x,y:t.y,bx:n.x-t.x,by:n.y-t.y})}else I.push({...c,x:s.x,y:s.y})}),A.forEach(e=>{e.kind===`placeholder`&&(e.emits||[]).forEach(t=>{let n=e.anchors[t.anchor||(t.type===`muzzleFlash`?`muzzle`:`smoke`)]||e.anchors.center;if(t.type===`muzzleFlash`){let r=1.6,a=i%r/r;a<.14&&I.push({type:`muzzleFlash`,space:`world`,x:n.x,y:n.y,p:a/.14,t0:i-a,tint:t.tint,scale:e.depthScale,VBW:o})}else I.push({type:t.type,space:pF(t.type),x:n.x,y:n.y,p:.5,t0:0,tint:t.tint,scale:e.depthScale,VBW:o})})});let ee=0,te=I.filter(e=>!uF.includes(e.type)||++ee<=2),L=0,R=0;te.forEach(e=>{if(!(e.shake===!0||e.shake!==!1&&e.type===`flashImpact`))return;let t=14*(1-Y((i-e.t0)/.3,0,1)),n=_k(`shk`+e.t0.toFixed(3))%100;L+=Math.sin(i*90+n)*t,R+=Math.cos(i*84+n)*t*.7});let ne={VBW:o,sceneT0:p.t0,sceneT1:p.t1,phrases:n,resolveTarget:j,seed:s,cast:D.map(e=>({rigX:e.rigX}))},re=Wj(y.setup.name)?Ij(y.setup.name,y.setup.seed==null?0:y.setup.seed,y.setup.elements||{}):null,ie=y.camera&&!Array.isArray(y.camera)?y.camera:null,ae=!!(ie||re),oe,se=null,ce=null;if(ae){let e=re?{worldW:re.worldW,worldH:re.worldH,viewW:re.viewW,viewH:re.viewH}:{worldW:o,worldH:640,viewW:o,viewH:640},t=ie&&ie.subjects||(re?re.subjects:[]),n=ie||{mode:`generated`,seed:y.setup.seed||1,style:`editorial`},r=mN(vN(n,{duration:p.t1-p.t0,...e,subjects:t}),i-p.t0);if(n.safeZone&&n.safeZone.enabled!==!1){let t=(n.safeZone.x==null?.22:n.safeZone.x)*e.viewW/r.scale,i=(n.safeZone.y==null?.2:n.safeZone.y)*e.viewH/r.scale;r={...r,x:Y(r.x,t,e.worldW-t),y:Y(r.y,i,e.worldH-i)}}if(se=r,oe={cx:r.x,cy:r.y,zoom:r.scale,rotation:r.rotation,pan:!0,subjectId:r.subjectId,worldW:e.worldW,worldH:e.worldH,viewW:e.viewW,viewH:e.viewH},re&&re.focusRing){let e=t.find(e=>e.id===r.subjectId)||t[0];e&&(ce={x:e.x,y:e.y})}(L||R)&&(oe.cx+=L,oe.cy+=R)}else{oe=_P(y,i,ne);let e=f[f.indexOf(p)-1],t=e&&(!Array.isArray(e.scene.camera)&&e.scene.camera||Wj(e.scene.setup.name));if(m&&i<p.t0+eI&&e&&!t){let t=_P(e.scene,e.t1-.001,{...ne,sceneT0:e.t0,sceneT1:e.t1}),n=Y((i-p.t0)/eI,0,1);oe.cx=xk(t.cx,oe.cx,n),oe.cy=xk(t.cy,oe.cy,n),oe.zoom=xk(t.zoom,oe.zoom,n)}(L||R)&&(oe.cx+=L,oe.cy+=R)}let le=y.setup.weather?typeof y.setup.weather==`string`?{type:y.setup.weather}:{...y.setup.weather}:null,ue=null,de=y.setup.timeRamp;if(de){let e=de.overPhrases||2,t=n[Math.min(n.length-1,(y.startPhrase||0)+e)].t,r=Y((i-p.t0)/Math.max(.1,t-p.t0),0,1),a=cM[de.from]||cM.day,s=cM[de.to]||cM.night;ue={k:r,top:bk(a.skyTop,s.skyTop,r),bot:bk(a.skyBot,s.skyBot,r),alpha:.55*r,sun:{x:o*(.2+.6*r),y:130+r*r*380,a:Y(1-r*1.25,0,1)},moon:{x:o*(.78-.5*r),y:430-r*300,a:Y((r-.4)/.45,0,1)}}}let fe=y.mode===`wordReveal`?`wordReveal`:`normal`,pe=null;if(fe===`wordReveal`){let e=y.wordReveal||{},t={...Df,...e},n=bf(y.words||[],(i-p.t0)*1e3,t,180),r=xf(t.swapAnim,n.enterP);if(pe={word:!n.cleared&&n.word?t.allCaps?n.word.toUpperCase():n.word:``,...r,emphasized:n.emphasized,background:t.background,accent:t.accentColor},Math.round(Number(e.trailCount==null?e.ghostWords:e.trailCount)||0)>0){let e=Tf(y.words||[],(i-p.t0)*1e3,t,180);pe.trail={entries:e.entries.map(e=>({...e,text:t.allCaps?e.text.toUpperCase():e.text,transform:e.role===`current`?xf(t.swapAnim,e.enterP):null})),layout:t.trailLayout,muteColor:t.trailMuteColor,exit:t.trailExit}}}let me=fe===`wordReveal`;return{t:i,dur:r,aspect:a,VBW:o,seed:s,phraseIndex:d,mode:fe,wordReveal:pe,background:{to:g,from:m,mix:h},cast:D,extras:P,entities:A,effects:te,bubbles:me?[]:x,cards:me?[]:S,props:k,overlays:M,transition:F,weather:le,timeGrade:ue,sfx:N,style:{bob:l,shadow:u},board:re?{name:y.setup.name,planes:re.planes,worldW:re.worldW,worldH:re.worldH,viewW:re.viewW,viewH:re.viewH,focusRing:re.focusRing,ring:ce,panels:re.panels}:null,camera:{view:oe,pan:se,bgCam:ae?{pan:0,scale:0}:bP(oe,o),coverage:ae?1:xP(y,ne),richness:ae?1:vP(y,ne),traveling:oe.directive===`travel`,shake:{x:L,y:R}}}}function UF(e){return{name:e.setup.name,seed:e.setup.seed==null?7:e.setup.seed,mode:e.setup.mode||`2.5d`,palette:e.setup.palette||`day`}}function WF(e){return{...Nk,...e}}var GF,KF,qF,JF,YF,XF,ZF,QF,$F,eI,tI,nI,rI=o((()=>{Tk(),Uk(),tA(),bj(),QM(),Gj(),wN(),nP(),dP(),DP(),BP(),sF(),gF(),bF(),Dj(),Pf(),GF=590,KF=[`grid`,`wedge`,`column`,`line`],qF=[`march`,`run`,`flee`,`idle`,`cheer`],JF=.18,YF=1,XF=e=>e===`right`?1.16:-.16,ZF=[`idle`,`stand`,`look`,`lookAround`,`turn`,`talkGesture`,`talk`],QF=.06,$F=.25,eI=.5,tI=3.5,nI=class extends Error{constructor(e){super(e),this.name=`SchemaError`}}}));function iI(e,t){let n=Math.round(Y(15*e,12,27));return{fontPx:n,padY:Math.round(n*.5),padX:Math.round(n*.72),maxWidth:Math.min(t*.72,Math.round(250*e)),radius:Math.round(n*1.05),gap:Math.round(9+n*.4)}}function aI(e,t,n,r,i,a){let o=a.radius,s=a.gap,c=e.h*.5+r*.5+s,l=e.h*.5+i*.5+s,u=e.cx+n.x*c-r/2,d=e.midY+n.y*l-i/2;u=Y(u,10,t.w-10-r),d=Y(d,10,t.h-10-i);let f=u+r/2,p=d+i/2,m=e.cx-f,h=e.midY-p,g;return g=Math.abs(h)>=Math.abs(m)?{side:h>0?`down`:`up`,left:Math.round(Y(e.cx,u+o+4,u+r-o-4)-u-9),top:null}:{side:m>0?`right`:`left`,left:null,top:Math.round(Y(e.midY,d+o+4,d+i-o-4)-d-8)},{left:Math.round(u),top:Math.round(d),tail:g}}function oI(e,t,n=34){return Math.max(0,Math.min(e.length,Math.floor(t*n)))}var sI=o((()=>{Tk()}));function cI(e){let t=`gen:`+e;if(pI.has(t))return pI.get(t);let n=_k(e);vk(e);let r=n%360,i=`hsl(${r} 62% 58%)`,a=`hsl(${r} 55% 38%)`,o=`generic`;for(let[t,n]of fI)if(n.test(e)){o=t;break}let s={svg:`<g data-prop>${dI[o]({c:i,d:a})}</g>`,w:80,h:80,icon:o,cached:!1};return pI.set(t,{...s,cached:!0}),s}function lI(e){return e?e.source===`coded`?{svg:`<g data-prop>${(mI[e.ref]||mI.box)()}</g>`,w:90,h:100}:cI(e.prompt||e.ref||`object`):null}function uI(e,t,n,r=1){let i=r;if(e===`hoverIdle`){let e=Math.sin(n*1.6)*6;return{x:t.x,y:t.y+e,scale:i,shadow:`breathe`,floatY:e}}return e===`pinned`?{x:t.x,y:t.y,scale:i,shadow:`none`}:e===`planeAt`?{x:t.x,y:t.y,scale:i,shadow:`soft`}:{x:t.x,y:t.y,scale:i,shadow:`contact`}}var dI,fI,pI,mI,hI=o((()=>{Tk(),dI={coin:e=>`<g><ellipse cx="0" cy="-30" rx="30" ry="30" fill="${e.c}"/><ellipse cx="0" cy="-30" rx="22" ry="22" fill="none" stroke="${e.d}" stroke-width="3"/><text x="0" y="-22" font-size="26" font-weight="800" text-anchor="middle" fill="${e.d}">$</text></g>`,card:e=>`<g><rect x="-38" y="-52" width="76" height="48" rx="7" fill="${e.c}"/><rect x="-38" y="-40" width="76" height="10" fill="${e.d}"/><rect x="-30" y="-18" width="30" height="6" rx="3" fill="#fff" opacity=".85"/></g>`,house:e=>`<g><rect x="-26" y="-42" width="52" height="42" rx="3" fill="${e.c}"/><path d="M-34 -42 L0 -70 L34 -42 Z" fill="${e.d}"/><rect x="-8" y="-24" width="16" height="24" fill="${e.d}"/></g>`,phone:e=>`<g><rect x="-20" y="-64" width="40" height="64" rx="8" fill="${e.c}"/><rect x="-15" y="-58" width="30" height="46" rx="2" fill="#dfe7ee"/><circle cx="0" cy="-7" r="3" fill="#dfe7ee"/></g>`,key:e=>`<g><circle cx="-16" cy="-46" r="14" fill="none" stroke="${e.c}" stroke-width="8"/><rect x="-6" y="-50" width="42" height="8" rx="3" fill="${e.c}"/><rect x="24" y="-42" width="8" height="12" fill="${e.c}"/></g>`,chart:e=>`<g><rect x="-34" y="-8" width="16" height="30" fill="${e.c}"/><rect x="-8" y="-40" width="16" height="62" fill="${e.d}"/><rect x="18" y="-24" width="16" height="46" fill="${e.c}"/></g>`,clock:e=>`<g><circle cx="0" cy="-34" r="30" fill="${e.c}"/><circle cx="0" cy="-34" r="24" fill="#fff" opacity=".9"/><line x1="0" y1="-34" x2="0" y2="-52" stroke="${e.d}" stroke-width="3"/><line x1="0" y1="-34" x2="14" y2="-34" stroke="${e.d}" stroke-width="3"/></g>`,bag:e=>`<g><path d="M-28 -48 Q-28 -60 0 -60 Q28 -60 28 -48 L34 -4 Q34 2 26 2 L-26 2 Q-34 2 -34 -4 Z" fill="${e.c}"/><path d="M-14 -50 Q-14 -66 0 -66 Q14 -66 14 -50" fill="none" stroke="${e.d}" stroke-width="4"/></g>`,generic:e=>`<g><rect x="-30" y="-58" width="60" height="56" rx="12" fill="${e.c}"/><circle cx="0" cy="-30" r="15" fill="${e.d}"/><rect x="-18" y="-14" width="36" height="7" rx="3.5" fill="${e.d}" opacity=".7"/></g>`},fI=[[`coin`,/coin|gold|money|cash/i],[`card`,/card|credit|debit/i],[`house`,/house|home|mortgage|building/i],[`phone`,/phone|mobile|cell/i],[`key`,/key|lock|access/i],[`chart`,/chart|graph|bar|stat/i],[`clock`,/clock|time|watch|hour/i],[`bag`,/bag|shop|purse|wallet/i]],pI=new Map,mI={bookshelf:()=>`<g><rect x="-40" y="-96" width="80" height="96" rx="3" fill="#8a6a45"/><rect x="-34" y="-90" width="68" height="26" fill="#a9855c"/><rect x="-34" y="-60" width="68" height="26" fill="#a9855c"/><rect x="-34" y="-30" width="68" height="26" fill="#a9855c"/>${[-30,-20,-10,2,12,22].map((e,t)=>`<rect x="${e}" y="${-86-t%2*0}" width="7" height="20" fill="${[`#c0563f`,`#3f7fc0`,`#3fae6b`,`#c9a13a`,`#8b5cf6`,`#e08a3a`][t]}"/>`).join(``)}</g>`,table:()=>`<g><rect x="-44" y="-30" width="88" height="10" rx="3" fill="#a9855c"/><rect x="-40" y="-20" width="8" height="20" fill="#8a6a45"/><rect x="32" y="-20" width="8" height="20" fill="#8a6a45"/></g>`,plant:()=>`<g><path d="M-12 0 L-8 -30 L8 -30 L12 0 Z" fill="#c98a3a"/><circle cx="0" cy="-44" r="20" fill="#3f8f63"/><circle cx="-14" cy="-38" r="13" fill="#4fa576"/><circle cx="14" cy="-40" r="12" fill="#357a53"/></g>`,sign:()=>`<g><rect x="-3" y="-40" width="6" height="40" fill="#8a6a45"/><rect x="-30" y="-72" width="60" height="34" rx="4" fill="#eef2f4" stroke="#c7d0d6" stroke-width="2"/></g>`,box:()=>`<g><rect x="-26" y="-48" width="52" height="48" rx="3" fill="#c39a5f"/><path d="M-26 -34 L26 -34" stroke="#9a7440" stroke-width="3"/><path d="M0 -48 L0 0" stroke="#9a7440" stroke-width="2"/></g>`,lamp:()=>`<g><rect x="-2" y="-58" width="4" height="58" fill="#5b636b"/><path d="M-18 -58 L18 -58 L10 -78 L-10 -78 Z" fill="#f2c14e"/></g>`,window:()=>`<g><rect x="-34" y="-64" width="68" height="64" rx="3" fill="#bfe3f2" stroke="#9fb3c0" stroke-width="4"/><path d="M0 -64 L0 0 M-34 -32 L34 -32" stroke="#9fb3c0" stroke-width="3"/></g>`,coin:()=>`<g><ellipse cx="0" cy="-16" rx="16" ry="16" fill="#e6b83a"/><ellipse cx="0" cy="-16" rx="11" ry="11" fill="none" stroke="#b5892a" stroke-width="2"/></g>`}}));function gI(e){let t=e.w||100,n=e.h||100,r=96/Math.max(t,n);return{svg:`<svg x="${(-t*r/2).toFixed(1)}" y="${(-n*r).toFixed(1)}" width="${(t*r).toFixed(1)}" height="${(n*r).toFixed(1)}" viewBox="0 0 ${t} ${n}" preserveAspectRatio="xMidYMax meet" overflow="visible">${e.inner}</svg>`,w:t*r,h:n*r}}var _I,vI,yI,bI=o((()=>{Uk(),bj(),QM(),sI(),DP(),wN(),Gj(),nP(),hI(),BP(),sF(),bF(),gF(),OF(),cN(),Tk(),Pf(),_I=`http://www.w3.org/2000/svg`,vI=()=>document.createElementNS(_I,`g`),yI=class{constructor(e){this.stage=e,this.canvas=document.createElement(`canvas`),this.canvas.className=`v2-bg`,this.svg=document.createElementNS(_I,`svg`),this.svg.setAttribute(`class`,`v2-hero`),this.svg.setAttribute(`preserveAspectRatio`,`xMidYMid meet`),this.boardG=vI(),this.world=vI(),this.extrasG=vI(),this.entitiesG=vI(),this.propsG=vI(),this.wfxG=vI(),this.world.append(this.extrasG,this.entitiesG,this.propsG,this.wfxG),this.stateG=vI(),this.world.appendChild(this.stateG),this.timeG=vI(),this.occG=vI(),this.weatherG=vI(),this.fx=vI(),this.sfxG=vI(),this.transG=vI(),this.wrG=vI(),this.svg.append(this.boardG,this.world,this.timeG,this.occG,this.weatherG,this.fx,this.sfxG,this.transG,this.wrG),this.overlay=document.createElement(`div`),this.overlay.className=`v2-overlay`,e.append(this.canvas,this.svg,this.overlay),this.ctx=this.canvas.getContext(`2d`),this.rigs=new Map,this.bubbleEls=new Map,this.cardEl=null,this._setupCache=new Map,this.assets=null,this._resize=()=>this._sizeCanvas(),window.addEventListener(`resize`,this._resize)}destroy(){window.removeEventListener(`resize`,this._resize),this.stage.innerHTML=``}setAspect(e){this._vbw=Ek(e),this.svg.setAttribute(`viewBox`,`0 0 ${this._vbw} 640`),this._sizeCanvas()}setAssets(e){return this.assets=e||null,this}_sizeCanvas(){let e=this.stage.getBoundingClientRect(),t=Math.min(2,window.devicePixelRatio||1);this.canvas.width=Math.max(1,Math.round(e.width*t)),this.canvas.height=Math.max(1,Math.round(e.height*t))}_setup(e){let t=e.name+`:`+e.seed+`:`+e.mode+`:`+(e.palette||`day`);return this._setupCache.has(t)||this._setupCache.set(t,Qj(e.name,e.seed,e.mode,e.palette)),this._setupCache.get(t)}_rig(e,t,n){let r=Vk(n)?`profile`:`flat`,i=this.rigs.get(e);if(i&&i.family!==r&&(i.rig.remove(),i=null),!i){let t=Dk(r===`profile`?`right`:`front`);this.world.appendChild(t),i={rig:t,paintKey:null,family:r},this.rigs.set(e,i)}let a=JSON.stringify(t);return a!==i.paintKey&&(uj(i.rig,t),i.paintKey=a),i.rig}_groundY(){let e=this.svg.getScreenCTM();if(!e)return this.canvas.height*.9;let t=this.svg.createSVGPoint();t.x=0,t.y=592;let n=this.stage.getBoundingClientRect(),r=this.canvas.height/Math.max(1,n.height);return Y((t.matrixTransform(e).y-n.top)*r,this.canvas.height*.5,this.canvas.height*.98)}render(e){this._aspect!==e.aspect&&(this._aspect=e.aspect,this.setAspect(e.aspect)),this.canvas.width<2&&this._sizeCanvas(),this._t=e.t,this.world.setAttribute(`transform`,yP(e.camera.view,this._vbw));let t=e.camera.view.whip||0;this.world.style.filter=t>.05?`blur(${(t*4).toFixed(1)}px)`:``;let n=this.canvas.width,r=this.canvas.height,i=this._groundY();this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,n,r),e.board?this._board(e):(this.boardG.innerHTML=``,e.background.from&&(this.ctx.globalAlpha=1,$j(this.ctx,this._setup(e.background.from),n,r,i,e.camera.bgCam,e.t)),this.ctx.globalAlpha=e.background.from?e.background.mix:1,$j(this.ctx,this._setup(e.background.to),n,r,i,e.camera.bgCam,e.t),this.ctx.globalAlpha=1),this.extrasG.innerHTML=(e.extras||[]).map(t=>{let n=t.depthScale*.82,r=512+(t.yShift||0),i=Math.sin(e.t*.9+t.phase)*3;return`<g transform="translate(${(t.x+i).toFixed(1)} ${r.toFixed(1)}) scale(${n.toFixed(3)})" opacity="${(t.opacity*.85).toFixed(3)}"><ellipse cx="0" cy="6" rx="42" ry="10" fill="#000" opacity="0.06"/><rect x="-32" y="-150" width="64" height="150" rx="30" fill="${t.shirt}"/><circle cx="0" cy="-178" r="31" fill="#d9ac88"/></g>`}).join(``),this.entitiesG.innerHTML=(e.entities||[]).slice().sort((e,t)=>t.z-e.z).map(e=>{if(e.kind===`placeholder`){let t=this.assets&&e.source?this.assets[e.source]:null,n=t?WP(e,t):XP(e);return`<g transform="translate(${e.x.toFixed(1)} ${e.y.toFixed(1)})" opacity="${e.opacity.toFixed(3)}"${e.blur>.3?` style="filter:blur(${e.blur.toFixed(1)}px)"`:``}>${n}</g>`}return e.kind===`formation`?this._formationSvg(e):``}).join(``),this.propsG.innerHTML=(e.props||[]).map(t=>{let n=t.spec&&t.spec.cache&&this.assets?this.assets[t.spec.cache]:null,r=n?gI(n):lI(t.spec);if(!r)return``;let i=uI(t.presentation,{x:t.x,y:t.y},e.t,t.depthScale||1),a=i.shadow===`none`?``:`<ellipse cx="0" cy="2" rx="34" ry="8" fill="#000" opacity="${i.shadow===`breathe`?(.12+.04*Math.sin(e.t*1.6)).toFixed(3):`0.12`}"/>`;return`<g transform="translate(${t.x.toFixed(1)} ${i.y.toFixed(1)}) scale(${i.scale.toFixed(3)})">${a}${r.svg}</g>`}).join(``);let a=new Set(e.cast.map(e=>e.ref)),o=!(e.style&&e.style.shadow===!1);this.rigs.forEach((e,t)=>{a.has(t)||e.rig.setAttribute(`opacity`,`0`)}),e.cast.forEach(e=>{let t=this._rig(e.ref,e.params,e.facing);t.setAttribute(`opacity`,String(e.opacity==null?1:e.opacity)),t.style.filter=e.blur>.3?`blur(${e.blur.toFixed(1)}px)`:``,Ok(t,e.pose,hj(e.params,e.rigX,{facing:e.facing,squash:e.squash,depthScale:e.depthScale,yShift:e.yShift}));let n=Hk(t,`shadow`);n&&n.setAttribute(`opacity`,o?`0.10`:`0`),this.world.appendChild(t)}),this.stateG.innerHTML=(e.cast||[]).filter(e=>e.states&&e.states.length).map(t=>{let n=592-458*t.depthScale+t.yShift;return`<g transform="translate(${t.rigX.toFixed(1)} ${n.toFixed(1)}) scale(${t.depthScale.toFixed(3)})" opacity="${(t.opacity==null?1:t.opacity).toFixed(2)}">${xF(t.states,e.t)}</g>`}).join(``),this.world.appendChild(this.stateG),this.wfxG.innerHTML=(e.effects||[]).filter(e=>e.space===`world`).map(t=>`<g transform="translate(${t.x.toFixed(1)} ${t.y.toFixed(1)})">${cF(t,t.p,e.t)}</g>`).join(``),this.world.appendChild(this.wfxG),this.sfxG.innerHTML=(e.effects||[]).filter(e=>e.space===`screen`).map(t=>cF(t,t.p,e.t)).join(``),this.fx.innerHTML=(e.overlays||[]).map(t=>`<g transform="translate(${t.x.toFixed(1)} ${t.y.toFixed(1)})">${OP(t,t.p,e.t)}</g>`).join(``),this._timeGrade(e),this._weather(e),this._occluders(e),this._transition(e.transition),this._wordReveal(e);let s=new Set(e.bubbles.map(e=>e.ref));this.bubbleEls.forEach((e,t)=>{s.has(t)||(e.style.display=`none`)}),e.bubbles.forEach(t=>this._bubble(t,e)),this._card(e.cards[0],e)}_board(e){let t=e.board,n=e.camera.pan||{x:t.worldW/2,y:t.worldH/2,scale:1,rotation:0},r=this._vbw/t.viewW,i=640/t.viewH;this.boardG.setAttribute(`transform`,`scale(${r.toFixed(4)} ${i.toFixed(4)})`),this.boardG.innerHTML=t.planes.map(r=>{let i=r.depth===1&&t.focusRing&&t.ring?Lj(t.ring.x,t.ring.y,e.t):``;return`<g transform="${hN(n,r.depth,t.viewW,t.viewH)}">${r.svg}${i}</g>`}).join(``)}_timeGrade(e){let t=e.timeGrade;if(!t){this.timeG.innerHTML=``;return}let n=e.VBW,r=t.sun.a>.01?`<circle cx="${t.sun.x.toFixed(1)}" cy="${t.sun.y.toFixed(1)}" r="58" fill="#ffe08a" opacity="${(t.sun.a*.18).toFixed(2)}"/><circle cx="${t.sun.x.toFixed(1)}" cy="${t.sun.y.toFixed(1)}" r="34" fill="#ffe79a" opacity="${t.sun.a.toFixed(2)}"/>`:``,i=t.moon.a>.01?`<circle cx="${t.moon.x.toFixed(1)}" cy="${t.moon.y.toFixed(1)}" r="24" fill="#eef2f8" opacity="${t.moon.a.toFixed(2)}"/>`:``;this.timeG.innerHTML=`<defs><linearGradient id="v2tg" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${t.top}"/><stop offset="1" stop-color="${t.bot}"/></linearGradient></defs><rect x="0" y="0" width="${n}" height="640" fill="url(#v2tg)" opacity="${t.alpha.toFixed(3)}"/>${r}${i}`}_weather(e){this.weatherG.innerHTML=e.weather?$M(e.weather,e.t,e.VBW):``}_occluders(e){if(!e.camera||!e.camera.traveling){this.occG.innerHTML=``;return}let t=this._vbw,n=(1.2-e.t/.9%1*1.4)*t;this.occG.innerHTML=`<defs><linearGradient id="occEdgeL" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#0e1622" stop-opacity="0.26"/><stop offset="1" stop-color="#0e1622" stop-opacity="0"/></linearGradient><linearGradient id="occEdgeR" x1="1" y1="0" x2="0" y2="0"><stop offset="0" stop-color="#0e1622" stop-opacity="0.26"/><stop offset="1" stop-color="#0e1622" stop-opacity="0"/></linearGradient><filter id="occBlur" x="-40%" y="-40%" width="180%" height="180%"><feGaussianBlur stdDeviation="7"/></filter></defs><rect x="0" y="0" width="${(t*.17).toFixed(0)}" height="640" fill="url(#occEdgeL)"/><rect x="${(t*.83).toFixed(0)}" y="0" width="${(t*.17).toFixed(0)}" height="640" fill="url(#occEdgeR)"/><rect x="${n.toFixed(1)}" y="0" width="30" height="640" rx="10" fill="#0e1622" opacity="0.13" filter="url(#occBlur)"/>`}_wordReveal(e){if(e.mode!==`wordReveal`){this.wrG.innerHTML&&(this.wrG.innerHTML=``);return}let t=e.wordReveal||{},n=this._vbw,r=n/2,i=t.background||`#12151a`,a=e=>String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),o=``;if(t.trail&&t.trail.entries?.length){let e=t.trail.entries.find(e=>e.role===`current`),i=Math.max(40,Math.min(132,n*.9/Math.max(3,(e?.text||``).length*.62))),s=null;t.trail.layout===`inline`&&(s=Ef({entries:t.trail.entries},e=>String(e).length*i*.62,{maxWidth:n*.9,spaceW:i*.28,lineH:i*1.15,trailExit:t.trail.exit}));let c=t.trail.muteColor||`#8e8a80`;o=[...t.trail.entries].sort((e,t)=>t.slot-e.slot).map(e=>{let n=e.role===`current`,o=n?e.transform:null,l=s?s.get(e.wordIndex)||{x:0,y:0}:{x:e.dx*i,y:e.dy*i},u=e.scale*(o?o.scale:1)*(n&&e.emphasized?1.28:1),d=o&&o.ty?o.ty*640:0,f=e.emphasized?t.accent||`#ffd400`:Sf(`#f4f6f8`,c,e.muteP),p=Math.max(0,Math.min(1,e.opacity*(o?o.opacity:1)));return`<g transform="translate(${(r+l.x).toFixed(1)} ${(300+l.y+d).toFixed(1)}) scale(${u.toFixed(3)}) rotate(${(o&&o.rot||0).toFixed(1)})" opacity="${p.toFixed(2)}"><text x="0" y="0" text-anchor="middle" dominant-baseline="central" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${i.toFixed(1)}" fill="${f}">${a(e.text)}</text></g>`}).join(``)}else if(t.word){let e=t.word,i=Math.max(40,Math.min(132,n*.9/Math.max(3,e.length*.62))),s=t.emphasized?1.28:1,c=t.emphasized?t.accent||`#ffd400`:`#f4f6f8`;o=`<g transform="translate(${r.toFixed(1)} ${(300+(t.ty||0)*640).toFixed(1)}) scale(${((t.scale==null?1:t.scale)*s).toFixed(3)}) rotate(${(t.rot||0).toFixed(1)})" opacity="${(t.opacity==null?1:t.opacity).toFixed(2)}"><text x="0" y="0" text-anchor="middle" dominant-baseline="central" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${i.toFixed(1)}" fill="${c}">${a(e)}</text></g>`}this.wrG.innerHTML=`<rect x="0" y="0" width="${n}" height="640" fill="${i}"/>${o}`}_transition(e){if(!e){this.transG.innerHTML=``;return}if(e.harness){let t=AN(e.spec,e.p,{VBW:this._vbw,bridge:e.bridge,subjectFrom:e.subjectFrom,subjectTo:e.subjectTo,subject:e.subjectFrom});this.transG.innerHTML=t.cover;return}let t=this._vbw,n=`#0d1220`,r=e.direction===`right`?1:-1,i=e.p,a=``;if(e.type===`flash`){let n=Math.max(0,1-i*1.1),r=e.tint||`#ffffff`,o=(i*1.5-.25)*t;a=`<rect x="0" y="0" width="${t}" height="640" fill="${r}" opacity="${n.toFixed(3)}"/><path d="M ${o.toFixed(1)} -20 l ${120 .toFixed(1)} 0 l ${(-80).toFixed(1)} ${680 .toFixed(1)} l ${(-120).toFixed(1)} 0 z" fill="${r}" opacity="${(n*.85).toFixed(3)}"/>`}else if(e.type===`fade`)a=`<rect x="0" y="0" width="${t}" height="640" fill="${n}" opacity="${(.55*(1-i)).toFixed(3)}"/>`;else if(e.type===`slide`)a=`<rect x="${(r*i*t).toFixed(1)}" y="0" width="${t}" height="640" fill="${n}" opacity="0.92"/>`;else if(e.type===`irisWipe`){let e=i*Math.hypot(t,640)*.62;a=`<path fill-rule="evenodd" d="M0 0 H ${t} V 640 H 0 Z M ${t/2} 320 m ${(-e).toFixed(1)} 0 a ${e.toFixed(1)} ${e.toFixed(1)} 0 1 0 ${(2*e).toFixed(1)} 0 a ${e.toFixed(1)} ${e.toFixed(1)} 0 1 0 ${(-2*e).toFixed(1)} 0" fill="${n}"/>`}else if(e.type===`whipPan`){let e=Math.sin(i*Math.PI);for(let r=0;r<8;r++){let o=r/8*640,s=(i*1.6-.3)*t+(r%2?20:-20);a+=`<rect x="${s.toFixed(1)}" y="${o.toFixed(1)}" width="${(t*.5).toFixed(1)}" height="${81 .toFixed(1)}" fill="${n}" opacity="${(e*.5).toFixed(2)}"/>`}}else if(e.type===`doorPass`){let e=t/2*i;a=`<rect x="${(-e).toFixed(1)}" y="0" width="${(t/2).toFixed(1)}" height="640" fill="${n}"/><rect x="${(t/2+e).toFixed(1)}" y="0" width="${(t/2).toFixed(1)}" height="640" fill="${n}"/>`}else if(e.type===`objectWipe`){let e=t*.45;a=`<rect x="${(-e+i*(t+2*e)).toFixed(1)}" y="-20" width="${e.toFixed(1)}" height="${680 .toFixed(1)}" rx="18" fill="${n}"/>`}else if(e.type===`matchDissolve`)a=`<rect x="0" y="0" width="${t}" height="640" fill="${n}" opacity="${(Math.sin(i*Math.PI)*.5).toFixed(3)}"/>`;else{let o=Math.max(2,e.bands||4),s=t/o;for(let e=0;e<o;e++){let o=r*Y((i-e*.12)/.6,0,1)*t;a+=`<rect x="${(e*s+o).toFixed(1)}" y="0" width="${(s+1).toFixed(1)}" height="640" fill="${n}"/>`}}this.transG.innerHTML=a}_formationSvg(e){let t=this._t||0;return(e.units||[]).map(e=>`<g transform="translate(${e.x.toFixed(1)} ${e.y.toFixed(1)})">${vF(e,t)}</g>`).join(``)}_bubble(e,t){let n=this.bubbleEls.get(e.ref);n||(n=document.createElement(`div`),n.className=`v2-bubble`,n.innerHTML=`<span class="txt"></span><i class="tail"></i>`,this.overlay.appendChild(n),this.bubbleEls.set(e.ref,n));let r=this.rigs.get(e.ref);if(!r){n.style.display=`none`;return}let i=Hk(r.rig,`head`).getBoundingClientRect(),a=this.stage.getBoundingClientRect();if(!i.width){n.style.display=`none`;return}let o={cx:i.left+i.width/2-a.left,midY:i.top+i.height/2-a.top,h:i.height},s=iI(Y(o.h/135,.6,2),a.width);n.querySelector(`.txt`).textContent=e.text.slice(0,oI(e.text,t.t-e.tStart))||` `,Object.assign(n.style,{display:`inline-block`,fontSize:s.fontPx+`px`,padding:s.padY+`px `+s.padX+`px`,maxWidth:s.maxWidth+`px`,borderRadius:s.radius+`px`,zIndex:String(20+Math.round((1-(e.z==null?.5:e.z))*40))});let c=n.offsetWidth,l=n.offsetHeight,u=aI(o,{w:a.width,h:a.height},{x:0,y:-.9},c,l,s);n.style.left=u.left+`px`,n.style.top=u.top+`px`;let d=n.querySelector(`.tail`);d.className=`tail `+u.tail.side,d.style.left=u.tail.left==null?``:u.tail.left+`px`,d.style.top=u.tail.top==null?``:u.tail.top+`px`}_card(e,t){if(!e){this.cardEl&&(this.cardEl.style.display=`none`);return}this.cardEl||(this.cardEl=document.createElement(`div`),this.overlay.appendChild(this.cardEl));let n=!!e.full;this.cardEl.className=(n?`v2-card-full `:`v2-card `)+(e.tone===`dark`?`v2-card-dark`:`v2-card-light`),this.cardEl.textContent=e.text,this.cardEl.style.display=n?`flex`:`block`}}})),xI,SI,CI,wI,TI,EI=o((()=>{xI={flat:{amb:1,dir:0,len:1},soft:{amb:.85,dir:.4,len:1.4},dramatic:{amb:.5,dir:.9,len:2.6},night:{amb:.35,dir:.6,len:2.2},screenlit:{amb:.6,dir:.5,len:1.2}},SI=[`phone`,`laptop`,`monitor`,`tablet`],CI={condition:[`new`,`worn`,`rusted`,`broken`],fill:[`empty`,`full`],growth:[`seed`,`sprout`,`tree`],temperature:[`cold`,`hot`],damage:[`whole`,`cracked`,`shattered`],life:[`fresh`,`wilted`],size:[`small`,`large`],power:[`dark`,`lit`]},wI=[`stream`,`emitToTarget`,`flowField`,`converge`,`disperse`,`counted`],TI={V1_lighting:{renderers:[`lightShadow`,`glowSvg`,`rimSvg`,`shaftsSvg`,`ambientOcclusion`],looks:Object.keys(xI)},V2_liquids:{renderers:[`fillSvg`,`pourSvg`,`waveSvg`,`dripSvg`,`glassSvg`,`metalSvg`,`wetSvg`]},V3_fire:{renderers:[`flameSvg`,`smokeSvg`,`sparkSvg`,`explosionSvg`,`steamSvg`]},V4_dataviz:{renderers:[`plotOverTime`,`barRace`,`pieGrow`,`sankeySvg`,`scatterSvg`,`networkSvg`,`mapChoropleth`]},V5_type:{renderers:[`wordPop`,`numberMorph`,`kineticHeadline`,`typewriter`,`highlightSweep`,`maskReveal`,`textPath`]},V6_ui:{renderers:[`deviceFrame`,`fakeUI`,`chatThread`,`codeType`,`browserBar`,`notification`],frames:SI},V7_state:{renderers:[`stateChange`],stateSets:Object.keys(CI)},V8_weather:{renderers:[`wetGroundSvg`,`snowAccumulationSvg`,`windEffect`,`fogBankSvg`,`wetCharacterTint`]},V9_continuity:{renderers:[`carryObject`,`motionCarry`,`thematicReprise`]},V10_particles:{renderers:[`particleFlow`,`trailRibbon`],modes:wI}},Object.keys(TI)})),DI,OI,kI,AI,jI,MI,NI,PI,FI,II,LI,RI,zI,BI=o((()=>{({sin:DI,cos:OI,PI:kI,pow:AI,abs:jI,min:MI,max:NI,exp:PI}=Math),FI=[`anticipate`,`overshootSettle`,`snap`,`punch`,`drift`,`cushion`,`elastic`,`linearIntentional`,`flat`],II={primary:{durS:.65,feel:`overshootSettle`,hold:!0},secondary:{durS:.3,feel:`snap`,hold:!1},ambient:{durS:1.1,feel:`drift`,hold:!1},emphasis:{durS:.18,feel:`punch`,hold:!0}},LI=Object.keys(II),RI={polished:{tierFeel:{primary:`overshootSettle`,secondary:`snap`,ambient:`drift`,emphasis:`punch`},staggerMs:75,secondaryMotion:!0,rhythm:1},calm:{tierFeel:{primary:`cushion`,secondary:`drift`,ambient:`drift`,emphasis:`overshootSettle`},staggerMs:110,secondaryMotion:!0,rhythm:.4},energetic:{tierFeel:{primary:`punch`,secondary:`snap`,ambient:`snap`,emphasis:`punch`},staggerMs:50,secondaryMotion:!0,rhythm:1.6},flat:{tierFeel:{primary:`flat`,secondary:`flat`,ambient:`flat`,emphasis:`flat`},staggerMs:0,secondaryMotion:!1,rhythm:0}},zI=Object.keys(RI)})),VI,HI,UI,WI=o((()=>{VI=[`number`,`process`,`comparison`,`thing`,`place`,`person`,`changeOverTime`,`causeEffect`,`concept`,`emphasis`,`list`,`warning`],HI={number:[{id:`counter`,uses:`V4 counter`,note:`the value counts up`},{id:`proportionFill`,uses:`V2 fill / pie`,note:`a proportion filled truthfully`},{id:`oneBigNumber`,uses:`V5 numberMorph`,note:`one big number, held`}],process:[{id:`stepPath`,uses:`method stepPath`,note:`literal ordered sequence`},{id:`causeArrowChain`,uses:`device causeArrowChain`,note:`A→B→C arrows`},{id:`explodedCutaway`,uses:`method explodedView`,note:`exploded / cutaway`}],comparison:[{id:`splitScreen`,uses:`setup split`,note:`both, side by side`},{id:`sideBySideScaled`,uses:`prominence rule`,note:`sized truthfully`},{id:`barCompare`,uses:`V4 barRace`,note:`bars compared`}],thing:[{id:`heroShot`,uses:`placeholder / prop focal`,note:`one clear hero shot`},{id:`labeledObject`,uses:`device connectorLine`,note:`the object, labeled`}],place:[{id:`establishSetup`,uses:`scenes setup`,note:`the place, established`}],person:[{id:`castInRole`,uses:`wardrobe + action`,note:`right wardrobe, relevant action`}],changeOverTime:[{id:`timeline`,uses:`device timelineTicker`,note:`the timeline`},{id:`beforeAfter`,uses:`V7 stateChange`,note:`before / after`},{id:`timeLapse`,uses:`timeRamp`,note:`time-lapse the delta`}],causeEffect:[{id:`arrowAtoB`,uses:`overlay arrow`,note:`A → B`},{id:`domino`,uses:`V10 stream`,note:`domino / chain`},{id:`effectResults`,uses:`V7 stateChange`,note:`the effect visibly resulting`}],concept:[{id:`lightMetaphor`,uses:`ONE metaphor slot`,note:`⚠ only if no literal image exists — instantly readable`},{id:`literalExemplar`,uses:`a concrete example`,note:`show one concrete instance instead`}],emphasis:[{id:`justType`,uses:`V5 + punch feel`,note:`big text + punch + hold — sometimes JUST type`},{id:`bigNumberHold`,uses:`V5 numberMorph`,note:`the number, held`}],list:[{id:`sequentialReveal`,uses:`stagger + numbered`,note:`items reveal in order, numbered`}],warning:[{id:`alertTreatment`,uses:`device alert + red accent`,note:`red accent, consequence shown`},{id:`consequenceShown`,uses:`V7 stateChange`,note:`the consequence visibly`}]},UI=e=>HI[e]||HI.thing,Object.fromEntries(VI.map(e=>[e,UI(e).map(e=>e.id)]))})),GI,KI,qI,JI,YI,XI,ZI,QI,$I,eL,tL,nL,rL=o((()=>{QM(),sF(),tA(),OF(),cN(),gF(),BP(),Gj(),aj(),EI(),BI(),WI(),GI=Object.keys(xI),KI=SI,qI=Object.keys(CI),JI=wI,YI=TI.V4_dataviz.renderers,XI=TI.V5_type.renderers,ZI=[`editorial`,`energetic`,`calm`,`doc`,`documentary`,`dramatic`,`warfilm`],QI=[`panTo`,`punchTo`,`follow`,`hop`,`travel`,`zoomOut`,`establish`,`orbitLite`,`snapZoom`],$I=[`carry`,`fade`,`slide`,`shapeWipe`,`flash`,`irisWipe`,`whipPan`,`doorPass`,`objectWipe`,`matchDissolve`],eL=[`walkIn`,`runIn`,`fadeIn`,`present`,`popIn`,`dropIn`,`riseFrom`,`carryOver`],tL=[`front`,`back`,`left`,`right`],nL=[{path:`setup.name`,type:`enum`,options:YM,default:`openField`,group:`World`,label:`Setup`},{path:`setup.palette`,type:`enum`,options:lM,default:`day`,group:`World`,label:`Palette`},{path:`setup.mode`,type:`enum`,options:[`2.5d`,`2d`],default:`2.5d`,group:`World`,label:`Depth mode`},{path:`setup.seed`,type:`number`,min:0,max:9999,step:1,default:7,group:`World`,label:`Seed`},{path:`entity.face`,type:`enum`,options:tF,default:`assetBox`,group:`Placeholder`,label:`Face`},{path:`entity.label`,type:`text`,default:``,group:`Placeholder`,label:`Label`},{path:`entity.size`,type:`enum`,options:[`S`,`M`,`L`],default:`M`,group:`Placeholder`,label:`Size`},{path:`entity.plane`,type:`number`,min:0,max:1,step:.01,default:.5,group:`Placeholder`,label:`Plane (z)`},{path:`entity.x`,type:`number`,min:0,max:1,step:.01,default:.5,group:`Placeholder`,label:`X`},{path:`entity.placement`,type:`enum`,options:$P,default:`ground`,group:`Placeholder`,label:`Placement`},{path:`entity.tint`,type:`color`,default:`#4a5a6b`,group:`Placeholder`,label:`Tint`},{path:`entity.source`,type:`enum`,options:[`placeholder`,`asset`],default:`placeholder`,group:`Placeholder`,label:`Source`},{path:`cast.action`,type:`enum`,options:$k,default:`idle`,group:`Performance`,label:`Action`},{path:`cast.state`,type:`enum`,options:SF,default:[],multi:!0,group:`Performance`,label:`State overlays`},{path:`cast.facing`,type:`enum`,options:tL,default:`front`,group:`Performance`,label:`Facing`},{path:`cast.enter.type`,type:`enum`,options:eL,default:`walkIn`,group:`Performance`,label:`Entrance`},{path:`effect.type`,type:`enum`,options:lF,default:`burst`,group:`Effects`,label:`Effect`},{path:`effect.tint`,type:`color`,default:`#ffd27a`,group:`Effects`,label:`Effect tint`},{path:`effect.intensity`,type:`number`,min:0,max:1,step:.05,default:.6,group:`Effects`,label:`Intensity`},{path:`setup.weather`,type:`enum`,options:[`none`,...aN],default:`none`,group:`Weather`,label:`Weather`},{path:`setup.weather.intensity`,type:`enum`,options:[`light`,`storm`],default:`light`,group:`Weather`,label:`Intensity`},{path:`setup.timeRamp.from`,type:`enum`,options:lM,default:`goldenHour`,group:`Weather`,label:`Time ramp — from`},{path:`setup.timeRamp.to`,type:`enum`,options:lM,default:`night`,group:`Weather`,label:`Time ramp — to`},{path:`setup.timeRamp.overPhrases`,type:`number`,min:1,max:12,step:1,default:2,group:`Weather`,label:`Time ramp — over phrases`},{path:`overlay.type`,type:`enum`,options:RP,default:`counter`,group:`Overlays`,label:`Overlay`},{path:`overlay.anchor`,type:`text`,default:`skyBand`,group:`Overlays`,label:`Anchor`},{path:`overlay.value`,type:`number`,min:0,max:1e3,step:1,default:60,group:`Overlays`,label:`Value`},{path:`overlay.label`,type:`text`,default:``,group:`Overlays`,label:`Label`},{path:`overlay.tint`,type:`color`,default:`#2BB3A3`,group:`Overlays`,label:`Overlay tint`},{path:`card.type`,type:`enum`,options:zP,default:`titleCard`,group:`Overlays`,label:`Structural card`},{path:`camera.idle`,type:`enum`,options:[`focusFlow`,`drift`,`locked`],default:`focusFlow`,group:`Camera`,label:`Idle motion`},{path:`camera.stylePreset`,type:`enum`,options:ZI,default:`editorial`,group:`Camera`,label:`Style preset`},{path:`camera.directive`,type:`enum`,options:QI,default:`establish`,group:`Camera`,label:`Directive`},{path:`transitionOut.type`,type:`enum`,options:$I.concat([`irisObject`,`strokeSweep`,`slabWipe`,`curtainFall`,`lightWash`,`bandWipe`,`carryTravel`]),default:`carry`,group:`Transitions`,label:`Transition out`},{path:`transitionOut.durationMs`,type:`number`,min:200,max:4e3,step:50,default:1200,group:`Transitions`,label:`Duration (ms)`},{path:`transitionOut.ease`,type:`enum`,options:[`linear`,`smooth`,`smoother`],default:`smoother`,group:`Transitions`,label:`Ease`},{path:`transitionOut.direction`,type:`enum`,options:[`L2R`,`R2L`,`T2B`,`B2T`,`radialIn`,`radialOut`],default:`L2R`,group:`Transitions`,label:`Direction`},{path:`transitionOut.colorMode`,type:`enum`,options:[`bridge`,`incoming`,`token`,`custom`],default:`bridge`,group:`Transitions`,label:`Colour mode`},{path:`transitionOut.carrySubject`,type:`text`,default:``,group:`Transitions`,label:`Carry subject (castId)`},{path:`sfx.name`,type:`text`,default:``,group:`Audio`,label:`SFX cue`},{path:`board.name`,type:`enum`,options:Uj,default:`conceptTriptych`,group:`Boards`,label:`Board`},{path:`setup.element`,type:`bool`,default:!0,group:`Boards`,label:`Element (per manifest)`},{path:`camera.mode`,type:`enum`,options:[`generated`,`manual`,`hybrid`],default:`generated`,group:`PanControl`,label:`Camera mode`},{path:`camera.style`,type:`enum`,options:[`editorial`,`calm`,`energetic`,`dramatic`,`custom`],default:`editorial`,group:`PanControl`,label:`Shot style`},{path:`camera.seed`,type:`number`,min:0,max:9999,step:1,default:1,group:`PanControl`,label:`Shot seed`},{path:`camera.safeZone.enabled`,type:`bool`,default:!0,group:`PanControl`,label:`Safe-zone clamp`},{path:`camera.point.x`,type:`number`,min:-4e3,max:4e3,step:1,default:0,group:`PanControl`,label:`Point · X`},{path:`camera.point.y`,type:`number`,min:-4e3,max:4e3,step:1,default:0,group:`PanControl`,label:`Point · Y`},{path:`camera.point.zoom`,type:`number`,min:.5,max:3,step:.01,default:1,group:`PanControl`,label:`Point · zoom`},{path:`camera.point.rotation`,type:`number`,min:-6,max:6,step:.1,default:0,group:`PanControl`,label:`Point · rotation`},{path:`camera.point.time`,type:`number`,min:0,max:600,step:.1,default:0,group:`PanControl`,label:`Point · time`},{path:`camera.point.ease`,type:`enum`,options:[`linear`,`smooth`,`smoother`],default:`smoother`,group:`PanControl`,label:`Point · ease`},{path:`appearance.hair`,type:`enum`,options:jA,default:`crop`,group:`Wardrobe`,label:`Hair`},{path:`appearance.top`,type:`enum`,options:ij.top,default:`tee`,group:`Wardrobe`,label:`Top`},{path:`appearance.sleeves`,type:`enum`,options:ij.sleeves,default:`short`,group:`Wardrobe`,label:`Sleeves`},{path:`appearance.outerwear`,type:`enum`,options:ij.outerwear,default:`none`,group:`Wardrobe`,label:`Outerwear`},{path:`appearance.bottom`,type:`enum`,options:ij.bottom,default:`jeans`,group:`Wardrobe`,label:`Bottom`},{path:`appearance.footwear`,type:`enum`,options:ij.footwear,default:`sneakers`,group:`Wardrobe`,label:`Footwear`},{path:`appearance.faceShape`,type:`enum`,options:UA,default:`oval`,group:`Wardrobe`,label:`Face shape`},{path:`appearance.facialHair`,type:`enum`,options:KA,default:`none`,group:`Wardrobe`,label:`Facial hair`},{path:`appearance.glasses`,type:`enum`,options:JA,default:`none`,group:`Wardrobe`,label:`Glasses`},{path:`appearance.topColor`,type:`color`,default:`#2b6cb0`,group:`Wardrobe`,label:`Top colour`},{path:`appearance.outerColor`,type:`color`,default:`#455a70`,group:`Wardrobe`,label:`Outerwear colour`},{path:`appearance.bottomColor`,type:`color`,default:`#37455a`,group:`Wardrobe`,label:`Bottom colour`},{path:`appearance.pack`,type:`enum`,options:rj,default:`casual`,group:`Wardrobe`,label:`Wardrobe pack`},{path:`cast.ageHint`,type:`enum`,options:[`childYoung`,`child`,`teen`,`adult`,`elder`],default:`adult`,group:`Wardrobe`,label:`Age`},{path:`appearance.headwear`,type:`enum`,options:XA,default:`none`,group:`Wardrobe`,label:`Headwear`},{path:`appearance.headwearColor`,type:`color`,default:`#37455a`,group:`Wardrobe`,label:`Headwear colour`},{path:`appearance.eyeShape`,type:`enum`,options:QA,default:`round`,group:`Wardrobe`,label:`Eye shape`},{path:`appearance.eyeSpacing`,type:`number`,min:-1,max:1,step:.1,default:0,group:`Wardrobe`,label:`Eye spacing`},{path:`appearance.irisColor`,type:`color`,default:`#243038`,group:`Wardrobe`,label:`Iris colour`},{path:`appearance.lashes`,type:`bool`,default:!1,group:`Wardrobe`,label:`Lashes`},{path:`appearance.browShape`,type:`enum`,options:ej,default:`flat`,group:`Wardrobe`,label:`Brow shape`},{path:`appearance.browThickness`,type:`number`,min:2,max:7,step:.5,default:4,group:`Wardrobe`,label:`Brow thickness`},{path:`appearance.browColor`,type:`color`,default:`#253038`,group:`Wardrobe`,label:`Brow colour`},{path:`appearance.freckles`,type:`bool`,default:!1,group:`Wardrobe`,label:`Freckles`},{path:`appearance.blush`,type:`bool`,default:!1,group:`Wardrobe`,label:`Blush`},{path:`appearance.earrings`,type:`bool`,default:!1,group:`Wardrobe`,label:`Earrings`},{path:`appearance.wrinkles`,type:`bool`,default:!1,group:`Wardrobe`,label:`Wrinkles (age)`},{path:`lighting.look`,type:`enum`,options:GI,default:`soft`,group:`Lighting`,label:`Lighting look`},{path:`lighting.light.type`,type:`enum`,options:[`sun`,`point`,`spot`,`ambient`],default:`sun`,group:`Lighting`,label:`Key light`},{path:`lighting.light.x`,type:`number`,min:0,max:1,step:.01,default:.3,group:`Lighting`,label:`Light X`},{path:`lighting.light.y`,type:`number`,min:0,max:1,step:.01,default:.1,group:`Lighting`,label:`Light Y (height)`},{path:`lighting.light.color`,type:`color`,default:`#fff2cc`,group:`Lighting`,label:`Light colour`},{path:`element.glow.color`,type:`color`,default:`#ffd27a`,group:`Lighting`,label:`Glow colour`},{path:`element.glow.radius`,type:`number`,min:0,max:200,step:5,default:60,group:`Lighting`,label:`Glow radius`},{path:`element.rim`,type:`bool`,default:!1,group:`Lighting`,label:`Rim light`},{path:`liquid.type`,type:`enum`,options:[`fill`,`pour`,`flow`,`drip`,`wave`],default:`fill`,group:`Materials`,label:`Liquid`},{path:`liquid.pct`,type:`number`,min:0,max:1,step:.01,default:.5,group:`Materials`,label:`Fill level`},{path:`liquid.color`,type:`color`,default:`#4aa3c4`,group:`Materials`,label:`Liquid colour`},{path:`material.shader`,type:`enum`,options:[`none`,`glass`,`metal`,`wet`],default:`none`,group:`Materials`,label:`Material`},{path:`fire.type`,type:`enum`,options:[`flame`,`smoke`,`spark`,`explosion`,`steam`],default:`flame`,group:`Fire`,label:`Fire/energy`},{path:`fire.size`,type:`number`,min:10,max:200,step:5,default:60,group:`Fire`,label:`Size`},{path:`smoke.variant`,type:`enum`,options:[`smolder`,`puff`,`billow`,`wisp`],default:`billow`,group:`Fire`,label:`Smoke variant`},{path:`dataviz.type`,type:`enum`,options:YI,default:`plotOverTime`,group:`Data-viz`,label:`Chart`},{path:`dataviz.data`,type:`text`,default:`[]`,group:`Data-viz`,label:`Data (JSON)`},{path:`type.effect`,type:`enum`,options:XI,default:`wordPop`,group:`Typography`,label:`Kinetic type`},{path:`type.text`,type:`text`,default:``,group:`Typography`,label:`Text`},{path:`type.stagger`,type:`number`,min:0,max:.5,step:.01,default:.15,group:`Typography`,label:`Stagger`},{path:`ui.device`,type:`enum`,options:KI,default:`phone`,group:`Screen/UI`,label:`Device frame`},{path:`ui.content`,type:`enum`,options:[`fakeUI`,`chatThread`,`codeType`,`browserBar`,`notification`,`graphOnScreen`],default:`fakeUI`,group:`Screen/UI`,label:`Screen content`},{path:`state.set`,type:`enum`,options:qI,default:`condition`,group:`Object-state`,label:`State set`},{path:`state.shakeIntensity`,type:`number`,min:0,max:20,step:1,default:6,group:`Object-state`,label:`Shake`},{path:`state.popScale`,type:`number`,min:1,max:2,step:.05,default:1.25,group:`Object-state`,label:`Pop scale`},{path:`weather.consequence`,type:`enum`,options:[`wetGround`,`snowAccumulation`,`windEffect`,`wetCharacter`,`fogBank`],default:`wetGround`,group:`Weather`,label:`Consequence`},{path:`weather.windStrength`,type:`number`,min:0,max:3,step:.1,default:1,group:`Weather`,label:`Wind strength`},{path:`continuity.mode`,type:`enum`,options:[`carryObject`,`motionCarry`,`thematicReprise`],default:`carryObject`,group:`Continuity`,label:`Carry mode`},{path:`particles.mode`,type:`enum`,options:JI,default:`stream`,group:`Particles`,label:`Flow mode`},{path:`particles.count`,type:`number`,min:1,max:300,step:1,default:20,group:`Particles`,label:`Count`},{path:`particles.particleType`,type:`enum`,options:[`dot`,`coin`,`arrow`],default:`dot`,group:`Particles`,label:`Particle`},{path:`particles.rate`,type:`number`,min:.1,max:4,step:.1,default:1,group:`Particles`,label:`Rate`},{path:`finish.profile`,type:`enum`,options:zI,default:`polished`,group:`Finish`,label:`Finish profile`},{path:`element.tier`,type:`enum`,options:LI,default:`secondary`,group:`Finish`,label:`Motion tier`},{path:`element.feel`,type:`enum`,options:FI,default:`flat`,group:`Finish`,label:`Feel (override)`},{path:`element.feelParams.overshootPct`,type:`number`,min:0,max:.4,step:.01,default:.08,group:`Finish`,label:`Overshoot %`},{path:`element.feelParams.windupPct`,type:`number`,min:0,max:.3,step:.01,default:.08,group:`Finish`,label:`Wind-up %`},{path:`element.feelParams.settleMs`,type:`number`,min:0,max:500,step:10,default:150,group:`Finish`,label:`Settle (ms)`},{path:`element.feelParams.intensity`,type:`number`,min:0,max:2,step:.1,default:1,group:`Finish`,label:`Feel intensity`},{path:`finish.staggerMs`,type:`number`,min:0,max:200,step:5,default:75,group:`Finish`,label:`Stagger (ms)`},{path:`finish.secondaryMotion`,type:`bool`,default:!0,group:`Finish`,label:`Secondary motion`},{path:`beat.simultaneous`,type:`bool`,default:!1,group:`Finish`,label:`Enter simultaneously`},{path:`beat.type`,type:`enum`,options:VI,default:`thing`,group:`Taste`,label:`Beat type`},{path:`beat.emphasis`,type:`bool`,default:!1,group:`Taste`,label:`Emphasis beat`},{path:`beat.focalSide`,type:`enum`,options:[`left`,`center`,`right`],default:`left`,group:`Taste`,label:`Focal position`},{path:`beat.deliberateCenter`,type:`bool`,default:!1,group:`Taste`,label:`Deliberate center`},{path:`beat.intensity`,type:`number`,min:0,max:1,step:.05,default:.4,group:`Taste`,label:`Beat intensity`}],Object.fromEntries(nL.map(e=>[e.path,e]))})),iL=o((()=>{rI(),bI(),QM(),Gj(),tA(),BP(),nP(),gF(),cN(),OF(),sF(),bj(),rL()})),aL=o((()=>{iL()})),oL=o((()=>{iL(),new Set(YM)})),sL=o((()=>{new Set(`the a an and or but of to in on at for with by from as is are was were be been it its this that these those they them their you your we our i he she his her not no yes so if then than into over about after before while when where why how what which who whom can could will would should may might must do does did have has had get got make makes made just very more most some any all each every one two three now here there also only even because through during them then meanwhile feel feels feeling think thinks really actually basically thing things stuff time times way ways`.split(` `))})),cL=o((()=>{sL(),new Set(`the a an and or of to in on at for with by from as is are was were it its this that your you our their about`.split(` `))}));function lL(e){return String(e||``).trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function uL(e,t=`flat`){return`${t}-${lL(e)}`}var dL=o((()=>{})),fL=o((()=>{cL(),new Set(`the a an and or of to in on at for with by from as is are was were it its this that so now then`.split(` `))})),pL=o((()=>{iL(),oL(),cL(),sL(),Pf(),fL()})),mL=o((()=>{iL(),aL()})),hL=o((()=>{iL(),aL(),oL(),pL(),mL()}));function gL(e={}){let t=new Map(Object.entries(e));return{read:()=>Object.fromEntries(t),write:e=>{t.clear();for(let[n,r]of Object.entries(e))t.set(n,r)}}}function _L(){return{read(){try{return JSON.parse(localStorage.getItem(bL)||`{}`)||{}}catch{return{}}},write(e){try{localStorage.setItem(bL,JSON.stringify(e))}catch{}}}}function vL(){return typeof localStorage<`u`?_L():gL()}function yL(e=vL()){let t=()=>e.read();return{has(e){return Object.prototype.hasOwnProperty.call(t(),e)},get(e){return t()[e]||null},put(n,r){let i=t();return i[n]={inner:r.inner,w:r.w,h:r.h},e.write(i),n},keys(){return Object.keys(t())},resolverFor(e){let n=t(),r={};return e.forEach(e=>{n[e]&&(r[e]=n[e])}),r}}}var bL,xL=o((()=>{bL=`aivw.v2.assets`}));function SL(e,t,n={}){let r=n.style||`flat`,i=!1,a=(e.scenes||[]).map(e=>{if(!e.entities?.length)return e;let n=!1,a=e.entities.map(e=>{if(e.type!==`assetBox`&&e.type!==`placeholder`)return e;let i=lL(e.label);if(!i)return e;let a=uL(i,r),o=t.has(a)?`${TL}${a}`:`placeholder`;return e.source===o?e:(n=!0,{...e,source:o})});return n?(i=!0,{...e,entities:a}):e});return i?{...e,scenes:a}:e}function CL(e){let t=new Set;return(e.scenes||[]).forEach(e=>(e.entities||[]).forEach(e=>{let n=DL(e.source);n&&t.add(n)})),(e.props||[]).forEach(e=>{let n=DL(e.cache);n&&t.add(n)}),[...t]}function wL(e,t){let n={};return CL(e).forEach(e=>{let r=t.get(e);r&&(n[`${TL}${e}`]=r)}),n}var TL,EL,DL,OL=o((()=>{dL(),TL=`vault:`,EL=e=>typeof e==`string`&&e.startsWith(TL),DL=e=>EL(e)?e.slice(6):null})),kL=o((()=>{dL(),xL(),OL()})),AL,jL=o((()=>{xL(),AL=yL(vL())}));function ML(e,t,n){return new Promise((t,n)=>{let r=new Blob([e],{type:`image/svg+xml;charset=utf-8`}),i=URL.createObjectURL(r),a=new Image;a.onload=()=>{URL.revokeObjectURL(i),t(a)},a.onerror=()=>{URL.revokeObjectURL(i),n(Error(`v2 svg raster failed`))},a.src=i})}function NL(e,t,n,r){let i=(t||[]).map(e=>e.text).filter(Boolean).join(` `).trim();if(!i)return;let a=Math.max(14,Math.round(r*.03));e.font=`700 ${a}px Nunito, system-ui, sans-serif`;let o=n*.86,s=i.split(/\s+/),c=[],l=``;for(let t of s){let n=l?`${l} ${t}`:t;e.measureText(n).width>o&&l?(c.push(l),l=t):l=n}l&&c.push(l);let u=a*1.3,d=a*.7,f=a*.5,p=Math.min(o+d*2,Math.max(...c.map(t=>e.measureText(t).width))+d*2),m=c.length*u+f*2,h=(n-p)/2,g=r-m-r*.06,_=Math.min(18,m/2);e.fillStyle=`rgba(20,24,30,0.82)`,e.beginPath(),e.moveTo(h+_,g),e.arcTo(h+p,g,h+p,g+m,_),e.arcTo(h+p,g+m,h,g+m,_),e.arcTo(h,g+m,h,g,_),e.arcTo(h,g,h+p,g,_),e.closePath(),e.fill(),e.fillStyle=`#f4f6f8`,e.textAlign=`center`,e.textBaseline=`middle`,c.forEach((t,r)=>e.fillText(t,n/2,g+f+u*(r+.5)))}function PL(e,t,n){let r=SL(e,AL),i=wL(r,AL),a=document.createElement(`div`);a.style.cssText=`position:fixed;left:-99999px;top:0;width:${t}px;height:${n}px;`,document.body.appendChild(a);let o=new yI(a);o.setAspect(r.meta?.aspect||`16:9`),o.setAssets(i),o.svg.setAttribute(`width`,String(t)),o.svg.setAttribute(`height`,String(n));let s=document.createElement(`canvas`);s.width=t,s.height=n;let c=s.getContext(`2d`),l=new XMLSerializer;return{width:t,height:n,async frameAt(e){let i=HF(r,Math.max(0,e));o.render(i),c.clearRect(0,0,t,n),c.fillStyle=`#0b0e12`,c.fillRect(0,0,t,n);try{c.drawImage(o.canvas,0,0,t,n)}catch{}try{let e=await ML(l.serializeToString(o.svg),t,n);c.drawImage(e,0,0,t,n)}catch{}return NL(c,i.bubbles,t,n),s},close(){try{o.destroy()}catch{}try{a.remove()}catch{}}}}var FL=o((()=>{hL(),kL(),jL()}));function IL(e,t,n,r,i){let a=e.createLinearGradient(0,0,0,n);a.addColorStop(0,r),a.addColorStop(1,i),e.fillStyle=a,e.fillRect(0,0,t,n)}function LL(e){let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)}function RL(e){let t=/^#?([0-9a-f]{6})$/i.exec(String(e||``).trim());if(!t)return null;let n=parseInt(t[1],16);return{r:n>>16&255,g:n>>8&255,b:n&255}}function zL(e,t,n){let r=RL(e),i=RL(t);if(!r||!i)return e;let a=e=>Math.round(r[e]+(i[e]-r[e])*n);return`rgb(${a(`r`)},${a(`g`)},${a(`b`)})`}function BL(e,t){let n=RL(e);return n?`rgba(${n.r},${n.g},${n.b},${t})`:`rgba(0,0,0,${t})`}function VL(e,t,n,r,i){let a,o,s,c,l;if(YL(i)){let e=i[0]||QL[0],t=i[1]||QL[1];a=e,o=zL(e,t,.4),s=BL(t,.28),c=BL(t,.35),l=BL(t,0)}else a=`#0a1a3f`,o=`#123a8a`,s=`rgba(120,170,255,0.28)`,c=`rgba(80,140,255,0.35)`,l=`rgba(80,140,255,0)`;IL(e,t,n,a,o);let u=Math.max(28,Math.min(t,n)*.09),d=r*u*.35%u;e.lineWidth=Math.max(1,Math.min(t,n)*.0022),e.strokeStyle=s,e.beginPath();for(let r=-u+d%u;r<=t+u;r+=u)e.moveTo(r,0),e.lineTo(r,n);for(let r=-u+d;r<=n+u;r+=u)e.moveTo(0,r),e.lineTo(t,r);e.stroke();let f=e.createRadialGradient(t/2,n*.45,0,t/2,n*.45,Math.max(t,n)*.6);f.addColorStop(0,c),f.addColorStop(1,l),e.fillStyle=f,e.fillRect(0,0,t,n)}function HL(e,t,n,r){IL(e,t,n,`#050716`,`#0b1030`);let i=[{c:`rgba(90,220,200,0.55)`,fx:.07,fy:.05,px:.3,py:.35,r:.55},{c:`rgba(140,90,240,0.5)`,fx:.05,fy:.08,px:.7,py:.5,r:.6},{c:`rgba(60,140,255,0.5)`,fx:.09,fy:.06,px:.5,py:.7,r:.5},{c:`rgba(240,120,190,0.4)`,fx:.06,fy:.09,px:.4,py:.2,r:.45}];e.globalCompositeOperation=`lighter`;for(let a=0;a<i.length;a++){let o=i[a],s=t*(o.px+.18*Math.sin(r*o.fx*Math.PI*2+a)),c=n*(o.py+.16*Math.cos(r*o.fy*Math.PI*2+a*1.7)),l=Math.max(t,n)*o.r,u=e.createRadialGradient(s,c,0,s,c,l);u.addColorStop(0,o.c),u.addColorStop(1,`rgba(0,0,0,0)`),e.fillStyle=u,e.fillRect(0,0,t,n)}e.globalCompositeOperation=`source-over`}function UL(e,t,n,r){IL(e,t,n,`#1a1130`,`#2a0f3a`);let i=[{c:`rgba(255,120,80,0.55)`,bx:.25,by:.3},{c:`rgba(255,80,160,0.5)`,bx:.75,by:.28},{c:`rgba(120,90,255,0.5)`,bx:.7,by:.75},{c:`rgba(80,200,255,0.45)`,bx:.28,by:.72}];e.globalCompositeOperation=`lighter`;for(let a=0;a<i.length;a++){let o=i[a],s=t*(o.bx+.1*Math.sin(r*.15*Math.PI+a*1.3)),c=n*(o.by+.1*Math.cos(r*.13*Math.PI+a*.9)),l=Math.max(t,n)*(.5+.06*Math.sin(r*.2+a)),u=e.createRadialGradient(s,c,0,s,c,l);u.addColorStop(0,o.c),u.addColorStop(1,`rgba(0,0,0,0)`),e.fillStyle=u,e.fillRect(0,0,t,n)}e.globalCompositeOperation=`source-over`}function WL(e,t,n,r,i){let a;if(YL(i)){let r=i[0]||$L[0],o=i[1]||$L[1];IL(e,t,n,r,zL(r,o,.18)),a=e=>BL(o,e)}else IL(e,t,n,`#0b1226`,`#152244`),a=e=>`rgba(150,190,255,${e})`;let o=n*1.25;e.globalCompositeOperation=`lighter`;for(let i=0;i<46;i++){let s=.4+LL(i)*.9,c=(.01+LL(i+99)*.04)*Math.min(t,n),l=(LL(i+7)+.05*Math.sin(r*.3+i))*t,u=n+c-(r*s*n*.06+LL(i+31)*o)%o,d=.15+LL(i+53)*.4,f=e.createRadialGradient(l,u,0,l,u,c);f.addColorStop(0,a(d)),f.addColorStop(1,a(0)),e.fillStyle=f,e.beginPath(),e.arc(l,u,c,0,Math.PI*2),e.fill()}e.globalCompositeOperation=`source-over`}function GL(e,t,n,r){IL(e,t,n,`#04122a`,`#0a2e4a`);for(let i of[{c:`rgba(30,140,200,0.5)`,amp:.05,base:.62,k:1.3,spd:.5},{c:`rgba(40,190,180,0.5)`,amp:.06,base:.72,k:1,spd:-.7},{c:`rgba(80,110,230,0.55)`,amp:.07,base:.82,k:.8,spd:.9}]){e.beginPath(),e.moveTo(0,n);let a=Math.max(6,t/120);for(let o=0;o<=t;o+=a){let a=o/t*Math.PI*2*i.k+r*i.spd,s=n*i.base+Math.sin(a)*n*i.amp;e.lineTo(o,s)}e.lineTo(t,n),e.closePath(),e.fillStyle=i.c,e.fill()}}function KL(e,t,n,r,i){let a=YL(i),o=a?i[0]||eR[0]:`#e8e4da`,s=a?i[1]||eR[1]:`#57503f`,c=Math.floor(Math.max(0,Number(r)||0)/XL)%ZL*977,l=Math.min(t,n)/360;IL(e,t,n,o,zL(o,s,.08));let u=e.createRadialGradient(t/2,n/2,Math.min(t,n)*.35,t/2,n/2,Math.max(t,n)*.75);u.addColorStop(0,BL(s,0)),u.addColorStop(1,BL(s,.1)),e.fillStyle=u,e.fillRect(0,0,t,n);for(let r=0;r<6;r++){let i=LL(c+11+r)*t,a=LL(c+23+r)*n,o=Math.max(t,n)*(.1+.16*LL(c+37+r)),l=e.createRadialGradient(i,a,0,i,a,o);l.addColorStop(0,BL(s,.055)),l.addColorStop(1,BL(s,0)),e.fillStyle=l,e.fillRect(0,0,t,n)}let d=Math.max(24,Math.min(t,n)*.075),f=(LL(c+3)-.5)*3*l,p=(LL(c+4)-.5)*3*l;e.lineWidth=Math.max(1,l*1.1),e.strokeStyle=BL(s,.16),e.beginPath();for(let r=-d+f;r<=t+d;r+=d)e.moveTo(r,0),e.lineTo(r,n);for(let r=-d+p;r<=n+d;r+=d)e.moveTo(0,r),e.lineTo(t,r);e.stroke(),e.fillStyle=BL(s,.5);for(let r=0;r<42;r++){let i=LL(c+101+r)*t,a=LL(c+211+r)*n,o=(.8+1.8*LL(c+307+r))*l;e.globalAlpha=.22+.38*LL(c+401+r),e.fillRect(i,a,o,o)}e.strokeStyle=BL(s,.3),e.lineWidth=Math.max(.6,l*.7);for(let r=0;r<14;r++){let i=LL(c+503+r)*t,a=LL(c+601+r)*n,o=LL(c+701+r)*Math.PI*2,s=(4+6*LL(c+809+r))*l;e.globalAlpha=.15+.2*LL(c+907+r),e.beginPath(),e.moveTo(i,a),e.lineTo(i+Math.cos(o)*s,a+Math.sin(o)*s),e.stroke()}for(let r=0;r<160;r++){let i=LL(c+1103+r)*t,a=LL(c+1301+r)*n,o=r%2==0;e.fillStyle=o?BL(s,1):`#ffffff`,e.globalAlpha=o?.04+.05*LL(c+1409+r):.05+.07*LL(c+1511+r),e.fillRect(i,a,l,l)}e.globalAlpha=1}function qL(e){if(typeof e!=`string`||!e.startsWith(`anim|`))return null;let[,t,...n]=e.split(`|`);return tR[t]?{key:t,colors:n}:null}function JL(e,t,n,r,i){let a=qL(t);return a?(tR[a.key].draw(e,n,r,Number(i)||0,a.colors),!0):!1}var YL,XL,ZL,QL,$L,eR,tR,nR=o((()=>{YL=e=>Array.isArray(e)&&e.length>0,XL=.17,ZL=8,QL=[`#0a1a3f`,`#3b7dff`],$L=[`#0b1226`,`#96beff`],eR=[`#e8e4da`,`#57503f`],tR={grid:{label:`Blue Grid`,draw:VL,css:`linear-gradient(180deg, #0a1a3f, #123a8a)`,tunable:[{key:`base`,label:`Background`,default:QL[0]},{key:`accent`,label:`Grid & glow`,default:QL[1]}]},aurora:{label:`Aurora`,draw:HL,css:`radial-gradient(circle at 35% 40%, rgba(90,220,200,0.7), rgba(140,90,240,0.5) 45%, #0b1030 80%)`},mesh:{label:`Mesh`,draw:UL,css:`radial-gradient(circle at 30% 30%, rgba(255,120,80,0.7), rgba(120,90,255,0.5) 55%, #2a0f3a 85%)`},bokeh:{label:`Bokeh`,draw:WL,css:`radial-gradient(circle at 60% 70%, rgba(150,190,255,0.5), #152244 70%)`,tunable:[{key:`base`,label:`Background`,default:$L[0]},{key:`accent`,label:`Dots`,default:$L[1]}]},waves:{label:`Waves`,draw:GL,css:`linear-gradient(180deg, #0a2e4a 40%, rgba(40,190,180,0.6) 70%, #04122a)`},paper:{label:`Paper`,draw:KL,css:`linear-gradient(180deg, #e8e4da, #ded9cd)`,tunable:[{key:`base`,label:`Paper`,default:eR[0]},{key:`accent`,label:`Grid & flecks`,default:eR[1]}]}}}));function rR(e,t,n,r,i){let a=typeof t==`string`?t:``;if(!JL(e,a,n,r,(Number(i)||0)/1e3)){if(a.startsWith(`radial|`)||a.startsWith(`linear|`)){let t=a.split(`|`),i;if(t[0]===`radial`){let a=t.slice(1);i=e.createRadialGradient(n/2,r*.42,Math.min(n,r)*.05,n/2,r*.5,Math.max(n,r)*.72),iR(i,a)}else{let a=Number(t[1])||90,o=t.slice(2),s=(a-90)*Math.PI/180,c=Math.max(n,r)/2,l=Math.cos(s)*c,u=Math.sin(s)*c;i=e.createLinearGradient(n/2-l,r/2-u,n/2+l,r/2+u),iR(i,o)}e.fillStyle=i}else e.fillStyle=a||`#ffffff`;e.fillRect(0,0,n,r)}}function iR(e,t){let n=t.length;t.forEach((t,r)=>e.addColorStop(n===1?0:r/(n-1),t))}function aR(e){let t=Number(e?.videoWidth||e?.width||e?.naturalWidth||e?.displayWidth)||0,n=Number(e?.videoHeight||e?.height||e?.naturalHeight||e?.displayHeight)||0;return{w:Math.max(1,t),h:Math.max(1,n)}}function oR(e,t){let n=Math.max(0,(t-(e.appearMs||0))/1e3),r=Number(e.speed)>0?Number(e.speed):1,i=Math.max(0,Number(e.trimStartSec)||0),a=i+n*r,o=Number(e.durationSec)||0;if(o>0){let t=Math.max(.05,o-i);a=e.loop===!1?Math.min(a,o-.05):i+(a-i)%t}return a}function sR(e,t){if(Array.isArray(e.wordTimes)&&Number.isFinite(Number(e.wordTimes[t])))return Number(e.wordTimes[t]);let n=e.anim?.speedMs||180;return(e.appearMs||0)+t*n}function cR(e,t){return String(e.text||``).split(/\s+/).filter(Boolean).map((n,r)=>{let i=sR(e,r),a=t-i;return{text:n,start:i,local:a,p:vR(a/320,0,1),spoken:a>=0}})}function lR(e,t){let n=cR(e,t),r=0;for(let t=0;t<n.length;t++){let i=n[t];if(!i.spoken)break;let a=t+1<n.length?Math.max(40,n[t+1].start-i.start):(e.anim?.speedMs||180)*2,o=vR(i.local/a,0,1);r+=Math.round(o*(i.text.length+1))}return r}function uR(e,t,n){if(!e.motion||e.motion.type===`none`||t<(e.appearMs||0))return null;let r=e.leaveMs==null?n||0:e.leaveMs,i=Math.max(.1,(r-(e.appearMs||0))/1e3),a=(t-(e.appearMs||0))/1e3;return Ld(e.motion,a,i)}function dR(e,t,n){return e+(t-e)*n}function fR(e,t){let n=Math.max(0,Math.min(1,e));return t===`linear`?n:t===`ease-in`?n*n:t===`ease-out`?1-(1-n)*(1-n):n<.5?2*n*n:1-(-2*n+2)**2/2}function pR(e,t){let n={x:e.pos?.x??.5,y:e.pos?.y??.5,size:e.size},r=Array.isArray(e.moves)?e.moves.filter(e=>e&&typeof e==`object`).slice().sort((e,t)=>(e.atMs||0)-(t.atMs||0)):[],i=n;for(let e=0;e<r.length;e++){let n=r[e],a=Number(n.atMs)||0;if(t<a)break;let o=Number(n.durMs),s=Number.isFinite(o)&&o>=0?o:500,c=e+1<r.length?Number(r[e+1].atMs)||0:1/0,l=Math.max(0,Math.min(s,c-a)),u={x:n.pos?.x==null?i.x:n.pos.x,y:n.pos?.y==null?i.y:n.pos.y,size:n.size==null?i.size:n.size};if(l<=0||t>=a+l){i=u;continue}let d=fR((t-a)/l,n.ease);return{pos:{x:dR(i.x,u.x,d),y:dR(i.y,u.y,d)},size:i.size!=null&&u.size!=null?dR(i.size,u.size,d):u.size??i.size}}return{pos:{x:i.x,y:i.y},size:i.size}}function mR(e,t,n){let r=t.shadow==null?.18:Math.max(0,Math.min(1,Number(t.shadow)));if(r<=.001){e.shadowColor=`transparent`,e.shadowBlur=0,e.shadowOffsetY=0;return}e.shadowColor=`rgba(0,0,0,${r})`,e.shadowBlur=n*(.03+r*.14),e.shadowOffsetY=n*(.008+r*.05)}function hR(e,t){return(e?.elements||[]).filter(e=>t>=(e.appearMs||0)&&(e.leaveMs==null||t<e.leaveMs))}function gR(e,t,n=`pop`){let r=t-(e.appearMs||0),i=vR(r/320,0,1),a=1-(1-i)*(1-i);switch(e.kind===`text`?e.anim?.type||`pop`:e.entrance||n||`pop`){case`fade`:return{alpha:a,scale:1,dy:0,p:i};case`rise`:return{alpha:a,scale:1,dy:(1-a)*.06,p:i};case`scale`:return{alpha:1,scale:.4+.6*a,dy:0,p:i};case`typewriter`:case`pop-word`:case`word-pop`:case`sentence-build`:case`highlight`:return{alpha:1,scale:1,dy:0,p:i};case`line`:{let e=i<.7?i/.7*1.12:1.12-.12*((i-.7)/.3);return{alpha:Math.min(1,i*2.5),scale:e,dy:0,p:i}}default:{let e=i<.7?i/.7*1.12:1.12-.12*((i-.7)/.3);return{alpha:Math.min(1,i*2.5),scale:e,dy:0,p:i}}}}function _R(e,t,n,r,i,a){e.save(),rR(e,t.background,i,a,n);let o=t.handoff?.arrive===`fade`?`fade`:`pop`;for(let s of hR(t,n)){let c=gR(s,n,o),l=pR(s,n),u=l.pos,d=l.size==null?s.size:l.size,f=u.x*i,p=(u.y+(c.dy||0))*a;e.save(),e.globalAlpha=c.alpha,e.translate(f,p);let m=uR(s,n,t.durationMs);if(m&&(e.translate(m.tx/100*i,m.ty/100*a),m.rot&&e.rotate(m.rot*Math.PI/180),m.scale!==1&&e.scale(m.scale,m.scale),m.blur>.01&&(e.filter=`blur(${(m.blur*(a/1080)).toFixed(2)}px)`)),s.tilt&&e.rotate(s.tilt*Math.PI/180),c.scale!==1&&e.scale(c.scale,c.scale),s.kind===`image`||s.kind===`video`){let t=s.src?r(s.src,s):null;!t&&s.kind===`video`&&s.poster&&(t=r(s.poster,s));let n=(d||.28)*i,o=s.box?Math.max(1,s.box.h*a):null,c=s.box?Math.max(1,s.box.w*i):null;if(t&&c){let{w:n,h:r}=aR(t),i=Math.max(c/n,o/r),a=c/i,l=o/i,u=(n-a)/2,d=(r-l)/2;mR(e,s,c),s.cutout||(e.fillStyle=`#fff`,e.fillRect(-c/2-c*.02,-o/2-c*.02,c+c*.04,o+c*.04),e.shadowColor=`transparent`),e.drawImage(t,u,d,a,l,-c/2,-o/2,c,o),s.cutout&&(e.shadowColor=`transparent`)}else if(t){let{w:r,h:i}=aR(t),a=i/r*n;mR(e,s,n),s.cutout||(e.fillStyle=`#fff`,e.fillRect(-n/2-n*.02,-a/2-n*.02,n+n*.04,a+n*.04),e.shadowColor=`transparent`),e.drawImage(t,-n/2,-a/2,n,a),s.cutout&&(e.shadowColor=`transparent`)}else{let t=c||n,r=o||n*.66;e.strokeStyle=`rgba(0,0,0,0.25)`,e.setLineDash([6,5]),e.lineWidth=2,e.strokeRect(-t/2,-r/2,t,r),e.setLineDash([]),e.fillStyle=`rgba(0,0,0,0.4)`,e.font=`${Math.round(a*.028)}px Hanken Grotesk, Arial, sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(String(s.query||(s.kind===`video`?`video`:`image`)).slice(0,28),0,0)}}else{let t=Math.max(10,(d||.07)*a);e.font=`${s.weight||700} ${t}px ${s.font||`Hanken Grotesk`}, Arial, sans-serif`,e.fillStyle=s.color||`#111111`,e.textAlign=`center`,e.textBaseline=`middle`;let r=s.anim?.type||`pop`,i=String(s.text||``);if(r===`typewriter`){if(Array.isArray(s.wordTimes)&&s.wordTimes.length){let t=lR(s,n);e.fillText(i.slice(0,t),0,0)}else{let t=s.anim?.speedMs||45,r=Math.max(0,Math.floor((n-(s.appearMs||0))/t));e.fillText(i.slice(0,r),0,0)}}else if(r===`pop-word`||r===`word-pop`||r===`sentence-build`||r===`highlight`){let i=cR(s,n),a=i.map(t=>e.measureText(`${t.text} `).width),o=-a.reduce((e,t)=>e+t,0)/2,l=s.anim?.entrance||`pop`;for(let n=0;n<i.length;n++){let s=i[n];if(r===`highlight`)e.save(),e.translate(o+a[n]/2,0),e.globalAlpha=c.alpha*(s.spoken?1:.3),e.fillText(s.text,0,0),e.restore();else if(s.spoken){let i=s.p;e.save();let u=1,d=0,f=0,p=Math.min(1,i*2.5);if(r===`sentence-build`){let e=1-(1-i)*(1-i);l===`fade`?p=e:l===`slide`?(d=(1-e)*-t*.8,p=e):l===`rise`?(f=(1-e)*t*.6,p=e):l===`scale`?(u=.4+.6*e,p=1):u=i<.7?i/.7*1.12:1.12-.12*((i-.7)/.3)}else u=i<.7?i/.7*1.12:1.12-.12*((i-.7)/.3);e.translate(o+a[n]/2+d,f),e.scale(u,u),e.globalAlpha=c.alpha*p,e.fillText(s.text,0,0),e.restore()}o+=a[n]}}else e.fillText(i,0,0)}e.restore()}e.restore()}var vR,yR=o((()=>{Vd(),nR(),[...Object.entries(tR).map(([e,t])=>({key:`anim-${e}`,label:t.label,value:`anim|${e}`,animated:!0}))],vR=(e,t,n)=>Math.max(t,Math.min(n,e))}));function bR(e){return e===`9:16`?[1080,1920]:e===`1:1`?[1080,1080]:[1920,1080]}async function xR(e,t=1920,n=1080){let r=typeof OffscreenCanvas<`u`?new OffscreenCanvas(t,n):Object.assign(document.createElement(`canvas`),{width:t,height:n}),i=r.getContext(`2d`),a=new Map,o=new Set;for(let t of e?.elements||[])t.kind===`image`&&t.src&&o.add(t.src),t.kind===`video`&&t.poster&&o.add(t.poster);await Promise.all([...o].map(e=>new Promise(t=>{let n=new Image;n.crossOrigin=`anonymous`,n.onload=()=>{a.set(e,n),t()},n.onerror=()=>t(),n.src=e})));let s=(e?.elements||[]).filter(e=>e.kind===`video`&&e.src),c=new Map;await Promise.all(s.map(e=>new Promise(t=>{if(typeof document>`u`)return t();let n=document.createElement(`video`);n.crossOrigin=`anonymous`,n.muted=!0,n.playsInline=!0,n.preload=`auto`;let r=()=>t();n.addEventListener(`loadeddata`,()=>{c.set(e.id,n),r()},{once:!0}),n.addEventListener(`error`,r,{once:!0}),setTimeout(r,8e3),n.src=e.src})));let l=(e,t)=>new Promise(n=>{if(Math.abs((e.currentTime||0)-t)<CR)return n();let r=setTimeout(n,SR);e.addEventListener(`seeked`,()=>{clearTimeout(r),n()},{once:!0});try{e.currentTime=t}catch{clearTimeout(r),n()}});return{width:t,height:n,frameAt:async o=>{let u=Math.max(0,o)*1e3;for(let e of s){let t=c.get(e.id);if(!t||u<(e.appearMs||0)||e.leaveMs!=null&&u>=e.leaveMs)continue;let n=Number(e.durationSec)||t.duration||0;await l(t,oR({...e,durationSec:n},u))}return _R(i,e,u,(e,t)=>a.get(e)||(t&&t.src===e?c.get(t.id):null)||null,t,n),r},close:()=>{a.clear();for(let e of c.values())try{e.pause(),e.removeAttribute(`src`),e.load()}catch{}c.clear()}}}var SR,CR,wR=o((()=>{yR(),SR=1500,CR=.006}));async function TR(e){let t=e?.original;if(!t?.assetId||!t?.versionId)return null;try{let e=hp(t);return e?await mp(e):null}catch{return null}}function ER(e){return e===`16:9`?[1920,1080]:e===`1:1`?[1080,1080]:[1080,1920]}function DR(e){return e?.aspect===`9:16`?[1080,1920]:e?.aspect===`1:1`?[1080,1080]:[1920,1080]}async function OR(e){let t=e.kind||`image`;if(t===`vector-scene`&&e.scene){let[t,n]=DR(e.scene),r=mk(e.scene,t,n,{debug:e.debug}),i=e.trimStart||0,a=e.speed||1;return{width:r.width,height:r.height,frameAt:e=>r.frameAt(i+Math.max(0,e)*a),close:()=>r.close?.()}}if(t===`collage`&&e.collage){let[t,n]=bR(e.collage.aspect),r=await xR(e.collage,t,n);return{width:r.width,height:r.height,frameAt:t=>r.frameAt(Math.max(0,t)*(e.speed||1)+(e.trimStart||0)),close:()=>r.close?.()}}if(t===`v2-scene`&&e.v2video){let[t,n]=ER(e.v2video.meta?.aspect),r=PL(e.v2video,t,n),i=e.trimStart||0,a=e.speed||1;return{width:r.width,height:r.height,frameAt:e=>r.frameAt(i+Math.max(0,e)*a),close:()=>r.close?.()}}let n=t===`video`?await dp(e.url):null;if(n)return kR({...e,url:n},null);let r=await TR(e)||await lp(e);if(fp(r))throw Error(`Can't find "${r.name}" on this device. Reconnect your local folder or re-import it, then try the export again.`);if(t===`video`&&(r.type||``).startsWith(`image/`)&&(t=`image`),t===`image`)try{let e=await createImageBitmap(r);return{frameAt:async()=>e,close:()=>e.close?.()}}catch{let t=URL.createObjectURL(r),n=new Image;await new Promise((r,i)=>{n.onload=r,n.onerror=()=>i(Error(`image load failed: ${e.title||e.url}`)),n.src=t});let i=await createImageBitmap(n);return URL.revokeObjectURL(t),{frameAt:async()=>i,close:()=>i.close?.()}}if(!e.reverse)try{return await GC(e,await r.arrayBuffer())}catch(t){console.warn(`[export] WebCodecs decode failed, seek fallback:`,e.title||e.url,t?.message||t)}return kR(e,r)}async function kR(e,t){let n=document.createElement(`video`);n.crossOrigin=`anonymous`,n.muted=!0,n.preload=`auto`,n.playsInline=!0;let r=t?URL.createObjectURL(t):e.url;n.src=r,await new Promise((t,r)=>{let i=()=>{s(),t()},a=()=>{s(),r(Error(`video load failed: ${e.title||e.url}`))},o=setTimeout(()=>{s(),r(Error(`video load timeout: ${e.title||e.url}`))},3e4);function s(){clearTimeout(o),n.removeEventListener(`loadeddata`,i),n.removeEventListener(`error`,a)}n.addEventListener(`loadeddata`,i),n.addEventListener(`error`,a)});let i=e.speed||1,a=e.trimStart||0,o=n.duration||0;return{async frameAt(t){let r=e.reverse?(e.trimEnd??o)-t*i:a+t*i;return r=Math.max(0,Math.min(Math.max(0,o-.001),r)),Math.abs(n.currentTime-r)>.001&&await new Promise(e=>{let t=()=>{n.removeEventListener(`seeked`,t),e()};n.addEventListener(`seeked`,t),n.currentTime=r,setTimeout(e,2e3)}),n},close(){try{n.removeAttribute(`src`),n.load(),URL.revokeObjectURL(r)}catch{}}}}var AR=o((()=>{KC(),vp(),gk(),FL(),wR()}));async function jR(e){let t=[];for(let n of e||[]){let e=n?.kind||`image`;if(!n?.url||e===`vector-scene`||e===`v2-scene`||e===`collage`||!LR(n))continue;let r=null;try{if(n.original?.assetId&&n.original?.versionId){let e=hp(n.original);e&&(r=await mp(e).catch(()=>null))}r||=await lp(n)}catch{continue}fp(r)&&t.push(r.name||n.title||n.url)}return[...new Set(t)]}function MR(e,t){let n=String(e||``).split(/[:/]/).map(Number),[r,i]=n.length===2&&n[0]>0&&n[1]>0?n:[16,9],a=[720,1080].includes(Number(t))?Number(t):1080,o,s;return r>=i?(s=a,o=Math.round(r/i*a)):(o=a,s=Math.round(i/r*a)),o-=o%2,s-=s%2,[Math.max(2,o),Math.max(2,s)]}function NR(e={}){let t=e||{},n=[24,30,60].includes(t.fps)?t.fps:RR.fps,[r,i]=MR(t.aspect||`16:9`,t.resolution),a=t.quality===`standard`?.1:.15;return{width:r,height:i,fps:n,bitrate:Math.min(28e6,Math.max(2e6,Math.round(r*i*n*a)))}}function PR(e){let t=new Map((e||[]).map((e,t)=>[e,t]));return(e,n)=>{let r=t.has(e.trackId)?t.get(e.trackId):0,i=t.has(n.trackId)?t.get(n.trackId):0;return r===i?(e.start||0)-(n.start||0):r-i}}async function FR(e,t){let n;for(let e=0;;e++)try{n=await up(t);break}catch(t){if(e>=2)throw Error(`audio fetch failed after ${e+1} tries: ${t.message}`);await new Promise(t=>setTimeout(t,400*(e+1)))}if(fp(n))throw Error(`Can't find audio "${n.name}" on this device. Reconnect your local folder or re-import it, then try the export again.`);return e.decodeAudioData(n)}async function IR(e,{onProgress:t,settings:n,nativeAudio:r=null}={}){let{clips:i=[],audio:a=[],targetDuration:o=0,trackOrder:s=[],overlays:c=[],stickers:l=[],blurs:u=[],zooms:d=[],polishFx:f=[],fullscreenFrames:p=[],figureSweeps:m=[],graphs:h=[],fxEvents:g=[],liveOverlays:_=[],previewH:v=0,backgroundColor:y=`#000000`,stillmadeWatermark:b=!1,stillmadeWatermarkPos:x=`br`,stillmadeWatermarkOpacity:S=null,stillmadeWatermarkLook:C=null,stillmadeEndScreen:w=!1,stillmadeEndScreenSec:T=void 0,stillmadeEndScreenAnim:E=void 0}=e||{},D=await jR(i);if(D.length){let e=D.length===1?D[0]:`${D.slice(0,-1).join(`, `)} and ${D.at(-1)}`;throw Error(`Can't find ${D.length===1?`this file`:`these files`} on this device: ${e}. Reconnect your local folder or re-import, then try the export again. If you just re-imported ${D.length===1?`it`:`them`}, choose Update affected steps on the Steps after Import media first, so they use the new copies.`)}let O=i.filter(e=>e&&(e.url||e.kind===`vector-scene`&&e.scene||e.kind===`v2-scene`&&e.v2video||e.kind===`collage`&&e.collage)).map(e=>({id:e.id,kind:e.kind||`image`,url:e.url,scene:e.kind===`vector-scene`?e.scene:void 0,v2video:e.kind===`v2-scene`?e.v2video:void 0,collage:e.kind===`collage`?e.collage:void 0,source:e.source,localKey:e.localKey,original:e.original,title:e.title,trackId:e.trackId,start:e.start||0,duration:e.duration||0,speed:e.speed||1,reverse:!!e.reverse,trimStart:(e.trimStart||0)+(e.sourceOffset||0),trimEnd:e.trimEnd,motion:e.motion,color:e.color,lut:e.lut,transition:e.transition,speedRamp:e.speedRamp,freeze:e.freeze,transform:{...e.transform||{},opacity:e.transform?.opacity??e.opacity??1},shareSource:!!e.shareSource})).sort(PR(s)),k=O.reduce((e,t)=>Math.max(e,t.start+t.duration),0),A=a.reduce((e,t)=>Math.max(e,(t.start||0)+(t.duration||0)),0),j=Math.max(o||0,k,A,1),M=w?j+mm(T):j,N=[],P=new Map;for(let e of O)P.has(e.trackId)||P.set(e.trackId,[]),P.get(e.trackId).push(e);for(let e of P.values()){e.sort((e,t)=>e.start-t.start);for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1],i=n.transition?.type;if(!i||i===`Cut`)continue;let a=Math.min(n.transition.duration||.5,n.duration*.9,r.duration*.9);a<=.01||N.push({outId:n.id,inId:r.id,type:i,startT:Math.max(0,n.start+n.duration-a/2),dur:a,color:n.transition.color||null})}}let F=null,I=a.filter(e=>e&&e.url);if(I.length&&r===null){let e=new(window.AudioContext||window.webkitAudioContext),n=[],r=new Map;for(let i of I){t&&t({phase:`audio-decode`});try{let t=`${i.source||``}\u0000${i.localKey||``}\u0000${i.url}`;r.has(t)||r.set(t,FR(e,i));let a=await r.get(t);n.push({audioBuffer:a,start:i.start||0,durationSec:i.duration||a.duration,volume:(i.volume??80)/100,fadeIn:i.fadeIn||0,fadeOut:i.fadeOut||0,sourceOffset:i.sourceOffset||0,loop:!!i.loop,rate:i.rate>0?i.rate:1})}catch(t){if(!i.embedded){try{e.close?.()}catch{}throw Error(`Audio "${i.title||i.url}" failed to load (${t.message}). Export stopped so this sound isn't silently missing — if retrying doesn't fix it, re-import or replace that item (its source may be gone).`)}console.warn(`[export] audio decode failed, skipping:`,i.url,t.message)}}try{e.close?.()}catch{}n.length&&(F=await jd(n,{duration:M}))}let ee={...n,aspect:n?.aspect||e?.aspect||e?.aspectRatio};return{...RR,...NR(ee),duration:M,layers:O,transitions:N,overlays:c,stickers:l,blurs:u,zooms:d,polishFx:f,fullscreenFrames:p,figureSweeps:m,graphs:h,fxEvents:g,liveOverlays:_,previewH:v,backgroundColor:y,stillmadeWatermark:b,stillmadeWatermarkPos:x,stillmadeWatermarkOpacity:S,stillmadeWatermarkLook:C,stillmadeEndScreen:w,stillmadeEndScreenSec:T,stillmadeEndScreenAnim:E,audioBuffer:F,nativeAudio:r}}var LR,RR,zR=o((()=>{Nd(),vp(),Dm(),LR=e=>!!(e?.original?.assetId&&e?.original?.versionId)||/^(?:sm-media|blob|file):/i.test(String(e?.url||``)),RR={width:1920,height:1080,fps:60,bitrate:18e6}}));function BR(e){return e instanceof Blob&&VR.add(e),e}var VR,HR=o((()=>{VR=new WeakSet})),UR=c({renderNative:()=>GR,wavHeader:()=>WR});function WR(e){let t=e.numberOfChannels,n=e.length*t*2;if(n>4294967259)throw Error(`Audio exceeds WAV size limit`);let r=new Uint8Array(44),i=new DataView(r.buffer),a=(e,t)=>[...t].forEach((t,n)=>i.setUint8(e+n,t.charCodeAt(0)));return a(0,`RIFF`),i.setUint32(4,n+36,!0),a(8,`WAVE`),a(12,`fmt `),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,t,!0),i.setUint32(24,e.sampleRate,!0),i.setUint32(28,e.sampleRate*t*2,!0),i.setUint16(32,t*2,!0),i.setUint16(34,16,!0),a(36,`data`),i.setUint32(40,n,!0),r}async function GR(e,{onProgress:t,signal:n,exportAuthorization:r}={}){let i=_p(),a=new Map,o,s=()=>{if(n?.aborted)throw Error(`Export aborted`)},c=()=>{o&&i.cancelExport(o.id).catch(()=>{})};n?.addEventListener(`abort`,c,{once:!0});try{s();let n=Math.max(1,Math.round(e.duration*e.fps));if(o=await i.beginExport({width:e.width,height:e.height,fps:e.fps,frames:n},r?.ticket),s(),await document.fonts?.ready,s(),e.stickers?.some(e=>e.shape===`gif`)){let{preloadGifStickers:t}=await Ti(async()=>{let{preloadGifStickers:e}=await Promise.resolve().then(()=>(Up(),Cp));return{preloadGifStickers:e}},void 0);await t(e.stickers)}for(let t of e.layers)s(),a.has(t.id)||a.set(t.id,await OR(t));let c=new OffscreenCanvas(e.width,e.height).getContext(`2d`,{willReadFrequently:!0});for(let r=0;r<n;r++)s(),await Wg(c,e,r/e.fps,a,e.width,e.height),s(),await i.writeExportFrame(o.id,r,new Uint8Array(c.getImageData(0,0,e.width,e.height).data.buffer)),s(),(r%12==0||r===n-1)&&t?.({phase:`video`,done:r+1,total:n});if(e.nativeAudio?.length&&(s(),t?.({phase:`audio`}),await i.mixExportAudio(o.id,e.nativeAudio),s()),s(),e.audioBuffer){let n=e.audioBuffer;t?.({phase:`audio`}),await i.writeExportAudio(o.id,WR(n));let r=Array.from({length:n.numberOfChannels},(e,t)=>n.getChannelData(t));for(let e=0;e<n.length;e+=16384){s();let t=Math.min(16384,n.length-e),a=new Uint8Array(t*r.length*2),c=new DataView(a.buffer);for(let n=0;n<t;n++)for(let t=0;t<r.length;t++){let i=Math.max(-1,Math.min(1,r[t][e+n]));c.setInt16((n*r.length+t)*2,Math.round(i<0?i*32768:i*32767),!0)}await i.writeExportAudio(o.id,a)}}s();let l=await i.finishExport(o.id);return o=null,s(),t?.({phase:`done`}),l}finally{n?.removeEventListener(`abort`,c);for(let e of a.values())e.close?.();o&&await i.cancelExport(o.id).catch(()=>{})}}var KR=o((()=>{Jg(),AR(),vp(),Ei()}));async function qR(){return _p()&&(await _p().capabilities()).nativeTimelineExport?{strategy:`native`}:zi()}async function JR(e,t={}){cz(t.signal),t.exportAuthorization?.watermark===!0&&(e={...e,stillmadeWatermark:!0,stillmadeWatermarkLook:t.exportAuthorization.mark||null});let n=_p(),r=n&&(await n.capabilities()).nativeTimelineExport;cz(t.signal);let i=r&&n.prepareNativeAudio?await n.prepareNativeAudio(e.audio||[]):null;cz(t.signal);let a=await IR(e,{...t,nativeAudio:i});if(a.stillmadeWatermark||a.stillmadeEndScreen)try{await Promise.all(bm().map(e=>document.fonts.load(e)))}catch{}cz(t.signal);let o=r?await(await Ti(async()=>{let{renderNative:e}=await Promise.resolve().then(()=>(KR(),UR));return{renderNative:e}},void 0)).renderNative(a,t):await $R(a,t);return t.exportAuthorization?BR(o):o}async function YR(e,{width:t,height:n,duration:r,fps:i=30,shortSide:a=1080,signal:o,onProgress:s,render:c=$R,plan:l=IR}={}){if(cz(o),!(e instanceof Blob)||!e.size)throw Error(`A video file is needed for a working copy.`);if(!(t>0&&n>0&&r>0))throw Error(`The video’s size and length are needed before it can be made smaller.`);if(Math.min(t,n)<720)throw Error(`no-gain`);let u=URL.createObjectURL(e);try{let e=await l({clips:[{id:`working`,kind:`video`,url:u,start:0,duration:r,trimStart:0,speed:1,trackId:`video`}],audio:[{id:`working-audio`,url:u,start:0,duration:r,trimStart:0,volume:1,trackId:`audio`}],targetDuration:r,trackOrder:[`video`],stillmadeWatermark:!1,stillmadeEndScreen:!1},{settings:{aspect:`${t}:${n}`,resolution:Math.min(a,1080)>=1080?1080:720,fps:[24,30,60].includes(i)?i:30,quality:`standard`},onProgress:s,signal:o});cz(o);let d=await c(e,{onProgress:s,signal:o});return d instanceof Blob?d:new Blob([d],{type:`video/mp4`})}finally{URL.revokeObjectURL(u)}}async function XR(e,{keep:t,width:n,height:r,duration:i,fps:a=30,shortSide:o=1080,signal:s,onProgress:c,render:l=$R,plan:u=IR}={}){cz(s);let d=e instanceof Blob&&e.size>0,f=typeof e==`string`&&e?e:d?URL.createObjectURL(e):null;if(!f)throw Error(`A video file is needed to cut.`);if(!(n>0&&r>0&&i>0))throw Error(`The video’s size and length are needed before it can be cut.`);let p=(Array.isArray(t)?t:[]).map(e=>({start:Math.max(0,Number(e?.start)),end:Math.min(i,Number(e?.end))})).filter(e=>Number.isFinite(e.start)&&Number.isFinite(e.end)&&e.end-e.start>.001);if(!p.length)throw Error(`Keep at least part of the recording.`);try{let e=0,t=[],i=[];for(let[n,r]of p.entries()){let a=r.end-r.start;t.push({id:`cut-${n}`,kind:`video`,url:f,start:e,duration:a,trimStart:r.start,speed:1,trackId:`video`}),i.push({id:`cut-audio-${n}`,url:f,start:e,duration:a,trimStart:r.start,volume:1,trackId:`audio`}),e+=a}let d=await u({clips:t,audio:i,targetDuration:e,trackOrder:[`video`],stillmadeWatermark:!1,stillmadeEndScreen:!1},{settings:{aspect:`${n}:${r}`,resolution:Math.min(n,r,o)>=1080?1080:720,fps:[24,30,60].includes(a)?a:30,quality:`standard`},onProgress:c,signal:s});cz(s);let m=await l(d,{onProgress:c,signal:s});return{file:m instanceof Blob?m:new Blob([m],{type:`video/mp4`}),duration:e}}finally{d&&URL.revokeObjectURL(f)}}async function ZR(e,t={}){cz(t.signal);let n=_p(),r=n?.beginAudioExport&&n.prepareNativeAudio?await n.prepareNativeAudio(e.audio||[]):null;cz(t.signal);let i=await IR(e,{...t,nativeAudio:r});if(cz(t.signal),r?.length){let e,a=()=>{e&&n.cancelExport(e.id).catch(()=>{})};try{e=await n.beginAudioExport(i.duration,t.exportAuthorization?.ticket),t.signal?.addEventListener(`abort`,a,{once:!0}),cz(t.signal),t.onProgress?.(.1),await n.mixExportAudio(e.id,r),cz(t.signal),t.onProgress?.(.8);let o=await n.finishExport(e.id);return e=null,cz(t.signal),t.onProgress?.(1),o}finally{t.signal?.removeEventListener(`abort`,a),e&&await n.cancelExport(e.id).catch(()=>{})}}if(!i.audioBuffer){let e=Error(`NO_AUDIO`);throw e.code=`NO_AUDIO`,e}return Md(i.audioBuffer,t)}async function QR(e,t){if(!e.shareSource||e.kind!==`video`||e.reverse||!e.url)return OR(e);t.has(e.url)||t.set(e.url,OR({...e,id:`shared:${e.url}`,start:0,trimStart:0,trimEnd:void 0,speed:1}));let n=await t.get(e.url),r=e.trimStart||0,i=e.speed||1;return{...n,frameAt:e=>n.frameAt(r+Math.max(0,e)*i),close(){}}}async function $R(e,t={}){let n=await zi();try{return await ez(e,t,n)}catch(r){if(t.signal?.aborted||n.hardwareAcceleration!==`prefer-hardware`||!/VideoEncoder|codec/i.test(String(r?.message||``)))throw r;return ez(e,t,{...n,hardwareAcceleration:`prefer-software`})}}async function ez(e,{onProgress:t,signal:n}={},r){if(r.strategy!==`webcodecs`)throw Error(`WebCodecs unavailable (wasm fallback is a later phase)`);let{width:i,height:a,fps:o,duration:s}=e;if(e.overlays?.length)try{await document.fonts?.ready}catch{}if(e.stickers?.some?.(e=>e?.shape===`gif`))try{let{preloadGifStickers:t}=await Ti(async()=>{let{preloadGifStickers:e}=await Promise.resolve().then(()=>(Up(),Cp));return{preloadGifStickers:e}},void 0);await t(e.stickers)}catch{}let c=new Map,l=new Map,u=null;try{for(let t of e.layers){if(n?.aborted)throw Error(`aborted`);c.has(t.id)||c.set(t.id,await QR(t,l))}let d=e.audioBuffer?await kd(e.audioBuffer):null,f=Math.max(1,Math.round(s*o)),p=d?Math.ceil(d.buffer.length/(d.codec===`opus`?960:1024))+64:0,m=Fs({width:i,height:a,fps:o,audio:d?{channels:d.buffer.numberOfChannels,sampleRate:d.buffer.sampleRate,codec:d.codec}:null,expected:{video:f+16,audio:p}});u=Ls({codec:r.videoCodec,width:i,height:a,fps:o,bitrate:e.bitrate||1e7,hardwareAcceleration:r.hardwareAcceleration||`prefer-hardware`,onChunk:(e,t)=>m.addVideoChunk(e,t)});let h=new OffscreenCanvas(i,a),g=h.getContext(`2d`),_=f;for(let r=0;r<_;r++){if(n?.aborted)throw Error(`aborted`);let s=r/o;await Wg(g,e,s,c,i,a),await u.encodeFrame(h,Math.round(s*1e6),r%48==0),t&&(r%12==0||r===_-1)&&t({phase:`video`,done:r+1,total:_})}return await u.finish(),u=null,d&&(t&&t({phase:`audio`}),await Ad(d.buffer,{config:d.config,onChunk:(e,t)=>m.addAudioChunk(e,t)})),t&&t({phase:`done`}),m.finalize()}finally{for(let e of c.values())try{e.close?.()}catch{}for(let e of l.values())try{(await e).close?.()}catch{}if(u)try{u.close()}catch{}}return e.audioBuffer&&(t&&t({phase:`audio`}),await Ad(e.audioBuffer,{onChunk:(e,t)=>muxer.addAudioChunk(e,t)})),t&&t({phase:`done`}),muxer.finalize()}async function tz(){let e=await zi();if(e.strategy!==`webcodecs`)return{ok:!1,reason:`no webcodecs`,caps:e};let t=44100,n=Fs({width:640,height:360,fps:24,audio:{channels:2,sampleRate:t}}),r=Ls({codec:e.videoCodec,width:640,height:360,fps:24,bitrate:2e6,onChunk:(e,t)=>n.addVideoChunk(e,t)}),i=new OffscreenCanvas(640,360),a=i.getContext(`2d`);for(let e=0;e<48;e++)a.fillStyle=`#101830`,a.fillRect(0,0,640,360),a.fillStyle=`#e0b84c`,a.fillRect(e/48*560,140,80,80),await r.encodeFrame(i,Math.round(e/24*1e6),e%48==0);await r.finish();let o=new OfflineAudioContext(2,t*2,t),s=o.createOscillator();s.frequency.value=440;let c=o.createGain();c.gain.value=.2,s.connect(c).connect(o.destination),s.start(0),s.stop(2),await Ad(await o.startRendering(),{onChunk:(e,t)=>n.addAudioChunk(e,t)});let l=n.finalize(),u=new Uint8Array(await l.slice(0,12).arrayBuffer()),d=String.fromCharCode(u[4],u[5],u[6],u[7])===`ftyp`,f=URL.createObjectURL(l),p=await new Promise(e=>{let t=document.createElement(`video`);t.preload=`metadata`,t.muted=!0,t.onloadedmetadata=()=>e({w:t.videoWidth,h:t.videoHeight,dur:Math.round(t.duration*100)/100}),t.onerror=()=>e({error:`decode error`}),t.src=f,setTimeout(()=>e({error:`timeout`}),5e3)});return URL.revokeObjectURL(f),{ok:!0,size:l.size,type:l.type,ftyp:d,codec:e.videoCodec,probe:p}}function nz(e,t){let n=document.createElement(`canvas`);n.width=800,n.height=450;let r=n.getContext(`2d`);r.fillStyle=t,r.fillRect(0,0,800,450),r.strokeStyle=`rgba(255,255,255,0.35)`;for(let e=0;e<=800;e+=80)r.beginPath(),r.moveTo(e,0),r.lineTo(e,450),r.stroke();for(let e=0;e<=450;e+=90)r.beginPath(),r.moveTo(0,e),r.lineTo(800,e),r.stroke();return r.fillStyle=`#fff`,r.font=`bold 160px sans-serif`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(e,400,225),n.toDataURL(`image/png`)}async function rz(){let e={width:640,height:360,fps:24,duration:4,bitrate:3e6,layers:[{id:`a`,kind:`image`,url:nz(`A`,`#1a3a5a`),start:0,duration:2,motion:{type:`zoom`,zoomDirection:`in`,zoomAmount:1.4,zoomAnchor:`center`,intensity:100,range:[0,100],easing:`ease-in-out`},color:{saturation:40},transform:{opacity:1}},{id:`b`,kind:`image`,url:nz(`B`,`#5a1a3a`),start:2,duration:2,motion:{type:`pan`,panDirection:`left-right`,panAmount:20,intensity:100,range:[0,100],easing:`linear`},lut:`Teal and Orange`,transform:{opacity:1}}]},t=44100,n=new OfflineAudioContext(2,t*4,t),r=n.createOscillator();r.frequency.value=330;let i=n.createGain();i.gain.value=.15,r.connect(i).connect(n.destination),r.start(0),r.stop(4),e.audioBuffer=await n.startRendering();let a=performance.now(),o=await $R(e),s=Math.round(performance.now()-a),c=new Map;for(let t of e.layers)c.set(t.id,await OR(t));let l=document.getElementById(`__rt`);l||(l=document.createElement(`canvas`),l.id=`__rt`,l.style.cssText=`position:fixed;top:8px;left:8px;z-index:99999;border:2px solid #0f0;background:#000`,document.body.appendChild(l)),l.width=640,l.height=360,await Wg(l.getContext(`2d`),e,1,c,640,360);let u=new Uint8Array(await o.slice(0,12).arrayBuffer()),d=String.fromCharCode(u[4],u[5],u[6],u[7])===`ftyp`,f=URL.createObjectURL(o),p=await new Promise(e=>{let t=document.createElement(`video`);t.preload=`metadata`,t.muted=!0,t.onloadedmetadata=()=>e({w:t.videoWidth,h:t.videoHeight,dur:Math.round(t.duration*100)/100}),t.onerror=()=>e({error:`decode`}),t.src=f,setTimeout(()=>e({error:`timeout`}),6e3)});return URL.revokeObjectURL(f),{ok:!0,size:o.size,ftyp:d,probe:p,ms:s}}async function iz(){let e=await $R({width:480,height:270,fps:24,duration:3,bitrate:2e6,layers:[{id:`s`,kind:`image`,url:nz(`V`,`#243a2a`),start:0,duration:3,motion:{type:`pan`,panDirection:`left-right`,panAmount:30,intensity:100,range:[0,100],easing:`linear`},transform:{opacity:1}}]}),t=URL.createObjectURL(e),n=performance.now(),r=await $R({width:480,height:270,fps:24,duration:2,bitrate:2e6,layers:[{id:`v`,kind:`video`,url:t,start:0,duration:2,trimStart:.5,speed:1,motion:{type:`zoom`,zoomDirection:`in`,zoomAmount:1.3,zoomAnchor:`center`,intensity:100,range:[0,100],easing:`ease-in-out`},transform:{opacity:1}}]}),i=Math.round(performance.now()-n);URL.revokeObjectURL(t);let a=new Uint8Array(await r.slice(0,12).arrayBuffer()),o=String.fromCharCode(a[4],a[5],a[6],a[7])===`ftyp`,s=URL.createObjectURL(r),c=await new Promise(e=>{let t=document.createElement(`video`);t.preload=`metadata`,t.muted=!0,t.onloadedmetadata=()=>e({w:t.videoWidth,h:t.videoHeight,dur:Math.round(t.duration*100)/100}),t.onerror=()=>e({error:`decode`}),t.src=s,setTimeout(()=>e({error:`timeout`}),8e3)});return URL.revokeObjectURL(s),{ok:!0,srcSize:e.size,size:r.size,ftyp:o,probe:c,ms:i}}async function az(){let e=await IR({targetDuration:4,trackOrder:[`video`,`overlay`],audio:[],clips:[{id:`c1`,kind:`image`,trackId:`video`,url:nz(`1`,`#203a4a`),start:0,duration:2,motion:{type:`ken-burns`,intensity:100,range:[0,100],easing:`ease-in-out`},transform:{opacity:1}},{id:`c2`,kind:`image`,trackId:`video`,url:nz(`2`,`#4a2030`),start:2,duration:2,motion:{type:`zoom`,zoomDirection:`out`,zoomAmount:1.5,intensity:100,range:[0,100]},lut:`Filmic`,transform:{opacity:1}}]}),t=performance.now(),n=await $R(e),r=Math.round(performance.now()-t),i=new Uint8Array(await n.slice(0,12).arrayBuffer()),a=String.fromCharCode(i[4],i[5],i[6],i[7])===`ftyp`,o=URL.createObjectURL(n),s=await new Promise(e=>{let t=document.createElement(`video`);t.preload=`metadata`,t.muted=!0,t.onloadedmetadata=()=>e({w:t.videoWidth,h:t.videoHeight,dur:Math.round(t.duration*100)/100}),t.onerror=()=>e({error:`decode`}),t.src=o,setTimeout(()=>e({error:`timeout`}),8e3)});return URL.revokeObjectURL(o),{ok:!0,layers:e.layers.length,dims:[e.width,e.height],size:n.size,ftyp:a,probe:s,ms:r}}async function oz(){let e=await IR({targetDuration:4,trackOrder:[`video`],audio:[],clips:[{id:`a`,kind:`image`,trackId:`video`,url:nz(`A`,`#1a3a5a`),start:0,duration:2,transition:{type:`Wipe left`,duration:1},transform:{opacity:1}},{id:`b`,kind:`image`,trackId:`video`,url:nz(`B`,`#5a1a3a`),start:2,duration:2,transform:{opacity:1}}]}),t=await $R(e),n=new Map;for(let t of e.layers)n.set(t.id,await OR(t));let r=document.getElementById(`__rt`);r||(r=document.createElement(`canvas`),r.id=`__rt`,r.style.cssText=`position:fixed;top:8px;left:8px;z-index:99999;border:2px solid #0ff;background:#000`,document.body.appendChild(r)),r.width=640,r.height=360,await Wg(r.getContext(`2d`),e,2,n,640,360);let i=new Uint8Array(await t.slice(0,12).arrayBuffer()),a=String.fromCharCode(i[4],i[5],i[6],i[7])===`ftyp`;return{ok:!0,transitions:e.transitions.length,transition:e.transitions[0],size:t.size,ftyp:a}}async function sz(){let e=await IR({targetDuration:3,trackOrder:[`video`],audio:[],previewH:360,clips:[{id:`bg`,kind:`image`,trackId:`video`,url:nz(`BG`,`#22303a`),start:0,duration:3,transform:{opacity:1}}],overlays:[{text:`Title Card`,subtitle:``,font:`Georgia`,size:60,color:`#ffffff`,background:`#16140F`,backgroundOpacity:90,backgroundPadding:10,backgroundRadius:5,position:`center`,start:0,end:3},{text:`A caption at the bottom`,font:`Hanken Grotesk`,size:28,color:`#ffffff`,background:`#000000`,backgroundOpacity:45,backgroundPadding:10,backgroundRadius:6,position:`bottom center`,start:0,end:3}],stickers:[{shape:`circle`,color:`#e0b84c`,x:22,y:30,scale:1,opacity:.9,rotation:0,start:0,end:3},{shape:`frame`,color:`#ffffff`,x:78,y:32,scale:1,opacity:.9,rotation:0,start:0,end:3}]}),t=await $R(e),n=new Map;for(let t of e.layers)n.set(t.id,await OR(t));let r=document.getElementById(`__rt`);r||(r=document.createElement(`canvas`),r.id=`__rt`,r.style.cssText=`position:fixed;top:8px;left:8px;z-index:99999;border:2px solid #ff0;background:#000`,document.body.appendChild(r)),r.width=640,r.height=360,await Wg(r.getContext(`2d`),e,1,n,640,360);let i=new Uint8Array(await t.slice(0,12).arrayBuffer()),a=String.fromCharCode(i[4],i[5],i[6],i[7])===`ftyp`;return{ok:!0,overlays:e.overlays.length,stickers:e.stickers.length,size:t.size,ftyp:a}}var cz,lz=o((()=>{Hi(),Is(),zs(),Nd(),Jg(),AR(),zR(),vp(),HR(),Dm(),Ei(),cz=e=>{if(e?.aborted)throw Object.assign(Error(`Export aborted`),{name:`AbortError`})}})),uz=c({__overlayTest:()=>sz,__planTest:()=>az,__renderTest:()=>rz,__smokeTestExport:()=>tz,__transitionTest:()=>oz,__videoTest:()=>iz,exportEditorAudioMp3:()=>ZR,exportEditorTimeline:()=>JR,getExportCapabilities:()=>qR,renderRecordingCut:()=>XR,renderTimeline:()=>$R,renderWorkingCopy:()=>YR}),dz,fz,pz=o((()=>{Ni(),ki(),Un(),lz(),dz=e=>()=>{throw Error(e+` is unavailable in the local preview.`)},fz={version:1};for(let e of Oi)fz[e]=[`toast`,`presenterHost`,`upgradeReasons`].includes(e)?{}:dz(e);Object.assign(fz,{loadMediaBlob:async e=>{let t=typeof e==`string`?e:e?.url,n=t?await fetch(t).catch(()=>null):null;return n?.ok?n.blob():{missing:!0,ref:e}},loadMediaArrayBuffer:async e=>{let t=typeof e==`string`?e:e?.url,n=t?await fetch(t).catch(()=>null):null;return n?.ok?n.arrayBuffer():{missing:!0,ref:e}},resolveDesktopMediaUrl:async e=>typeof e==`string`&&e.startsWith(`sm-media://asset/`)?e:null,isMissing:e=>!!(e&&e.missing),proxiedMediaUrl:e=>e,cachedObjectUrlIfPresent:()=>null,desktopBridge:()=>null,isDeviceMediaUrl:Dn,resolveDeviceMediaUrl:vn,deviceMediaUrlFor:e=>/^[0-9a-f-]{36}$/i.test(e?.assetId||``)&&/^[0-9a-f]{64}$/.test(e?.versionId||``)?Tn(e):null,loadDeviceMediaBlob:async e=>{let t=En(e);if(!t)return null;try{return await gn(t)}catch{return null}}}),Ai(fz)})),mz=c({cutRecording:()=>_z,cutWithMediaRecorder:()=>gz,rendererAvailable:()=>hz});async function hz({capabilities:e}={}){try{if(typeof VideoEncoder>`u`||typeof OffscreenCanvas>`u`)return!1;let t=await(e||(await Ti(async()=>{let{getExportCapabilities:e}=await Promise.resolve().then(()=>(pz(),uz));return{getExportCapabilities:e}},void 0)).getExportCapabilities)();return t?.strategy===`webcodecs`||t?.strategy===`native`}catch{return!1}}async function gz(e,{keep:t,width:n,height:r,shortSide:i=1080,fps:a=30,signal:o,onProgress:s,documentRef:c=globalThis.document}={}){if(typeof MediaRecorder!=`function`||!c)throw Error(`This browser cannot cut recordings.`);let l=(t||[]).filter(e=>e.end>e.start);if(!l.length)throw Error(`Keep at least part of the recording.`);let u=l.reduce((e,t)=>e+t.end-t.start,0),d=vz(n||1920,r||1080,i),f=URL.createObjectURL(e),p=c.createElement(`video`),m=c.createElement(`canvas`);m.width=d.width,m.height=d.height;for(let e of[p,m])e.setAttribute(`aria-hidden`,`true`),e.style.position=`fixed`,e.style.left=`-20000px`,e.style.top=`0`,e.style.width=`1px`,e.style.height=`1px`;p.preload=`auto`,p.playsInline=!0,p.muted=!1,p.volume=1,p.src=f,c.body.append(p,m);let h=m.getContext(`2d`,{alpha:!1}),g=null,_=null,v=null,y=null,b=()=>{clearInterval(y);try{_?.getTracks().forEach(e=>e.stop())}catch{}try{g?.close()}catch{}p.pause(),p.removeAttribute(`src`);try{p.load()}catch{}p.remove(),m.remove(),URL.revokeObjectURL(f)},x=()=>{if(o?.aborted)throw Object.assign(Error(`The cut was cancelled.`),{name:`AbortError`})};try{await new Promise((e,t)=>{let n=setTimeout(()=>t(Error(`The recording did not load in time.`)),3e4);p.onloadedmetadata=()=>{clearTimeout(n),e()},p.onerror=()=>{clearTimeout(n),t(Error(`This recording could not be read.`))}}),x(),_=m.captureStream(a);let e=globalThis.AudioContext||globalThis.webkitAudioContext;if(typeof e==`function`&&typeof MediaStream==`function`)try{g=new e;let t=g.createMediaStreamDestination();g.createMediaElementSource(p).connect(t),_=new MediaStream([..._.getVideoTracks(),...t.stream.getAudioTracks()])}catch{g?.close?.(),g=null}let t=Ir(`screen`,{isTypeSupported:e=>MediaRecorder.isTypeSupported?.(e),canPlayType:e=>c.createElement(`video`).canPlayType(e)});v=new MediaRecorder(_,{...t?{mimeType:t}:{},videoBitsPerSecond:Lr({width:d.width,height:d.height,frameRate:a}),audioBitsPerSecond:Hr.voice});let n=[];v.addEventListener(`dataavailable`,e=>{e.data?.size&&n.push(e.data)});let r=new Promise(e=>v.addEventListener(`stop`,e,{once:!0})),i=new Promise((e,t)=>v.addEventListener(`error`,()=>t(Error(`Recording the cut failed.`)),{once:!0})),f=()=>{try{h.drawImage(p,0,0,d.width,d.height)}catch{}},b=e=>new Promise((t,n)=>{let r=setTimeout(()=>n(Error(`The recording could not be positioned.`)),15e3);p.onseeked=()=>{clearTimeout(r),t()},p.currentTime=e});await b(l[0].start),f(),v.start(1e3),v.pause();let S=0;y=setInterval(f,Math.round(1e3/a));for(let e of l)x(),Math.abs(p.currentTime-e.start)>.05&&await b(e.start),f(),await g?.resume?.(),v.resume(),await p.play(),await new Promise((t,n)=>{let r=()=>{if(o?.aborted){n(Object.assign(Error(`The cut was cancelled.`),{name:`AbortError`}));return}let i=p.currentTime;if(s?.(Math.min(1,(S+Math.max(0,i-e.start))/u)),i>=e.end-1/a||p.ended){t();return}setTimeout(r,40)};Promise.race([i]).catch(n),r()}),p.pause(),v.pause(),S+=e.end-e.start;v.stop(),await Promise.race([r,i]);let C=v.mimeType||t||`video/webm`,w=await kr(new Blob(n,{type:C}),u*1e3);if(!w.size)throw Error(`Nothing was recorded from the cut.`);return s?.(1),{file:w,duration:u,width:d.width,height:d.height}}finally{b()}}async function _z(e,{keep:t,width:n,height:r,duration:i,shortSide:a=1080,fps:o=30,signal:s,onProgress:c,renderer:l,playback:u=gz,available:d=hz}={}){return await d()?{...await(l||(await Ti(async()=>{let{renderRecordingCut:e}=await Promise.resolve().then(()=>(pz(),uz));return{renderRecordingCut:e}},void 0)).renderRecordingCut)(e,{keep:t,width:n,height:r,duration:i,fps:o,shortSide:a,signal:s,onProgress:c}),method:`renderer`}:{...await u(e,{keep:t,width:n,height:r,shortSide:a,fps:o,signal:s,onProgress:c}),method:`playback`}}var vz,yz=o((()=>{Ei(),vz=(e,t,n)=>{let r=Math.min(1,n/Math.max(1,Math.min(e,t)));return{width:Math.max(2,Math.round(e*r/2)*2),height:Math.max(2,Math.round(t*r/2)*2)}}})),bz=c({canvasMediaFile:()=>xz,uploadCanvasMediaFile:()=>Sz});function xz(){return{kind:null}}async function Sz(){throw Error(`Read media from a folder in StillMade; the local preview reads text only.`)}var Cz=o((()=>{}));Et(),Ge(),Xt(),Un(),Fr(),Kr(),Ei();var wz={screen:`screen.capture`,camera:`camera.capture`,microphone:`microphone.capture`},Tz=500,Ez=async(e,t)=>(await Ti(async()=>{let{cutRecording:e}=await Promise.resolve().then(()=>(yz(),mz));return{cutRecording:e}},void 0)).cutRecording(e,t),Dz=async()=>{if(typeof MediaRecorder!=`function`)return`none`;try{return await(await Ti(async()=>{let{rendererAvailable:e}=await Promise.resolve().then(()=>(yz(),mz));return{rendererAvailable:e}},void 0)).rendererAvailable()?`renderer`:`playback`}catch{return`playback`}};async function Oz(e){if(typeof document>`u`)return{};let t=URL.createObjectURL(e),n=document.createElement(`video`);n.preload=`metadata`,n.muted=!0;try{return await new Promise((e,r)=>{let i=setTimeout(()=>r(Error(`The video did not load in time.`)),3e4);n.onloadedmetadata=()=>{clearTimeout(i),e({duration:Number.isFinite(n.duration)?n.duration:0,width:n.videoWidth,height:n.videoHeight})},n.onerror=()=>{clearTimeout(i),r(Error(`This video cannot be read here.`))},n.src=t})}finally{n.removeAttribute(`src`);try{n.load()}catch{}URL.revokeObjectURL(t)}}var kz=/^\/api\/media\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-][A-Za-z0-9._-]*$/;async function Az(e,{signal:t}={}){let n=typeof location<`u`?location.origin:``,r=e.startsWith(`sm-media://asset/`),i=kz.test(e),a=n&&e.startsWith(`blob:${n}/`);if(!r&&!i&&!a)throw Error(`Cut a recording kept on this device or saved in StillMade.`);let o=await fetch(e,{signal:t,credentials:`omit`,redirect:i?`follow`:`error`,referrerPolicy:`no-referrer`}).catch(()=>null);if(!o?.ok)throw Error(`This video cannot be read here.`);let s=(o.headers.get(`content-type`)||``).split(`;`)[0].trim().toLowerCase();if(!Gn.video.includes(s))throw Error(`Choose a supported video file.`);if(Number(o.headers.get(`content-length`))>2147483648)throw Error(`Videos over 2 GB cannot be cut here.`);if(!o.body?.getReader)return o.blob();let c=o.body.getReader(),l=[],u=0;try{for(;;){let{done:e,value:t}=await c.read();if(e)break;if(u+=t.byteLength,u>2147483648)throw Error(`Videos over 2 GB cannot be cut here.`);l.push(t)}}finally{await c.cancel().catch(()=>{}),c.releaseLock()}return new Blob(l,{type:s})}function jz(e,t){if(!Array.isArray(e)||!e.length||e.length>Tz)throw Error(`Keep 1 to ${Tz} ranges of the recording.`);let n=-1,r=[];for(let i of e){let e=Number(i?.start),a=Number(i?.end);if(!Number.isFinite(e)||!Number.isFinite(a)||e<0||e<n||a<=e)throw Error(`Keep ranges are ordered, non-overlapping {start, end} seconds.`);r.push({start:e,end:t>0?Math.min(a,t):a}),n=a}return r.filter(e=>e.end-e.start>.001)}var Mz={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!1},Nz=1048576,Pz=e=>{try{for(let t of e?.getTracks?.()||[])t.stop()}catch{}},Fz=(e,t)=>{try{return e?.[t===`video`?`getVideoTracks`:`getAudioTracks`]?.()||[]}catch{return[]}},Iz=e=>{try{return e?.getSettings?.()||{}}catch{return{}}},Lz=e=>[`NotAllowedError`,`AbortError`].includes(e?.name);function Rz(e,{bridge:t=globalThis.stillmadeDesktop?.blockDesktop,onStatus:n=()=>{},onLive:r=()=>{},onActivity:i=()=>{},storageScope:a=`preview`,limits:o,now:s=Date.now,renderCut:c=Ez,probeVideo:l=Oz,probeCut:u=Dz}={}){let d=null,f=null,p=!1,m=null,h=null,g=!1,_=null,v=null,y=new Set,b=e=>e&&[`audio`,`video`,`image`].includes(e.kind)&&[`assetId`,`versionId`,`url`].every(t=>typeof e[t]==`string`&&e[t])?JSON.stringify([e.kind,e.assetId,e.versionId,e.url]):``,x=e?.manifest?.permissions?.desktop||[],S=new Map((e?.manifest?.desktopTools||[]).map(e=>[e.id,new Set(e.actions||[])])),C={"tool.launch":`launch`,"tool.project.import":`project.import`,"tool.project.open":`project.open`,"tool.project.render":`project.render`,"tool.adapter.import":`adapter.import`,"tool.adapter.inspect":`adapter.inspect`,"tool.adapter.execute":`adapter.execute`,"tool.adapter.describe":`adapter.describe`,"tool.adapter.call":`adapter.call`},w=t?`desktop`:`browser`,T=!!t&&[`recordingOpen`,`recordingAppend`,`recordingClose`].every(e=>typeof t[e]==`function`),E={...w===`browser`?Wr.browser:T?Wr.desktop:Wr.legacyDesktop,...o},D=()=>({seconds:E.seconds,bytes:Number.isFinite(E.bytes)?E.bytes:null}),O=async(e,n,r)=>{if(!T)return t.save(d,e,new Uint8Array(await n.arrayBuffer()),r);let{id:i,maxAppendBytes:a}=await t.recordingOpen(d,{kind:e,mime:r}),o=Math.min(a||8*Nz,8*Nz);try{for(let e=0;e<n.size;e+=o)await t.recordingAppend(d,i,new Uint8Array(await n.slice(e,e+o).arrayBuffer()))}catch(e){throw await t.recordingClose(d,i,{discard:!0}).catch(()=>{}),e}return t.recordingClose(d,i,{})},k=e=>new Promise((t,r)=>{_={reject:r},n({awaitingStart:!0,...e,start:()=>{_=null,n({active:!1}),t()},cancel:()=>{_=null,n({active:!1}),r(Error(e.kind===`folder`?`No folder was chosen.`:`Folder access was not allowed.`))}})}),A=null,j=()=>A||=(async()=>yi({key:await bi(e,a),digest:await gt(e),name:e.manifest.name,permissions:x,askToStart:k,importMedia:async(e,t)=>{let{uploadCanvasMediaFile:n,canvasMediaFile:r}=await Ti(async()=>{let{uploadCanvasMediaFile:e,canvasMediaFile:t}=await Promise.resolve().then(()=>(Cz(),bz));return{uploadCanvasMediaFile:e,canvasMediaFile:t}},void 0),i=null;try{i=r({name:e.name,type:e.type,size:1}).kind}catch{}if(![`image`,`video`,`audio`].includes(i))throw Error(`Read ${e.name} as text; only images, video and audio are read as media.`);let a=await n(e,{localFirst:!0,handle:t});return{kind:a.kind,assetId:a.assetId,versionId:a.versionId,url:a.url,source:`local`,...a.mimeType?{mimeType:a.mimeType}:{},...a.bytes?{bytes:a.bytes}:{},name:e.name}},mediaBlob:async e=>{if(!Dn(e?.url))throw Error(`Not on this device`);return gn(e)}}))(),M=()=>{if(!t)throw Error(`This capability requires the StillMade desktop app.`)},N=e=>{if(p)throw Error(`Block desktop access was closed. Reopen the Block.`);if(!x.includes(e))throw Error(`Declare permissions.desktop: ${e}`)},P=async()=>(f||=(async()=>{M();let n=e.manifest,r=await t.open({id:n.id,version:n.version,digest:await gt(e),permissions:x,tools:n.desktopTools||[],name:n.name,storageScope:`${Jt()||`anonymous`}:${a}`,remember:{key:await bi(e,a)}});if(p)throw await t.close(r),Error(`Block was closed`);return d=r,r})(),f),F=async(e,n={})=>{M(),N(e);let r=await P();if(p)throw Error(`Block was closed`);return t.invoke(r,e,n)},I=(e,t,r)=>{if(!(m!==e||e.ended)){e.ended={stoppedBy:t,message:r},e.endedAt=s(),clearTimeout(e.timer),clearInterval(e.cursorTimer);try{e.recorder.state!==`inactive`&&e.recorder.stop()}catch{}n({active:!0,ended:!0,kind:e.kind,stoppedBy:t,message:r})}},ee=e=>{clearTimeout(e.timer),clearInterval(e.cursorTimer),Pz(e.stream),Pz(e.microphone);try{e.audioContext?.close?.()}catch{}},te=(e,n)=>{e.appending=e.appending.then(async()=>{e.discarded||await t.recordingAppend(d,e.sink.id,new Uint8Array(await n.arrayBuffer()))}).catch(t=>{!e.ended&&!e.discarded&&I(e,`disk`,t?.message||`The recording could not be written to disk.`)})},L=async e=>{let r=m;if(!r)throw Error(`No recording is active`);return r.finishing||=(async()=>{if(r.recorder.state!==`inactive`&&r.recorder.stop(),await r.stopped,ee(r),m=null,n({active:!1}),r.sink&&await r.appending,!e)return r.sink&&(r.discarded=!0,await t.recordingClose(d,r.sink.id,{discard:!0}).catch(()=>{})),{cancelled:!0};if(r.error)throw r.sink&&(r.discarded=!0,await t.recordingClose(d,r.sink.id,{discard:!0}).catch(()=>{})),Error(r.error);if(!r.chunks.length)throw Error(`Nothing was recorded.`);let i=r.recorder.mimeType||r.mimeType||``,a=Math.max(1,(r.endedAt||s())-r.started),o=r.kind===`microphone`?`audio`:`video`,c=i.split(`;`)[0].trim(),l={duration:a/1e3,mimeType:c,...o===`video`&&r.width?{width:r.width,height:r.height}:{}},u;if(r.sink){let e=await kr(new Blob([r.chunks[0]],i?{type:i}:void 0),a);u=await t.recordingClose(d,r.sink.id,{head:new Uint8Array(await e.arrayBuffer())})}else{let e=await kr(new Blob(r.chunks,i?{type:i}:void 0),a);if(t)u=await t.save(d,r.kind,new Uint8Array(await e.arrayBuffer()),c);else{let t=Gr(r.kind,c,r.started);u=yn(await pn(new File([e],t,i?{type:c}:void 0),{kind:o,metadata:l,maxBytes:E.bytes}),{name:t})}}let f=b(u);return f&&y.add(f),{asset:u,...l,bytes:r.bytes,...r.ended?{stoppedBy:r.ended.stoppedBy,message:r.ended.message}:{},cursor:r.cursor,displays:r.displays||[],coordinates:`Global screen coordinates in device-independent pixels; timestamps in milliseconds relative to recording start.`}})(),r.finishing},R=()=>{let e=m;return e?{active:!0,platform:w,kind:e.kind,elapsed:(e.endedAt||s())-e.started,bytes:e.bytes,ended:!!e.ended,...e.ended||{},limits:D()}:{active:!1,platform:w,...v?{cutting:{progress:v.progress}}:{},limits:D()}},ne=async()=>{N(Object.values(wz).find(e=>x.includes(e))||`screen.capture`);let e=typeof MediaRecorder==`function`&&!!navigator?.mediaDevices?.getDisplayMedia,n=null,r=0;if(!t)try{let e=await bn();n=Number.isFinite(e?.quota)?e.quota:null,r=Number(e?.bytes)||0}catch{}let i=Lr({width:1920,height:1080,frameRate:30})+Hr.voice,a=w===`browser`?zr({platform:`browser`,bitsPerSecond:i,quota:n,used:r}):{seconds:E.seconds,bytes:Number.isFinite(E.bytes)?E.bytes:null};return w===`browser`&&Number.isFinite(E.bytes)&&(a.bytes=Math.min(a.bytes,E.bytes)),{platform:w,streams:T,recorder:!!e&&(t?!0:fn()),cut:e?await u():`none`,budget:{seconds:Math.min(a.seconds,E.seconds),bytes:a.bytes==null?null:Math.floor(a.bytes/Nz)*Nz,bitsPerSecond:i},limits:D()}},re=async(e,t)=>{let n=navigator.mediaDevices;if(e===`screen`){let e=Rr({resolution:t.resolution,frameRate:t.frameRate}),r=t=>n.getDisplayMedia({video:e,audio:t}),i=t.systemAudio===!0;try{return await r(i)}catch(e){if(!i||Lz(e))throw e;return r(!1)}}return e===`camera`?n.getUserMedia({video:Rr({resolution:t.resolution,frameRate:t.frameRate}),audio:!1}):n.getUserMedia({video:!1,audio:Mz})},ie=(e,t)=>{if(!t)return{recorded:e};let n=Fz(t,`audio`),r=Fz(e,`audio`);if(!n.length)return{recorded:e};let i=globalThis.AudioContext||globalThis.webkitAudioContext;if(r.length&&typeof i==`function`&&typeof MediaStream==`function`){let n=new i,r=n.createMediaStreamDestination();for(let i of[e,t])n.createMediaStreamSource(i).connect(r);return{recorded:new MediaStream([...Fz(e,`video`),...Fz(r.stream,`audio`)]),audioContext:n}}return typeof MediaStream==`function`?{recorded:new MediaStream([...Fz(e,`video`),...r.length?r:n])}:{recorded:e}},ae=async(e,n=[])=>{if(N([`screen.capture`,`camera.capture`].find(e=>x.includes(e))||`screen.capture`),m)throw Error(`Stop the recording before cutting it.`);let r=e.source;if(!b(r)||r.kind!==`video`)throw Error(`Choose the video to cut.`);if(!y.has(b(r))&&!(Array.isArray(n)?n:[]).some(e=>b(e)===b(r)))throw Error(`Cut a video this Block received or recorded in this session.`);let i=String(r.url),a,o={width:Number(r.width)||0,height:Number(r.height)||0,duration:Number(r.duration)||0};if(Dn(i)){let e=En(i),t=await mn(e);if(!t)throw Error(`This recording is not on this device.`);a=await gn(e),o={width:Number(t.width)||o.width,height:Number(t.height)||o.height,duration:Number(t.duration)||o.duration}}else a=await Az(i);if(p)throw Error(`Block was closed`);o.width>0&&o.height>0&&o.duration>0||(o={...o,...await l(a)});let u=jz(e.keep,o.duration);if(!u.length)throw Error(`Keep at least part of the recording.`);v={progress:0,started:s()};try{let e=await c(a,{keep:u,width:o.width,height:o.height,duration:o.duration,onProgress:e=>{let t=typeof e==`number`?e:e?.total?e.done/e.total:null;Number.isFinite(t)&&v&&(v.progress=Math.max(0,Math.min(1,t)))}});if(p)throw Error(`Block was closed`);let n=e?.file;if(!(n instanceof Blob)||!n.size)throw Error(`The cut could not be rendered here.`);let i=await l(n).catch(()=>({})),s=String(n.type||`video/mp4`).split(`;`)[0].trim(),d={duration:i.duration||e.duration||u.reduce((e,t)=>e+t.end-t.start,0),width:i.width||o.width,height:i.height||o.height,mimeType:s},f=`${String(r.name||`recording`).replace(/\.[a-z0-9]+$/i,``).slice(0,200)||`recording`}-cut.${/webm/.test(s)?`webm`:`mp4`}`,m;m=t?await O(`screen`,n,s):yn(await pn(new File([n],f,{type:s}),{kind:`video`,metadata:d,maxBytes:E.bytes}),{name:f});let h=b(m);return h&&y.add(h),{asset:m,...d,bytes:n.size,keep:u}}finally{v=null}},oe=async e=>{if(h)throw Error(`The live feed is already on.`);if(m)throw Error(`Stop the recording before starting the live feed.`);let i=Yr(e),{camera:a,microphone:o}=i;if(a&&N(`camera.capture`),o&&N(`microphone.capture`),!navigator?.mediaDevices?.getUserMedia)throw Error(`This browser cannot open a camera or microphone. Use a current desktop browser or StillMade Desktop.`);if(await new Promise((e,t)=>{_={reject:t},n({awaitingStart:!0,kind:`live`,camera:a,microphone:o,start:()=>{_=null,e()}})}),p)throw Error(`Block was closed`);t&&(a&&await F(`camera.capture`),o&&await F(`microphone.capture`));let s=await navigator.mediaDevices.getUserMedia({video:a?{width:{ideal:i.width},frameRate:{ideal:i.fps}}:!1,audio:o?Mz:!1});if(p)throw Pz(s),Error(`Block was closed`);let c=Qr(s,{...i,onFrame:(e,t)=>{h===c?r({type:`frame`,bitmap:e,...t},[e]):e.close?.()},onAudio:(e,t)=>{h===c&&r({type:`audio`,samples:e,...t},[e.buffer])},onEnded:e=>{h===c&&(h=null,n({active:!1}),r({type:`ended`,reason:e},[]))}});h=c;let l=await c.ready;if(h!==c)throw Error(`The live feed ended before it started.`);return n({active:!0,kind:`live`,camera:a,microphone:o,stop:()=>c.stop(`person`)}),{live:!0,...l}},se=()=>h?{live:!0,...h.info}:{live:!1},ce=[],le=new Map,ue=()=>i({entries:[...ce],folders:[...le.values()]}),de=e=>{ce[0]?.text===e?ce[0]={...ce[0],at:s(),count:(ce[0].count||1)+1}:ce.unshift({at:s(),text:e}),ce.length=Math.min(ce.length,50),ue()},fe=(e,t,n)=>{if(e===`folder.shared`||e===`folder.pick`)for(let e of n?.folders||(n?.folder?[n.folder]:[]))le.set(e.id,e);if(e===`folder.forget`){let e=le.get(t.folder);return le.delete(t.folder),e&&`Stopped using ${e.name}`}let r=le.get(t?.folder)?.name||`the shared folder`,i=typeof t?.path==`string`&&t.path?t.path:``;return e===`folder.pick`?`Shared ${n.folder.name} for ${n.folder.write?`reading and changing`:`reading`}`:e===`folder.read`?`Read ${i} in ${r}`:e===`folder.write`?`${n?.replaced?`Replaced`:`Wrote`} ${i} in ${r}`:e===`folder.list`?`Looked in ${i?`${i} in `:``}${r}`:e===`clipboard.read`?`Read the text you copied`:e===`clipboard.write`?`Replaced the text you copied`:e===`media.pick`?`Opened ${n?.assets?.length||0} files you chose`:e.startsWith(`tool.`)&&e!==`tool.status`?`Ran ${t?.tool||`a desktop program`} (${e.slice(5)})`:null},pe=async(e,t={},n={})=>{let r=await me(e,t,n);try{let n=fe(e,t,r);n?de(n):e===`folder.shared`&&ue()}catch{}return r},me=async(e,r={},{received:i}={})=>{if(e===`record.stop`)return L(!0);if(e===`record.cancel`)return L(!1);if(e===`record.status`)return R();if(e===`device.info`)return ne();if(e===`session.close`)return await he(),{closed:!0};if(e===`live.status`)return se();if(e===`live.stop`)return h?.stop(`stopped`),{live:!1};if(g)throw Error(`A desktop request is already in progress`);g=!0;try{if(e===`record.cut`)return await ae(r,i);if(e===`live.start`)return await oe(r);if(e!==`record.start`){if(e.startsWith(`tool.`)){M(),N(`native.tools`);let n=S.get(r.tool),i=C[e];if(!n||e!==`tool.status`&&!n.has(i))throw Error(`Declare the exact desktop tool action`);let a=await t.invoke(await P(),e,r);if(p)throw Error(`Block desktop access closed before the native operation completed.`);let o=b(a?.asset);return o&&y.add(o),a}if(e.startsWith(`storage.`)){if(![`storage.info`,`storage.list`,`storage.read`,`storage.write`,`storage.remove`].includes(e))throw Error(`Unknown storage operation`);if(!t)throw Error(`Device storage requires the StillMade desktop app.`);if(p)throw Error(`Block desktop access was closed. Reopen the Block.`);return t.invoke(await P(),e,r)}if(e.startsWith(`folder.`)){if(!ei.includes(e))throw Error(`Unknown folder operation`);if(N(`folder.read`),(e===`folder.write`||e===`folder.pick`&&r.write===!0)&&N(`folder.write`),e===`folder.write`&&r.asset!==void 0&&!(y.has(b(r.asset))||(Array.isArray(i)?i:[]).some(e=>b(e)===b(r.asset))))throw Error(`Write a file this Block saved or received in this session.`);if(!t&&!pi())throw Error(`Folders need Chrome, Edge or StillMade Desktop.`);let n=t?await t.invoke(await P(),e,r):await(await j()).invoke(e,r);if(p)throw Error(`Block desktop access closed before the folder operation completed.`);let a=b(n?.asset);return a&&y.add(a),n}if(!We.includes(e))throw Error(`Unknown desktop operation`);if(Object.values(wz).includes(e))throw Error(`Use record.start with kind screen, camera, or microphone.`);let n=await F(e,r);if(e===`media.pick`)for(let e of n?.assets||[]){let t=b(e);t&&y.add(t)}return n}if(m)throw Error(`A recording is already active`);if(h)throw Error(`Stop the live feed before recording.`);let a=r.kind||`screen`,o=wz[a];if(!o)throw Error(`Choose screen, camera, or microphone`);N(o);let c=a===`screen`&&r.microphone===!0;if(c&&N(`microphone.capture`),r.cursor&&(N(`cursor.track`),M(),await F(`cursor.track`)),!t){if(!navigator?.mediaDevices?.[a===`screen`?`getDisplayMedia`:`getUserMedia`]||typeof MediaRecorder!=`function`)throw Error(`This browser cannot record. Use a current desktop browser or StillMade Desktop.`);if(!fn())throw Error(`This browser cannot keep recordings on the device. Use StillMade Desktop.`)}if(await new Promise((e,t)=>{_={reject:t},n({awaitingStart:!0,kind:a,microphone:c,start:()=>{_=null,e()}})}),p)throw Error(`Block was closed`);t&&(await F(o,a===`screen`?{systemAudio:r.systemAudio===!0}:{}),c&&await F(`microphone.capture`));let l=await re(a,r);if(p)throw Pz(l),Error(`Block was closed`);let u=null;if(c){try{u=await navigator.mediaDevices.getUserMedia({video:!1,audio:Mz})}catch(e){throw Pz(l),Error(`The microphone is unavailable: ${e?.message||e}`)}if(p)throw Pz(l),Pz(u),Error(`Block was closed`)}let f=Iz(Fz(l,`video`)[0]),g=Number(f.width)||0,v=Number(f.height)||0,x=Ir(a,{isTypeSupported:e=>MediaRecorder.isTypeSupported?.(e),canPlayType:e=>typeof document<`u`?document.createElement(`video`).canPlayType(e):`maybe`}),w={...x?{mimeType:x}:{},...a===`microphone`?{}:{videoBitsPerSecond:Lr({width:g,height:v,frameRate:f.frameRate})},audioBitsPerSecond:r.systemAudio===!0?Hr.system:Hr.voice},O,k,A;try{({recorded:O,audioContext:k}=ie(l,u)),A=new MediaRecorder(O,w)}catch(e){Pz(l),Pz(u);try{k?.close?.()}catch{}throw e}let R={kind:a,stream:l,microphone:u,audioContext:k,recorder:A,mimeType:x,width:g,height:v,chunks:[],bytes:0,cursor:[],started:s(),error:null,ended:null,endedAt:null,sink:null,appending:Promise.resolve(),discarded:!1};if(m=R,T){try{R.sink=await t.recordingOpen(d,{kind:a,mime:(A.mimeType||x||``).split(`;`)[0].trim()})}catch(e){throw ee(R),m=null,e}if(p)throw ee(R),m=null,await t.recordingClose(d,R.sink.id,{discard:!0}).catch(()=>{}),Error(`Block was closed`)}R.stopped=new Promise(e=>A.addEventListener(`stop`,e,{once:!0})),A.addEventListener(`dataavailable`,e=>{let n=e.data?.size||0;if(n&&m===R){if(R.bytes+n>E.bytes){I(R,`size`,`This recording reached the ${Math.round(E.bytes/Nz)} MB that fit here and was saved up to that point.${t?``:` StillMade Desktop records longer.`}`);return}R.bytes+=n,R.sink&&R.chunks.length?te(R,e.data):R.chunks.push(e.data)}}),A.addEventListener(`error`,()=>{R.error=`Recording failed`,L(!1).catch(()=>{})});for(let e of[...Fz(l,`video`),...Fz(l,`audio`)])e.addEventListener(`ended`,()=>{m===R&&!R.ended&&I(R,`sharing`,`Sharing ended. The recording was saved up to that point.`)});try{A.start(1e3)}catch(e){throw ee(R),m=null,e}if(r.cursor){let e=!1;R.cursorTimer=setInterval(async()=>{if(!(e||m!==R||R.ended||R.cursor.length>=18e3)){e=!0;try{let e=await F(`cursor.track`);m===R&&(R.displays=e.displays,R.cursor.push({x:e.x,y:e.y,time:e.time-R.started}))}catch(e){R.error=e.message,L(!1).catch(()=>{})}finally{e=!1}}},100)}return R.ended||(R.timer=setTimeout(()=>I(R,`time`,`This recording reached the ${Math.round(E.seconds/60)} minute limit and was saved up to that point.`),E.seconds*1e3),n({active:!0,kind:a})),{recording:!0,kind:a,cursor:!!r.cursor,microphone:!!u,mimeType:x||null,width:g,height:v,limits:D()}}catch(e){throw!m&&!h&&n({active:!1,error:e.message}),e}finally{g=!1}},he=async()=>{p||(p=!0,ge?.(),_?.reject(Error(`Recording cancelled`)),_=null,h?.stop(`closed`),m&&(Pz(m.stream),Pz(m.microphone)),m&&await L(!1).catch(()=>{}),d&&await t.close(d).catch(()=>{}),n({active:!1,closed:!0}))},ge=t?.onRevoked?.(e=>{d===e&&he().catch(()=>{})});return{call:pe,close:he,authorizesMedia:e=>y.has(b(e)),liveAck:()=>h?.ack(),platform:w}}function zz(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function Bz(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&MB.test(String.fromCharCode(e)):t!==!1&&zz(e,TB)}function Vz(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&NB.test(String.fromCharCode(e)):t===!1?!1:zz(e,TB)||zz(e,wB)}function Hz(e,t){return new PB(e,{beforeExpr:!0,binop:t})}function Uz(e,t){return t===void 0&&(t={}),t.keyword=e,LB[e]=new PB(e,t)}function Wz(e){return e===10||e===13||e===8232||e===8233}function Gz(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(Wz(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}function Kz(e){return qB[e]||(qB[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function qz(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function Jz(e,t){for(var n=1,r=0;;){var i=Gz(e,r,t);if(i<0)return new YB(n,t-r);++n,r=i}}function Yz(e){var t={};for(var n in ZB)t[n]=e&&GB(e,n)?e[n]:ZB[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!QB&&typeof console==`object`&&console.warn&&(QB=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
1170
+ </g>`,Bk=`http://www.w3.org/2000/svg`,Vk=e=>e===`left`||e===`right`,Hk=(e,t)=>e.querySelector(`[data-role="${t}"]`)}));function Wk(e,t,n){e===`talk`&&(e=`talkGesture`);let r=Qk[e];return r?r(t,n):{}}function Gk(e){let t=(X(e*8.7)+1)/2;return{mOpen:2+t*12,mWidth:12+t*15,mCurve:2+X(e*4.6)*6}}function Kk(e,t=0){return{armR:6*X(e*4.6),armL:4*X(e*4.6+1),headTilt:1.2*X(e*2.2)+t*3}}function qk(e,...t){let n={...e};for(let e of t)for(let t in e)n[t]=(n[t]||0)+e[t];return n}var X,Jk,Yk,Xk,Zk,Qk,$k,eA,tA=o((()=>{X=Math.sin,Jk=Math.cos,Yk=Math.max,Xk=Math.PI,Zk=(e,t,n)=>e<t?t:e>n?n:e,Qk={idle(e){return{headTilt:1.2*X(e*1.2),bob:1.5*X(e*1.5),armR:-8+2*X(e),armL:8-2*X(e)}},stand(e){return{headTilt:.5*X(e*1.1),bob:.6*X(e*1.3)}},turn(e){return Qk.idle(e)},wave(e){return{armR:-150,elbowR:-30+18*X(e*9),headTilt:3,bob:1.2*X(e*1.5)}},point(e,t={}){return{armR:-132-Zk((t.aimDY||0)*18,-10,22),elbowR:-6,headTilt:Zk(-4+(t.aimDX||0)*6,-11,7),card:1,bob:X(e*1.3)}},look(e,t={}){return{headTilt:Zk((t.aimDX||0)*9,-11,11),bob:1.1*X(e*1.3)}},lookAround(e,t={}){return{headTilt:((t.aimDX||0)*8||0)+10*X(e*.9),bob:1.1*X(e*1.2),armR:-8+2*X(e)}},walk(e,t={}){let n=e*(t.speed||1.2)%1*2*Xk;return{legR:-28*X(n),legL:-28*X(n+Xk),kneeR:34*Yk(0,X(n+2)),kneeL:34*Yk(0,X(n+Xk+2)),armR:-8+22*X(n+Xk),armL:8+22*X(n),elbowR:-12,elbowL:12,bob:-2-4*(.5-.5*Jk(2*n))}},run(e,t={}){let n=e*(t.speed||1.2)*1.6%1*2*Xk;return{legR:-42*X(n),legL:-42*X(n+Xk),kneeR:46*Yk(0,X(n+2)),kneeL:46*Yk(0,X(n+Xk+2)),armR:-22+34*X(n+Xk),armL:22+34*X(n),elbowR:-42,elbowL:42,bob:-3-7*(.5-.5*Jk(2*n)),headTilt:-4}},sit(e){return{legR:-58,legL:-56,kneeR:76,kneeL:74,bob:40,armR:-14,armL:14,headTilt:1*X(e*1.1)}},fall(e){return{headTilt:34,armR:-58,armL:58,elbowR:20,elbowL:-20,legR:-42,legL:18,kneeR:20,bob:22}},handshake(e){return{armR:-72+5*X(e*7),elbowR:34,headTilt:4,bob:1}},handOverItem(e){return{armR:-84,elbowR:22,armL:12,headTilt:3,bob:X(e*1.4)}},argue(e){return{armR:-66+22*X(e*6),elbowR:-22,armL:12,headTilt:5*X(e*3.2),bob:1.5*X(e*2)}},shrug(e){return{armL:26,armR:-26,elbowL:-34,elbowR:34,headTilt:2*X(e*1.4),bob:1+1.4*(.5-.5*Jk(e*3))}},think(e){return{armR:-96,elbowR:-62,headTilt:8,armL:6,bob:.8*X(e*1.1)}},shocked(e){return{armR:-42,armL:42,elbowR:22,elbowL:-22,headTilt:-6,mOpen:15,mWidth:12,bob:-3+.6*X(e*8)}},celebrate(e){return{armL:150,armR:-150,elbowL:10,elbowR:-10,headTilt:2*X(e*4),bob:-6*Math.abs(X(e*4))}},cry(e){return{armR:-104,armL:104,elbowR:-58,elbowL:58,headTilt:12+2*X(e*5),mCurve:-8,bob:1.4*X(e*3)}},whisper(e){return{armR:-98,elbowR:-54,headTilt:6,mOpen:3+1.5*X(e*8),mWidth:12,bob:.6*X(e*1.5)}},talkGesture(e,t={}){return{armR:-14+10*X(e*4.6),elbowR:-16,armL:12+8*X(e*4.6+1),headTilt:1.6*X(e*2.2)+(t.aimDX||0)*4,bob:1.1*X(e*1.5)}},carryBox(e){return{armL:66,armR:-66,elbowL:-40,elbowR:40,headTilt:2,bob:1+.8*X(e*1.4)}},type(e){return{armR:-30,armL:30,elbowR:22,elbowL:-22,headTilt:7,bob:.5*X(e*6)}},drink(e){return{armR:-120,elbowR:-72,headTilt:-5,armL:8,bob:.6*X(e*1.3)}},sleep(e){return{headTilt:32,bob:1.4*X(e*.8),armR:-4,armL:4}},march(e,t={}){let n=e*(t.speed||1)%1*2*Xk;return{legR:-24*X(n),legL:-24*X(n+Xk),kneeR:40*Yk(0,X(n+2)),kneeL:40*Yk(0,X(n+Xk+2)),armR:-10+16*X(n+Xk),armL:10+16*X(n),elbowR:-24,elbowL:24,bob:-2-3*(.5-.5*Jk(2*n)),headTilt:0}},flee(e,t={}){return{...Qk.run(e,t),headTilt:-18+3*X(e*6),armR:-30+40*X(e*8),armL:30+40*X(e*8+Xk),mOpen:6}},salute(e){return{armR:-150,elbowR:-78,headTilt:-2,armL:6,bob:.5*X(e*1.2)}},aim(e,t={}){return{armR:-92-Zk((t.aimDY||0)*16,-12,16),elbowR:4,armL:6,headTilt:Zk((t.aimDX||0)*6,-8,8),bob:.5*X(e*1.3)}},duck(e){return{bob:30,kneeR:60,kneeL:60,legR:-18,legL:-18,headTilt:14,armR:-30,armL:30,elbowR:30,elbowL:-30}},cheer(e){return{armL:160,armR:-160,elbowL:8,elbowR:-8,headTilt:3*X(e*5),bob:-7*Math.abs(X(e*5)),mOpen:10,mWidth:14}},tablePoint(e,t={}){return{armR:-50-Zk((t.aimDY||0)*20,-14,18),elbowR:40,headTilt:Zk(10+(t.aimDX||0)*6,2,18),armL:8,bob:.6*X(e*1.2)}},standGuard(e){return{headTilt:.6*X(e*.8),bob:.5*X(e*1),armR:-4,armL:4,elbowR:8,elbowL:-8,legR:-6,legL:6}},sneak(e,t={}){let n=e*(t.speed||.7)%1*2*Xk;return{legR:-16*X(n),legL:-16*X(n+Xk),kneeR:44+10*Yk(0,X(n)),kneeL:44+10*Yk(0,X(n+Xk)),bob:22,headTilt:6,armR:-24,armL:24,elbowR:30,elbowL:-30}},jump(e){let t=e%1*2*Xk,n=Yk(0,X(t));return{bob:30-n*70,legR:-20+n*40,legL:-20+n*40,kneeR:40-n*30,kneeL:40-n*30,armR:-20-n*120,armL:20+n*120,headTilt:-2}},climb(e){let t=e*3;return{armR:-150+20*X(t),armL:-150+20*X(t+Xk),elbowR:-20,elbowL:-20,legR:-30+20*X(t+Xk),legL:-30+20*X(t),kneeR:40,kneeL:40,bob:-2+3*X(t*2),headTilt:-4}},nod(e){let t=X(e*4);return{headTilt:1.5*X(e*1.1),bob:1+3*Yk(0,t),armR:-8,armL:8}},headShake(e){return{headTilt:12*X(e*5),bob:.6*X(e*1.3),armR:-8,armL:8}},facepalm(e){return{armR:-128,elbowR:-96,headTilt:16,armL:6,bob:.6*X(e*1.1)}},thumbsUp(e){return{armR:-70,elbowR:44,headTilt:-3,armL:8,bob:.8*X(e*1.4)}},clap(e){let t=24*(.5+.5*X(e*9));return{armR:-40-t,armL:40+t,elbowR:40,elbowL:-40,headTilt:2*X(e*2),bob:1+.8*X(e*4.5)}},beckon(e,t={}){return{armR:-60+12*X(e*5),elbowR:30+20*X(e*5),headTilt:Zk(2+(t.aimDX||0)*5,-8,8),armL:8,bob:.8*X(e*1.4)}},presentPalm(e,t={}){return{armR:-58-Zk((t.aimDY||0)*14,-10,14),elbowR:24,headTilt:Zk((t.aimDX||0)*6,-8,8),armL:8,bob:.6*X(e*1.3)}},laugh(e){return{headTilt:-12+4*X(e*9),bob:2+3*Yk(0,X(e*7)),armR:-40,armL:40,elbowR:30,elbowL:-30,mOpen:12,mWidth:18,mCurve:8}},angryStomp(e){let t=e%1*2*Xk,n=Yk(0,X(t));return{legR:-10-n*20,kneeR:20+n*40,legL:4,bob:6-n*8,headTilt:-8,armR:-30+10*X(e*6),armL:30-10*X(e*6),elbowR:40,elbowL:-40,mOpen:6}},exhausted(e){return{headTilt:20,bob:8+3*X(e*1.4),armR:-18,armL:18,elbowR:8,elbowL:-8,legR:-4,legL:4,mOpen:3+2*X(e*1.4)}},proud(e){return{armR:-44,armL:44,elbowR:64,elbowL:-64,headTilt:-4,bob:.6*X(e*1.1),legR:-8,legL:8}},worry(e){let t=X(e*.8);return{headTilt:5*X(e*1.6),bob:1*X(e*1.4),armR:-70+4*X(e*3),armL:-70-4*X(e*3),elbowR:-40,elbowL:40,legR:-3*t,legL:3*t}},hug(e){return{armR:-74,armL:74,elbowR:64,elbowL:-64,headTilt:6,bob:1+.6*X(e*1.3),legR:-4,legL:4}},pushObject(e){let t=.5-.5*Jk(e*3);return{armR:-70,armL:70,elbowR:12,elbowL:-12,headTilt:9,bob:2+2*t,legR:-18-4*t,legL:10}},pull(e){let t=X(e*3.4);return{armR:-46-6*t,armL:46+6*t,elbowR:72,elbowL:-72,headTilt:-7,bob:2+2*t,legR:-16,legL:8}},liftOverhead(e){return{armR:-172,armL:172,elbowR:-8,elbowL:8,headTilt:-6,bob:2+1.4*X(e*1.6),legR:-6,legL:6}},throw(e){let t=e%1*2*Xk,n=Jk(t);return{armR:-70-90*n,elbowR:-30-30*Yk(0,-n),armL:20+14*n,headTilt:-4-4*n,bob:1+1.5*X(e*1.4),legR:-10-6*n,legL:8}},catch(e){let t=Yk(0,X(e*2.4));return{armR:-58+6*t,armL:58-6*t,elbowR:52,elbowL:-52,headTilt:-4,bob:-2+4*t}},examine(e,t={}){return{armR:-110,elbowR:-68,headTilt:10+3*X(e*1.6)+(t.aimDX||0)*4,armL:14,elbowL:-10,bob:.5*X(e*1.3)}},write(e){return{armR:-34+3*X(e*8),elbowR:26,armL:22,elbowL:-12,headTilt:13,bob:.4*X(e*5)}},eat(e){let t=Yk(0,X(e*3));return{armR:-96-26*t,elbowR:-60-10*t,headTilt:-3,armL:10,bob:.5*X(e*1.3),mOpen:3+6*t}},phoneTalk(e){return{armR:-142,elbowR:-98,headTilt:8,armL:8,bob:.5*X(e*1.3),mOpen:3+2*X(e*7),mWidth:10}},phoneScroll(e){return{armL:44,armR:-34+2*X(e*7),elbowL:-34,elbowR:42,headTilt:15,bob:.4*X(e*1.4)}},sweep(e){let t=X(e*2.2);return{armR:-66+22*t,armL:-38+22*t,elbowR:28,elbowL:22,headTilt:9,bob:1+.6*t,legR:-6,legL:6}},hammer(e){let t=e*2%1*2*Xk,n=Yk(0,X(t));return{armR:-56-84*n,elbowR:-38,headTilt:6-4*n,armL:10,bob:1+1.4*n,legR:-6,legL:6}},dig(e){let t=e*1.5%1*2*Xk,n=Yk(0,X(t));return{armR:-44-10*n,armL:30-10*n,elbowR:34,elbowL:-20,headTilt:12+8*n,bob:5+12*n,kneeR:24+16*n,kneeL:24+16*n,legR:-10,legL:6}},drive(e){return{bob:40,legR:-52,legL:-50,kneeR:72,kneeL:70,armR:-46,armL:46,elbowR:38,elbowL:-38,headTilt:2*X(e*1.1)}},read(e){return{armR:-66,armL:66,elbowR:46,elbowL:-46,headTilt:16,bob:.5*X(e*1.2)}},blockShield(e){return{armR:-28,armL:38,elbowR:52,elbowL:-74,headTilt:6,bob:6+.6*X(e*2),kneeR:26,kneeL:26,legR:-8,legL:8}},dodge(e){let t=X(e*3.2);return{headTilt:-16+6*t,bob:5,armR:-40+8*t,armL:40+8*t,elbowR:24,elbowL:-24,legR:-20,legL:12,kneeR:22}}},$k=Object.keys(Qk),eA=[`point`,`look`,`talk`,`talkGesture`,`lookAround`,`aim`,`tablePoint`,`presentPalm`,`beckon`]}));function nA(){return{limbWidenX:1,limbWidenLeg:1,torsoScale:1,cover:{}}}function rA(e={}){let t=nA();return[RA[e.outerwear],FA[e.top],BA[e.bottom],IA[e.sleeves]].filter(Boolean).forEach(e=>{let n=e.fit||{};t.limbWidenX=Math.max(t.limbWidenX,n.limbWidenX||1),t.limbWidenLeg=Math.max(t.limbWidenLeg,n.limbWidenLeg||1),t.torsoScale=Math.max(t.torsoScale,n.torsoScale||1)}),t}function iA(e,t,n=0){let r=104-e,i=134-n,a=226+n;return DA(`M${i} 100 Q${i-4} ${r} 180 ${r-6} Q${a+4} ${r} ${a} 100 L${a-6} ${t+100} Q180 ${t+108} ${i+6} ${t+100} Z`)}function aA(e={}){let t=e.h||34,n=e.b||-34,r=100-t*.5;return iA(t,n,e.wob||0)+DA(`M136 ${r} Q180 ${68-t*.3} 224 ${r} Q200 ${80-t*.3} 180 80 Q160 80 136 ${r} Z`,`hairSh`,` opacity=".3"`)}function oA(e={}){let t=e.up||20,n=52-t,r=46-t;return DA(`M130 104 Q126 ${n} 180 ${r} Q234 ${n} 230 104 Q222 ${80-t*.5} 200 76 Q188 66 174 70 Q152 74 140 86 Q133 94 130 104 Z`)+DA(`M130 104 Q126 ${54-t} 180 ${48-t} Q150 58 140 92 Q134 99 130 104 Z`,`hairSh`,` opacity=".28"`)}function sA(e={}){let t=e.s||1;return DA(`M132 104 Q130 54 180 50 Q230 54 228 104 Q220 82 196 78 Q${180-20*t} 64 ${160-6*t} 74 Q144 82 132 104 Z`)+DA(`M132 104 Q130 56 180 52 Q164 60 150 88 Q138 98 132 104 Z`,`hairSh`,` opacity=".26"`)}function cA(e={}){let t=e.len||210;return DA(`M126 108 Q124 50 180 46 Q236 50 234 108 L228 ${t} Q224 ${t+22} 210 ${t+26} L206 150 Q206 96 180 92 Q154 96 154 150 L150 ${t+26} Q136 ${t+22} 132 ${t} Z`)+DA(`M132 100 Q145 58 180 56 Q215 58 228 100 Q206 74 180 74 Q154 74 132 100 Z`,`hairSh`,` opacity=".3"`)}function lA(e={}){let t=e.r||27,n=e.rows||2,r=``,i=[137,163,195,222],a=[85,61,61,85];return i.forEach((e,n)=>r+=OA(e,a[n],t)),n>1&&[132,154,205,228].forEach((e,n)=>r+=OA(e,[115,126,126,115][n],t-2)),r}function uA(e={}){let t=e.n||10,n=iA(30,-30);for(let e=0;e<t;e++){let r=e/t*Math.PI,i=180+Math.cos(r)*48,a=80-Math.sin(r)*26;n+=OA(i,a,7)}return n}function dA(e={}){let t=e.n||7,n=DA(`M134 102 Q140 78 180 74 Q220 78 226 102 Q206 88 180 86 Q154 88 134 102 Z`);for(let e=0;e<t;e++){let r=138+e*(80/(t-1));n+=DA(`M${r} 86 L${r-5} ${52+e%2*8} L${r+5} 54 Z`)}return n}function fA(){return DA(`M168 108 Q168 46 180 44 Q192 46 192 108 Z`)+DA(`M170 100 Q170 52 180 50 Q178 70 178 100 Z`,`hairSh`,` opacity=".3"`)}function pA(e={}){return iA(28,-30)+OA(180,46,e.r||16)}function mA(e={}){let t=e.side||1,n=e.len||170;return iA(30,-28)+DA(`M${180+t*40} 70 Q${180+t*70} 90 ${180+t*62} ${n} Q${180+t*44} ${n+10} ${180+t*40} ${n} Q${180+t*50} 120 ${180+t*30} 78 Z`)}function hA(e={}){return e.fringe?DA(`M136 100 Q140 84 180 82 Q220 84 224 100 Q206 92 180 92 Q154 92 136 100 Z`):``}function gA(){return DA(`M138 104 Q140 74 165 72 Q150 82 146 104 Z M222 104 Q220 74 195 72 Q210 82 214 104 Z`)}function _A(e={}){let t=e.n||6,n=iA(20,-22);for(let e=0;e<t;e++){let r=142+e*(76/(t-1)),i=180+(r-180)*.3;n+=DA(`M${r-2.5} 100 Q${r-2.5} 62 ${i-2.5} 54 L${i+2.5} 54 Q${r+2.5} 62 ${r+2.5} 100 Z`)}return n}function vA(e,t=`#59352b`){return`<g class="wardrobeHairArt" style="color:${t}">${(kA[e]||kA.crop).fn({})}</g>`}function yA(e,t){if(!RA[e])return``;let n=yk(t,.8),r=yk(t,.72),i=[`jacket`,`blazer`,`cardigan`,`hoodieOpen`,`bomber`,`suitJacket`,`denimJacket`,`vestOuter`,`kimono`,`peacoat`].includes(e),a=`<path d="M124 192 Q108 210 116 258 Q120 310 136 346 Q180 360 224 346 Q240 310 244 258 Q252 210 236 192 Q208 172 180 170 Q152 172 124 192 Z" fill="${t}"/>`,o=i?`<path d="M180 172 L164 348 M180 172 L196 348" stroke="${r}" stroke-width="4" fill="none"/><path d="M180 172 L150 196 L164 348 M180 172 L210 196 L196 348" fill="${n}" opacity=".5"/>`:`<path d="M180 172 L180 348" stroke="${r}" stroke-width="2.5" fill="none"/>`,s=e===`hiVisVest`?`<rect x="150" y="238" width="60" height="14" fill="#fff" opacity=".75"/><rect x="150" y="262" width="60" height="14" fill="#fff" opacity=".75"/>`:e===`labCoat`?`<rect x="152" y="256" width="16" height="20" fill="#eef2f5"/>`:e===`apron`?`<path d="M158 200 L158 344 L202 344 L202 200 Q180 190 158 200 Z" fill="${n}"/>`:e===`cape`?`<path d="M126 190 Q112 300 130 360 L230 360 Q248 300 234 190 Q208 200 180 200 Q152 200 126 190 Z" fill="${n}" opacity=".9"/>`:``;return`<g data-role="wardrobeOuter">${e===`cape`?s:``}${a}${o}${e===`cape`?``:s}</g>`}function bA(e,t){let n=t,r=yk(n,.82),i=e===`skirtLong`||e===`dressBottom`||e===`palazzo`,a=i?470:400,o=i?26:14;return`<g data-role="wardrobeBottom"><path d="M150 330 Q180 322 210 330 L${210+o} ${a} Q180 ${a+14} ${150-o} ${a} Z" fill="${n}"/><path d="M150 330 Q180 322 210 330" fill="none" stroke="${r}" stroke-width="3"/></g>`}function xA(e,t=`#2a2f3a`){if(e===`barefoot`||!HA[e])return``;let n=n=>{let r=e===`heels`?`<rect x="${n+12}" y="568" width="5" height="18" fill="${t}"/>`:``;return`${e===`boots`||e===`winterBoots`?`<rect x="${n-16}" y="530" width="32" height="34" rx="6" fill="${t}"/>`:``}<path d="M${n-20} 566Q${n-22} 556 ${n-12} 554L${n+18} 554Q${n+26} 556 ${n+26} 566Q${n+26} 574 ${n+14} 574L${n-18} 574Q${n-22} 572 ${n-20} 566Z" fill="${t}"/>${r}`};return`<g data-role="wardrobeFeet">${n(160)}${n(200)}</g>`}function SA(e,t=`#2a2018`){if(e===`none`||!qA(e))return``;let n={stubble:`M145 131Q152 152 180 160Q208 152 215 131Q208 145 180 149Q152 145 145 131Z`,shortBeard:`M145 130Q150 160 180 170Q210 160 215 130Q208 152 180 156Q152 152 145 130Z`,fullBeard:`M143 126Q146 172 180 186Q214 172 217 126Q210 156 180 160Q150 156 143 126Z`,goatee:`M170 140Q180 168 190 140Q184 156 180 156Q176 156 170 140Z`,vanDyke:`M170 138Q180 164 190 138Q184 152 180 152ZM168 120Q180 126 192 120Q180 130 168 120Z`,mustache:`M164 122Q180 130 196 122Q188 118 180 120Q172 118 164 122Z`,handlebar:`M158 122Q180 132 202 122Q194 116 180 120Q166 116 158 122Q160 128 156 130Q162 126 158 122ZM202 122Q204 128 208 130Q202 126 202 122Z`,mutton:`M145 118Q142 150 158 164Q160 140 156 118ZM215 118Q218 150 202 164Q200 140 204 118Z`,soulPatch:`M176 138Q180 148 184 138Q180 144 176 138Z`,circleBeard:`M164 122Q180 130 196 122Q188 118 180 120Q172 118 164 122ZM170 138Q180 166 190 138Q184 154 180 154Q176 154 170 138Z`,chinStrap:`M146 118Q148 158 180 168Q212 158 214 118Q210 150 180 154Q150 150 146 118ZM160 130L200 130Q198 140 180 142Q162 140 160 130Z`,verstache:`M164 122Q180 130 196 122Q188 118 180 120Q172 118 164 122ZM176 138Q180 148 184 138Z`,longBeard:`M143 126Q146 190 180 210Q214 190 217 126Q210 156 180 160Q150 156 143 126Z`};return`<path data-role="wardrobeFacial" d="${n[e]||n.shortBeard}" fill="${t}"/>`}function CA(e){if(e===`none`||e===!1||!YA(e))return``;let t=`#26313a`,n=e===`square`?e=>`<rect x="${e-13}" y="99" width="26" height="22" rx="4" fill="none" stroke="${t}" stroke-width="3"/>`:e===`catEye`?e=>`<path d="M${e-13} 116 Q${e-14} 100 ${e} 100 Q${e+14} 100 ${e+13} 116 Q${e} 122 ${e-13} 116 Z" fill="none" stroke="${t}" stroke-width="3"/>`:e===`sunglasses`?e=>`<circle cx="${e}" cy="110" r="13" fill="#26313a"/>`:n=>`<circle cx="${n}" cy="110" r="13" fill="${e===`rimless`?`rgba(180,200,220,.25)`:`none`}" stroke="${e===`rimless`?`none`:t}" stroke-width="3"/>`;return`<g data-role="wardrobeGlasses">${n(164)}${n(196)}<rect x="177" y="108" width="6" height="3" rx="1.5" fill="${t}"/></g>`}function wA(e,t=`#37455a`){if(e===`none`||!ZA(e))return``;let n=yk(t,.8);return`<g data-role="wardrobeHat">${{cap:`<path d="M134 66 Q180 30 226 62 Q228 74 180 74 Q140 74 134 66 Z" fill="${t}"/><path d="M226 62 Q252 62 256 74 L226 76 Q224 68 226 62 Z" fill="${n}"/>`,beanie:`<path d="M132 72 Q132 34 180 32 Q228 34 228 72 Q180 82 132 72 Z" fill="${t}"/><rect x="130" y="66" width="100" height="12" rx="6" fill="${n}"/>`,fedora:`<ellipse cx="180" cy="72" rx="66" ry="12" fill="${n}"/><path d="M146 70 Q150 38 180 36 Q210 38 214 70 Z" fill="${t}"/><rect x="146" y="60" width="68" height="8" fill="${n}"/>`,topHat:`<ellipse cx="180" cy="66" rx="58" ry="10" fill="${n}"/><rect x="150" y="8" width="60" height="60" rx="4" fill="${t}"/><rect x="150" y="52" width="60" height="8" fill="${n}"/>`,hardHat:`<path d="M138 66 Q180 30 222 66 Q180 76 138 66 Z" fill="${t}"/><rect x="132" y="64" width="96" height="8" rx="4" fill="${t}"/><rect x="176" y="34" width="8" height="30" fill="${n}"/>`,crown:`<path d="M142 66 L146 40 L160 56 L180 34 L200 56 L214 40 L218 66 Z" fill="#f2b134"/><circle cx="180" cy="40" r="4" fill="#fff"/>`,helmet:`<path d="M130 76 Q130 32 180 30 Q230 32 230 76 Q180 86 130 76 Z" fill="${t}"/><rect x="176" y="30" width="8" height="46" fill="${n}"/>`,headband:`<rect x="132" y="60" width="96" height="12" rx="6" fill="${t}"/>`,cowboyHat:`<path d="M118 72 Q180 60 242 72 Q180 88 118 72 Z" fill="${t}"/><path d="M150 68 Q154 38 180 36 Q206 38 210 68 Z" fill="${t}"/><rect x="150" y="60" width="60" height="7" fill="${n}"/>`,wizardHat:`<path d="M180 4 L214 70 L146 70 Z" fill="${t}"/><ellipse cx="180" cy="70" rx="44" ry="8" fill="${n}"/><circle cx="180" cy="26" r="4" fill="#ffd54a"/>`,beret:`<ellipse cx="180" cy="52" rx="42" ry="22" fill="${t}"/><circle cx="200" cy="40" r="4" fill="${n}"/>`,visor:`<rect x="134" y="62" width="92" height="10" rx="5" fill="${t}"/><path d="M226 66 Q250 66 254 76 L226 78 Z" fill="${n}"/>`,bandana:`<path d="M132 66 Q180 52 228 66 Q228 74 180 78 Q140 74 132 66 Z" fill="${t}"/><path d="M226 68 L246 84 L232 86 L222 72 Z" fill="${n}"/>`,partyHat:`<path d="M180 8 L200 66 L160 66 Z" fill="${t}"/><circle cx="180" cy="12" r="5" fill="#ff6b5e"/>`,santaHat:`<path d="M134 68 Q140 30 202 34 Q214 40 210 66 Z" fill="#c0392b"/><rect x="126" y="64" width="92" height="12" rx="6" fill="#fff"/><circle cx="210" cy="38" r="8" fill="#fff"/>`}[e]||``}</g>`}function TA(e={}){let t=``;return e.freckles&&(t+=`<g fill="#b5794f" opacity=".5">${[[152,116],[158,120],[148,122],[202,116],[208,120],[212,122]].map(([e,t])=>`<circle cx="${e}" cy="${t}" r="1.6"/>`).join(``)}</g>`),e.blush&&(t+=`<ellipse cx="150" cy="120" rx="10" ry="6" fill="#ff8a8a" opacity=".3"/><ellipse cx="210" cy="120" rx="10" ry="6" fill="#ff8a8a" opacity=".3"/>`),e.earrings&&(t+=`<circle cx="134" cy="122" r="3" fill="#f2b134"/><circle cx="226" cy="122" r="3" fill="#f2b134"/>`),e.wrinkles&&(t+=`<g stroke="#c9a882" stroke-width="1.2" fill="none" opacity=".5"><path d="M150 90 Q164 88 176 90"/><path d="M186 90 Q198 88 210 90"/><path d="M156 128 Q164 132 172 128"/><path d="M188 128 Q196 132 204 128"/></g>`),t?`<g data-role="wardrobeFaceExtras">${t}</g>`:``}var EA,DA,OA,kA,AA,jA,MA,NA,PA,FA,IA,LA,RA,zA,BA,VA,HA,UA,WA,GA,KA,qA,JA,YA,XA,ZA,QA,$A,ej,tj,nj,rj,ij,aj=o((()=>{Tk(),EA={armU:20,armL:17,legU:26,legL:22},DA=(e,t=`hair`,n=``)=>`<path class="${t}" d="${e}"${n}/>`,OA=(e,t,n,r=`hair`)=>`<circle class="${r}" cx="${e}" cy="${t}" r="${n}"/>`,kA={},AA=(e,t,n)=>t.forEach((t,r)=>{kA[t]={cat:e,fn:n(r)}}),AA(`short`,[`crop`,`buzz`,`caesar`,`ivyLeague`,`crewCut`,`taper`,`flatTop`,`hightop`,`shortAfro`,`pixie`,`frenchCrop`,`butch`,`burr`,`induction`,`shortBrush`,`lowFade`,`midFade`,`highFade`,`blowout`,`edgar`],e=>e===8?e=>lA({r:20,rows:1}):e===6||e===7?e=>oA({up:8}):t=>aA({h:28+e%5*2,wob:e%3-1})),AA(`medium`,[`quiff`,`pompadour`,`sidePart`,`comboOver`,`sweptBack`,`curtains`,`waves`,`shag`,`bob`,`lob`,`fauxHawkMed`,`texturedCrop`,`messyMed`,`flowMed`,`middlePart`,`slickBack`,`wolfCut`,`mullet`,`featheredMed`,`layeredMed`],e=>e<=1?t=>oA({up:18+e*6}):e===8||e===9?e=>cA({len:160}):e<=4?t=>sA({s:e%2?1:-1}):e=>aA({h:38,b:6,wob:2})),AA(`long`,[`straightLong`,`ponytail`,`highPonytail`,`braid`,`doubleBraid`,`bun`,`topKnot`,`spaceBuns`,`longAfro`,`dreads`,`longLayers`,`sidePonytail`,`lowBun`,`halfUp`,`mermaid`,`hime`,`longWavy`,`longStraight`,`longCurly`,`longShag`],e=>e===1||e===2||e===11?t=>mA({len:175,side:e===11?1:.1}):e===5||e===6||e===12?e=>pA({}):e===8?e=>lA({r:27,rows:2}):t=>cA({len:200+e%3*10})),AA(`textured`,[`curly`,`tightCurls`,`afro`,`afroTaper`,`coils`,`ringlets`,`wavyLong`,`kinky`,`twistOut`,`curlyFade`,`curlyBob`,`curlyShag`,`looseCurls`,`spiralCurls`,`bantuKnots`],e=>e===2||e===3?e=>lA({r:27,rows:2}):e===4||e===8?e=>uA({n:10}):e=>lA({r:22,rows:1})),AA(`styled`,[`mohawk`,`fauxHawk`,`undercut`,`manBun`,`cornrows`,`locs`,`spiky`,`emoFringe`,`bunched`,`hatHairShort`,`liberty`,`devilock`,`quiffPunk`,`razorPart`,`flattopHi`],e=>e===0||e===10||e===11||e===12?e=>fA():e===3?e=>pA({r:14}):e===4?e=>_A({n:6}):e===6||e===13||e===14?e=>dA({n:7}):e=>aA({h:30})),AA(`aged`,[`greySwept`,`greyBun`,`balding`,`saltPepper`,`wispy`,`recedingGrey`,`baldFringe`,`thinTop`,`combover`,`silverLong`],e=>e===1?e=>pA({}):e===2||e===7?e=>gA():e===6?e=>hA({fringe:!0}):e===9?e=>cA({len:180}):e=>sA({s:1})),kA.bald={cat:`aged`,fn:e=>hA({})},kA.widowsPeak={cat:`styled`,fn:e=>DA(`M136 104Q138 70 165 68L180 84L195 68Q222 70 224 104Q206 84 180 82Q154 84 136 104Z`)},kA.receding={cat:`aged`,fn:e=>gA()},jA=Object.keys(kA),MA=e=>Object.prototype.hasOwnProperty.call(kA,e),NA={tee:``,tank:e=>`<path d="M156 196L156 250M204 196L204 250" stroke="${yk(e,.8)}" stroke-width="3" fill="none" opacity=".5"/>`,poloShirt:e=>`<path d="M168 176L180 190L192 176" fill="none" stroke="${yk(e,.78)}" stroke-width="4"/><circle cx="180" cy="210" r="2.4" fill="${yk(e,.7)}"/><circle cx="180" cy="226" r="2.4" fill="${yk(e,.7)}"/>`,buttonUp:e=>`<path d="M180 176L180 340" stroke="${yk(e,.72)}" stroke-width="2.5"/>${[196,220,252,284,316].map(t=>`<circle cx="180" cy="${t}" r="2.2" fill="${yk(e,.6)}"/>`).join(``)}`,hoodie:e=>`<path d="M150 182Q180 168 210 182Q206 200 180 206Q154 200 150 182Z" fill="${yk(e,.82)}"/><path d="M172 206L172 250M188 206L188 250" stroke="${yk(e,.7)}" stroke-width="3"/><rect x="150" y="300" width="60" height="26" rx="8" fill="${yk(e,.86)}"/>`,jersey:e=>`<text x="180" y="270" text-anchor="middle" font-size="34" font-weight="900" fill="${yk(e,.6)}">${`0`+(1+e.length%9)}</text>`,turtleneck:e=>`<rect x="164" y="158" width="32" height="22" rx="8" fill="${e}"/>`,vest:e=>`<path d="M150 196L150 330M210 196L210 330" stroke="${yk(e,.7)}" stroke-width="4" fill="none"/>`,henley:e=>`<path d="M180 178L180 220" stroke="${yk(e,.72)}" stroke-width="2.5"/><circle cx="180" cy="196" r="2" fill="${yk(e,.6)}"/><circle cx="180" cy="212" r="2" fill="${yk(e,.6)}"/>`},PA=[`tee`,`tank`,`poloShirt`,`buttonUp`,`blouse`,`sweater`,`turtleneck`,`hoodie`,`jersey`,`croptop`,`vest`,`dressTop`,`tunic`,`henley`,`flannel`,`stripedTee`,`graphicTee`,`longSleeveTee`,`raglan`,`workShirt`,`scrubTop`,`thermal`,`poncho`,`halterTop`,`wrapTop`],FA={},PA.forEach(e=>{let t=[`sweater`,`turtleneck`,`hoodie`,`longSleeveTee`,`workShirt`,`thermal`,`flannel`,`blouse`,`scrubTop`].includes(e);FA[e]={id:e,slot:`top`,kind:`paint`,covers:[`arm`],longSleeve:t,capRx:10,detail:NA[e]||``,fit:{limbWidenX:t?1.12:1}}}),IA={short:{id:`short`,slot:`sleeves`,kind:`paint`,covers:[`arm`],longSleeve:!1,capRx:10},long:{id:`long`,slot:`sleeves`,kind:`paint`,covers:[`arm`],longSleeve:!0,capRx:8.5,fit:{limbWidenX:1.1}},rolled:{id:`rolled`,slot:`sleeves`,kind:`paint`,covers:[`arm`],longSleeve:!1,capRx:10},threeQuarter:{id:`threeQuarter`,slot:`sleeves`,kind:`paint`,covers:[`arm`],longSleeve:!0,capRx:8.5,fit:{limbWidenX:1.06}},sleeveless:{id:`sleeveless`,slot:`sleeves`,kind:`paint`,covers:[],capRx:10}},LA=[`jacket`,`blazer`,`coat`,`trenchcoat`,`hoodieOpen`,`cardigan`,`puffer`,`bomber`,`apron`,`labCoat`,`hiVisVest`,`robe`,`cape`,`suitJacket`,`denimJacket`,`raincoat`,`parka`,`peacoat`,`windbreaker`,`fleece`,`vestOuter`,`poncho2`,`kimono`,`overalls`,`wetsuitTop`],RA={},LA.forEach(e=>{let t=[`coat`,`trenchcoat`,`puffer`,`parka`,`peacoat`,`robe`,`labCoat`,`raincoat`,`fleece`].includes(e),n=e===`puffer`||e===`parka`?1.5:t?1.34:1.18;RA[e]={id:e,slot:`outerwear`,kind:`overlay`,covers:[`arm`],longSleeve:!0,capRx:12,fit:{limbWidenX:n,torsoScale:t?1.08:1.03,cover:{armU:EA.armU*n+2,armL:EA.armL*n+2}}}}),zA=[`shorts`,`jeans`,`trousers`,`slacks`,`joggers`,`cargos`,`skirtShort`,`skirtLong`,`leggings`,`dressBottom`,`kilt`,`shortsAthletic`,`snowPants`,`chinos`,`sweatpants`,`capris`,`overallsBottom`,`palazzo`,`culottes`,`bikeShorts`],BA={},zA.forEach(e=>{let t=![`shorts`,`skirtShort`,`shortsAthletic`,`bikeShorts`,`capris`].includes(e),n=e===`snowPants`;BA[e]={id:e,slot:`bottom`,kind:`paint`,covers:[`leg`],longLeg:t,capRx:11,skirt:e.startsWith(`skirt`)||e===`kilt`||e===`dressBottom`||e===`palazzo`,fit:{limbWidenLeg:n?1.4:t?1.06:1}}}),VA=[`sneakers`,`dressShoes`,`boots`,`heels`,`sandals`,`cleats`,`winterBoots`,`barefoot`,`loafers`,`hightops`],HA={},VA.forEach(e=>HA[e]={id:e,slot:`footwear`,kind:`overlay`}),UA=[`oval`,`round`,`square`,`heart`,`long`,`diamond`,`wide`,`narrow`,`soft`,`angular`,`chubby`,`gaunt`],WA={oval:[1,1],round:[1.06,.96],square:[1.04,1],heart:[1.03,1],long:[.94,1.08],diamond:[.98,1.04],wide:[1.12,.96],narrow:[.9,1.02],soft:[1.05,1],angular:[.98,1.02],chubby:[1.1,.98],gaunt:[.9,1.05]},GA=e=>UA.includes(e),KA=[`none`,`stubble`,`shortBeard`,`fullBeard`,`goatee`,`vanDyke`,`mustache`,`handlebar`,`mutton`,`soulPatch`,`circleBeard`,`chinStrap`,`verstache`,`longBeard`],qA=e=>KA.includes(e),JA=[`none`,`round`,`square`,`rimless`,`sunglasses`,`catEye`,`aviator`],YA=e=>JA.includes(e),XA=[`none`,`cap`,`beanie`,`fedora`,`topHat`,`hardHat`,`crown`,`helmet`,`headband`,`cowboyHat`,`wizardHat`,`beret`,`visor`,`bandana`,`partyHat`,`santaHat`],ZA=e=>XA.includes(e),QA=[`round`,`almond`,`narrow`,`wide`],$A={round:[6.5,9],almond:[7,6],narrow:[7,4.5],wide:[8,9.5]},ej=[`flat`,`arched`,`angled`],tj={flat:0,arched:-4,angled:3},nj={casual:{top:`tee`,sleeves:`short`,bottom:`jeans`,footwear:`sneakers`,outerwear:`none`},business:{top:`buttonUp`,sleeves:`long`,outerwear:`blazer`,bottom:`slacks`,footwear:`dressShoes`},uniformMilitary:{top:`workShirt`,sleeves:`long`,outerwear:`jacket`,bottom:`cargos`,footwear:`boots`},uniformPolice:{top:`buttonUp`,sleeves:`long`,outerwear:`vestOuter`,bottom:`trousers`,footwear:`boots`},doctor:{top:`scrubTop`,sleeves:`short`,outerwear:`labCoat`,bottom:`trousers`,footwear:`sneakers`},worker:{top:`workShirt`,sleeves:`long`,outerwear:`hiVisVest`,bottom:`cargos`,footwear:`boots`},chef:{top:`buttonUp`,sleeves:`long`,outerwear:`apron`,bottom:`trousers`,footwear:`sneakers`},athlete:{top:`jersey`,sleeves:`sleeveless`,bottom:`shortsAthletic`,footwear:`cleats`,outerwear:`none`},royal:{top:`dressTop`,sleeves:`long`,outerwear:`cape`,bottom:`dressBottom`,footwear:`dressShoes`},winter:{top:`sweater`,sleeves:`long`,outerwear:`puffer`,bottom:`snowPants`,footwear:`winterBoots`},ancient:{top:`tunic`,sleeves:`long`,outerwear:`robe`,bottom:`trousers`,footwear:`sandals`},spacesuit:{top:`thermal`,sleeves:`long`,outerwear:`parka`,bottom:`snowPants`,footwear:`boots`}},rj=Object.keys(nj),ij={hair:jA,top:Object.keys(FA),sleeves:Object.keys(IA),outerwear:[`none`,...LA],bottom:Object.keys(BA),footwear:VA,faceShape:UA,facialHair:KA,glasses:JA}}));function oj(e,t){return typeof e==`string`&&e[0]===`@`?(vj[t]||vj.auto)[e.slice(1)]||vj.auto[e.slice(1)]||`#888888`:e}function sj(e,t){let n={...e};return[`skin`,`hairColor`,`shirt`,`shorts`,`legs`].forEach(e=>{n[e]!=null&&(n[e]=oj(n[e],t))}),n}function cj(e={}){return{...yj,...e}}function lj(e,t,n){e.querySelectorAll(`.`+t).forEach(e=>e.setAttribute(`fill`,n))}function uj(e,t){let n=cj(t),r=n.shorts||n.shirt,i=n.legs||n.shirt;e.querySelectorAll(`.hairStyle`).forEach(e=>e.setAttribute(`opacity`,e.dataset.style===n.hairStyle?`1`:`0`)),lj(e,`hair`,n.hairColor),lj(e,`hairSh`,yk(n.hairColor,.78)),lj(e,`shirt`,n.shirt),lj(e,`shirtSh`,yk(n.shirt,.78)),lj(e,`shorts`,r),lj(e,`shortsSh`,yk(r,.78)),lj(e,`leg`,i),lj(e,`legSh`,yk(i,.78)),lj(e,`skin`,n.skin),lj(e,`skinSh`,yk(n.skin,.88));let a=e.querySelector(`[data-role="glasses"]`);a&&a.setAttribute(`opacity`,n.glasses?`1`:`0`);let o=e.querySelector(`[data-role="beard"]`);o&&(o.setAttribute(`opacity`,n.beard?`1`:`0`),n.beard&&o.setAttribute(`fill`,yk(n.hairColor,.85)));let s=e.querySelector(`[data-role="collar"]`);if(s&&s.setAttribute(`opacity`,n.collar||n.build===`dave`?`1`:`0`),e.querySelector(`[data-role="hairProfShort"]`)){let t=[`bob`,`long`,`ponytail`,`curly`,`afro`].includes(n.hairStyle),r=e.querySelector(`[data-role="hairProfLong"]`);r&&r.setAttribute(`opacity`,t?`1`:`0`);let i=e.querySelector(`[data-role="hairPony"]`);i&&i.setAttribute(`opacity`,n.hairStyle===`ponytail`?`1`:`0`)}n.appearance&&mj(e,n)}function dj(e,t,n){let r=e.querySelector(`[data-role="${t}"]`);return r||(r=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),r.setAttribute(`data-role`,t),(e.querySelector(n)||e).appendChild(r)),r}function fj(e,t,n=`char`,r=`head`){let i=e.querySelector(`[data-role="${t}"]`);if(!i){i=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),i.setAttribute(`data-role`,t);let a=e.querySelector(`[data-role="${n}"]`),o=e.querySelector(`[data-role="${r}"]`);a&&o?a.insertBefore(i,o):a&&a.appendChild(i)}return i}function pj(e,t,n){[`armL`,`armR`].forEach(n=>{let r=e.querySelector(`[data-role="${n}"] > rect`);r&&r.setAttribute(`fill`,t)}),n&&[`armLf`,`armRf`].forEach(n=>{let r=e.querySelector(`[data-role="${n}"] > rect`);r&&r.setAttribute(`fill`,t)})}function mj(e,t){let n=t.appearance,r=t.hairColor;if(n.hair&&MA(n.hair)&&(e.querySelectorAll(`.hairStyle`).forEach(e=>e.setAttribute(`opacity`,`0`)),e.querySelector(`[data-role="hairRoot"]`))){let t=dj(e,`wardrobeHair`,`[data-role="hairRoot"]`);t.innerHTML=vA(n.hair,r),lj(t,`hair`,r),lj(t,`hairSh`,yk(r,.78))}if(n.faceShape&&GA(n.faceShape)){let[t,r]=WA[n.faceShape],i=e.querySelector(`[data-role="face"]`);i&&i.setAttribute(`transform`,`translate(180 104) scale(${t} ${r}) translate(-180 -104)`)}if(n.top&&FA[n.top]){let r=n.topColor||t.shirt;lj(e,`shirt`,r),lj(e,`shirtSh`,yk(r,.78));let i=FA[n.top].detail,a=dj(e,`wardrobeTop`,`[data-role="torsoWrap"]`);a.innerHTML=typeof i==`function`?i(r):i||``}if(n.sleeves&&IA[n.sleeves]&&IA[n.sleeves].longSleeve&&pj(e,n.topColor||t.shirt,!0),n.outerwear&&n.outerwear!==`none`&&RA[n.outerwear]){let r=n.outerColor||yk(t.shirt,.7);pj(e,r,!0);let i=fj(e,`wardrobeOuterRoot`);i.innerHTML=yA(n.outerwear,r)}else{let t=e.querySelector(`[data-role="wardrobeOuterRoot"]`);t&&(t.innerHTML=``)}if(n.bottom&&BA[n.bottom]){let r=n.bottomColor||t.shorts||t.shirt;lj(e,`shorts`,r),lj(e,`shortsSh`,yk(r,.78)),BA[n.bottom].longLeg&&(lj(e,`leg`,r),lj(e,`legSh`,yk(r,.78)));let i=fj(e,`wardrobeBottomRoot`);i.innerHTML=BA[n.bottom].skirt?bA(n.bottom,r):``}{let t=dj(e,`wardrobeFeetRoot`,`[data-role="char"]`);t.innerHTML=n.footwear?xA(n.footwear,n.footColor||`#2a2f3a`):``}if(n.facialHair&&qA(n.facialHair)){let t=e.querySelector(`[data-role="beard"]`);t&&t.setAttribute(`opacity`,(n.facialHair,`0`));let i=fj(e,`wardrobeFacialRoot`,`faceFeatures`,`mouth`);i.innerHTML=SA(n.facialHair,yk(r,.85))}if(n.glasses&&YA(n.glasses)){let t=e.querySelector(`[data-role="glasses"]`);t&&t.setAttribute(`opacity`,`0`);let r=dj(e,`wardrobeGlassesRoot`,`[data-role="faceFeatures"]`);r.innerHTML=CA(n.glasses)}{let t=dj(e,`wardrobeHatRoot`,`[data-role="head"]`);t.innerHTML=n.headwear&&ZA(n.headwear)?wA(n.headwear,n.headwearColor||`#37455a`):``}{let t=fj(e,`wardrobeExtrasRoot`,`faceFeatures`,`mouth`);t.innerHTML=TA(n)}if(n.eyeShape||n.irisColor||n.eyeSpacing!=null||n.lashes){let[t,r]=$A[n.eyeShape]||$A.round,i=(n.eyeSpacing||0)*6;[[`eyeL`,164-i],[`eyeR`,196+i]].forEach(([i,a])=>{let o=e.querySelector(`[data-role="${i}"]`);o&&(o.setAttribute(`rx`,t),o.setAttribute(`ry`,r),o.setAttribute(`cx`,a),n.irisColor&&o.setAttribute(`fill`,n.irisColor))});let a=dj(e,`wardrobeLashRoot`,`[data-role="faceFeatures"]`);a.innerHTML=n.lashes?`<path d="M${158-i} ${104-r} Q${164-i} ${101-r} ${170-i} ${104-r}" stroke="#243038" stroke-width="1.4" fill="none"/><path d="M${190+i} ${104-r} Q${196+i} ${101-r} ${202+i} ${104-r}" stroke="#243038" stroke-width="1.4" fill="none"/>`:``}if(n.browShape||n.browThickness||n.browColor){let t=tj[n.browShape]||0;[[`browL`,153,174],[`browR`,186,207]].forEach(([r,i,a])=>{let o=e.querySelector(`[data-role="${r}"]`);o&&(n.browThickness&&o.setAttribute(`stroke-width`,n.browThickness),n.browColor&&o.setAttribute(`stroke`,n.browColor),o.setAttribute(`d`,`M${i} 94 Q${(i+a)/2} ${89+t} ${a} 94`))})}}function hj(e,t,n={}){let r=cj(e),i=_j[r.ageHint]||_j.adult,a=gj.includes(r.ageHint)?Fk[r.ageHint]:null,o=a||Fk[r.build]||Fk.default,s=rA(r.appearance||{}),c={...o,armX:o.armX*s.limbWidenX,legX:o.legX*s.limbWidenLeg,torsoX:o.torsoX*s.torsoScale},l=a?1:i.headScale,u=a?o.scale||1:i.heightScale;return{profile:Pk[r.body]||Pk.regular,build:c,hairVol:r.hairVol,eyeMul:r.eye,browTilt:n.browTilt||0,headScale:l,heightScale:(r.heightScale||1)*u*(n.depthScale||1),limbScale:n.limbScale||1,rigX:t,facing:n.facing||`front`,squash:n.squash==null?1:n.squash,yShift:n.yShift||0,opacity:n.opacity==null?1:n.opacity}}var gj,_j,vj,yj,bj=o((()=>{Tk(),Uk(),aj(),gj=[`childYoung`,`child`,`teen`],_j={child:{heightScale:.72,headScale:1.14},adult:{heightScale:1,headScale:1},elder:{heightScale:.95,headScale:1.02}},Object.keys(_j),vj={auto:{primary:`#2BB3A3`,accent:`#FF6B5E`,warm:`#F2B134`,cool:`#5B6CE0`,ink:`#2E3440`,pale:`#F2C9A0`},sunset:{primary:`#E07A5F`,accent:`#F2CC8F`,warm:`#F4A261`,cool:`#81B29A`,ink:`#3D405B`,pale:`#F4EBDD`},ocean:{primary:`#2b6cb0`,accent:`#38b2ac`,warm:`#ecc94b`,cool:`#4299e1`,ink:`#1a365d`,pale:`#bee3f8`}},yj={skin:`#F2C9A0`,hairStyle:`bob`,hairColor:`#59352B`,hairVol:1,shirt:`#2BB3A3`,shorts:null,legs:null,body:`regular`,build:`default`,eye:1,glasses:!1,beard:!1,collar:!1,heightScale:1}}));function xj(e,t,n=wj){let r=Tj[e]||Tj.central;return{x:r.x*t,y:r.y*n,tint:r.tint}}function Sj(e=7){return[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#123a52`),r.addColorStop(1,`#0c2536`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3)}},{d:0,draw:(e,t,n)=>{e.strokeStyle=`rgba(255,255,255,.05)`,e.lineWidth=1;for(let r=0;r<=t;r+=t/12)e.beginPath(),e.moveTo(r,0),e.lineTo(r,n),e.stroke();for(let r=0;r<=n;r+=n/8)e.beginPath(),e.moveTo(0,r),e.lineTo(t,r),e.stroke()}},{d:0,draw:(t,n,r)=>{let i=vk(`map`+e);Ej.forEach(e=>{let a=Tj[e],o=a.x*n,s=a.y*r,c=a.r*n;t.save(),t.fillStyle=a.tint,t.globalAlpha=.94,t.beginPath();for(let e=0;e<=Math.PI*2+.01;e+=Math.PI/7){let n=c*(.8+i()*.4),r=o+Math.cos(e)*n,a=s+Math.sin(e)*n*.82;e===0?t.moveTo(r,a):t.lineTo(r,a)}t.closePath(),t.fill(),t.strokeStyle=`rgba(0,0,0,.12)`,t.lineWidth=2,t.stroke(),t.restore()})}}]}function Cj(e=7){return[{d:.1,draw:(e,t,n)=>{e.fillStyle=`#1b2230`,e.fillRect(-500,-500,t+1e3,n+1e3)}},{d:.18,draw:(e,t,n)=>{let r=e.createRadialGradient(t/2,n*.28,20,t/2,n*.28,n*.85);r.addColorStop(0,`rgba(150,180,220,.20)`),r.addColorStop(1,`rgba(150,180,220,0)`),e.fillStyle=r,e.fillRect(0,0,t,n)}},{d:.4,draw:(t,n,r,i,a)=>{t.save(),t.fillStyle=`#2a3446`,t.beginPath(),t.moveTo(n*.26,i-30*a),t.lineTo(n*.74,i-30*a),t.lineTo(n*.92,i+130*a),t.lineTo(n*.08,i+130*a),t.closePath(),t.fill(),t.fillStyle=`#39496a`,t.beginPath(),t.moveTo(n*.3,i-22*a),t.lineTo(n*.7,i-22*a),t.lineTo(n*.84,i+96*a),t.lineTo(n*.16,i+96*a),t.closePath(),t.fill();let o=vk(`wr`+e);t.fillStyle=`#c9a36a`;for(let e=0;e<5;e++)t.beginPath(),t.arc(n*(.36+o()*.28),i+(6+o()*56)*a,6*a,0,7),t.fill();t.strokeStyle=`rgba(230,200,140,.5)`,t.lineWidth=2*a,t.beginPath(),t.moveTo(n*.4,i+20*a),t.lineTo(n*.6,i+60*a),t.stroke(),t.restore()}}]}var wj,Tj,Ej,Dj=o((()=>{Tk(),wj=640,Tj={north:{x:.3,y:.3,r:.14,tint:`#8fae7a`},south:{x:.42,y:.68,r:.12,tint:`#c9a36a`},east:{x:.68,y:.4,r:.15,tint:`#7a9bb5`},west:{x:.15,y:.52,r:.11,tint:`#b58a7a`},central:{x:.5,y:.47,r:.11,tint:`#a7b98c`},isles:{x:.82,y:.66,r:.07,tint:`#8aa6b5`}},Ej=Object.keys(Tj)}));function Oj(e){let t=e===`grid`?4:e===`hero`||e===`islands`?3:e===`pin`||e===`steps`||e===`orbit`?5:3,n=[{key:`bg`,default:!0},{key:`accent`,default:!0}];for(let e=0;e<t;e++)n.push({key:`panel`+e,default:!0});n.push({key:`fgBlob`,default:!0}),e===`pin`&&n.push({key:`strings`,default:!0},{key:`boardTexture`,default:!0}),e===`steps`&&n.push({key:`path`,default:!0}),e===`orbit`&&n.push({key:`orbitLines`,default:!0}),n.push({key:`focusRing`,default:!1},{key:`hud`,default:!1});let r=e===`steps`?[4200,1600]:e===`grid`?[2600,1900]:e===`orbit`?[2600,2e3]:e===`islands`?[3200,1900]:e===`hero`?[3e3,1700]:[800+t*760,1500];return{world:r,view:[1920,1080],kind:e,manifest:n,build(n,i){let[a,o]=r,s=vk(`board`+e+n),c=kj(e,t,a,o,s),l=[],u=[],d=[],f=`pmbg_`+e,p=`<defs><linearGradient id="${f}" x1="0" x2="1" y1="0" y2="1"><stop offset="0" stop-color="${Hj[e][0]}"/><stop offset="1" stop-color="${Hj[e][1]}"/></linearGradient></defs>`;i(`bg`)?l.push(p+`<rect x="${-a}" y="${-o}" width="${3*a}" height="${3*o}" fill="url(#${f})"/>`):l.push(p),i(`accent`)&&l.push(`<circle cx="${(a*.2).toFixed(0)}" cy="${(o*.26).toFixed(0)}" r="${(o*.22).toFixed(0)}" fill="${Hj[e][2]}" opacity=".5"/><circle cx="${(a*.82).toFixed(0)}" cy="${(o*.3).toFixed(0)}" r="${(o*.28).toFixed(0)}" fill="${Hj[e][3]}" opacity=".45"/>`),e===`pin`&&i(`boardTexture`)&&l.push(Nj(a,o)),e===`steps`&&i(`path`)&&u.push(Aj(c)),e===`orbit`&&i(`orbitLines`)&&u.push(jj(c)),e===`pin`&&i(`strings`)&&u.push(Mj(c));let m=[],h=[];return c.forEach((t,n)=>{if(!i(`panel`+n))return;let r=t.depth===.24?l:t.depth===1.28?d:u,a=e===`pin`?s()*6-3:0,o=Bj(0,0,t.w,t.h)+zj(0,0,t.w,t.h,t.fill||`#fff`,t.op||.95)+(e===`pin`?`<circle cx="0" cy="${(-t.h/2+26).toFixed(0)}" r="12" fill="#c0392b"/>`:``);r.push(`<g transform="translate(${t.x.toFixed(0)} ${t.y.toFixed(0)}) rotate(${a.toFixed(1)})">${o}</g>`),m.push({id:`panel`+n,x:t.x,y:t.y,w:t.w,h:t.h,depth:t.depth}),h.push({id:`panel`+n,x:t.x,y:t.y,importance:t.importance||1})}),i(`fgBlob`)&&d.push(`<circle cx="${(a*.1).toFixed(0)}" cy="${(o*.88).toFixed(0)}" r="${(o*.12).toFixed(0)}" fill="#25155b" opacity=".3"/><circle cx="${(a*.94).toFixed(0)}" cy="${(o*.84).toFixed(0)}" r="${(o*.15).toFixed(0)}" fill="#25155b" opacity=".26"/>`),{planes:[{depth:.24,id:`bg`,svg:l.join(``)},{depth:1,id:`mid`,svg:u.join(``)},{depth:1.28,id:`fg`,svg:d.join(``)}],panels:m,subjects:h}}}}function kj(e,t,n,r,i){let a=n/2,o=r/2,s=[];if(e===`row`){let e=n/(t+.4),r=e*.72;for(let n=0;n<t;n++)s.push({x:e*(.7+n),y:o+(n%2?70:-70),w:r,h:560,depth:1})}else if(e===`grid`){let e=[n*.3,n*.7],t=[r*.32,r*.7];for(let n=0;n<4;n++)s.push({x:e[n%2],y:t[n<2?0:1],w:720,h:520,depth:1})}else if(e===`hero`)s.push({x:n*.36,y:o,w:1120,h:900,depth:1,importance:1.15}),s.push({x:n*.78,y:r*.34,w:560,h:440,depth:1}),s.push({x:n*.78,y:r*.7,w:560,h:440,depth:1});else if(e===`islands`)s.push({x:n*.22,y:r*.3,w:560,h:440,depth:.24,importance:.9}),s.push({x:n*.52,y:r*.56,w:760,h:580,depth:1,importance:1.1}),s.push({x:n*.82,y:r*.4,w:620,h:480,depth:1.28});else if(e===`pin`)for(let e=0;e<t;e++){let c=e/t*6.28;s.push({x:a+Math.cos(c)*n*.28+(i()-.5)*120,y:o+Math.sin(c)*r*.26+(i()-.5)*100,w:480,h:380,depth:1,fill:[`#fffaf0`,`#fef3e2`,`#eef7ff`][e%3]})}else if(e===`steps`)for(let e=0;e<t;e++){let i=e/(t-1);s.push({x:n*(.1+i*.8),y:o+Math.sin(i*Math.PI*1.6)*r*.26,w:560,h:460,depth:1})}else if(e===`orbit`){s.push({x:a,y:o,w:720,h:620,depth:1,importance:1.15,fill:`#fff`});for(let e=0;e<t-1;e++){let i=e/(t-1)*6.28-1.57;s.push({x:a+Math.cos(i)*n*.3,y:o+Math.sin(i)*r*.32,w:420,h:340,depth:1})}}return s}function Aj(e){return e.length<2?``:`<path d="${e.map((e,t)=>(t?`L`:`M`)+e.x.toFixed(0)+` `+e.y.toFixed(0)).join(` `)}" fill="none" stroke="#8a7a5a" stroke-width="10" stroke-dasharray="4 26" stroke-linecap="round" opacity=".7"/>`}function jj(e){if(!e.length)return``;let t=e[0];return e.slice(1).map(e=>`<line x1="${t.x.toFixed(0)}" y1="${t.y.toFixed(0)}" x2="${e.x.toFixed(0)}" y2="${e.y.toFixed(0)}" stroke="#5b6ce0" stroke-width="5" stroke-dasharray="2 14" opacity=".55"/>`).join(``)}function Mj(e){let t=``;for(let n=1;n<e.length;n++)t+=`<line x1="${e[n-1].x.toFixed(0)}" y1="${e[n-1].y.toFixed(0)}" x2="${e[n].x.toFixed(0)}" y2="${e[n].y.toFixed(0)}" stroke="#b04a3a" stroke-width="4" opacity=".6"/>`;return t}function Nj(e,t){return`<rect x="0" y="0" width="${e}" height="${t}" fill="#c8a97a" opacity=".5"/>`}function Pj(e,t={}){let n=Vj[e];if(!n)throw Error(`unknown board "${e}"`);let r={};n.manifest.forEach(e=>r[e.key]=e.default);for(let n of Object.keys(t))if(!(n in r))throw Error(`unknown element "${n}" for board "${e}" (has: ${Object.keys(r).join(`, `)})`);return{...r,...t}}function Fj(e){let t=Vj[e];return t?t.manifest:[]}function Ij(e,t=0,n={}){let r=Vj[e];if(!r)throw Error(`unknown board "${e}"`);let i=Pj(e,n),a=e=>i[e]!==!1,o=r.build(t,a);return{worldW:r.world[0],worldH:r.world[1],viewW:r.view[0],viewH:r.view[1],focusRing:a(`focusRing`),hud:a(`hud`),elements:i,...o}}function Lj(e,t,n=0){let r=175+Math.sin(n*4)*12;return`<circle cx="${e.toFixed(1)}" cy="${t.toFixed(1)}" r="155" fill="none" stroke="#fff" stroke-width="18" opacity=".78"/><circle cx="${e.toFixed(1)}" cy="${t.toFixed(1)}" r="${r.toFixed(1)}" fill="none" stroke="#f5c43e" stroke-width="6" opacity=".8"/>`}var Rj,zj,Bj,Vj,Hj,Uj,Wj,Gj=o((()=>{Tk(),Rj=44,zj=(e,t,n,r,i=`#fff`,a=.92)=>`<rect x="${(e-n/2).toFixed(0)}" y="${(t-r/2).toFixed(0)}" width="${n.toFixed(0)}" height="${r.toFixed(0)}" rx="${Rj}" fill="${i}" opacity="${a}"/>`,Bj=(e,t,n,r)=>`<ellipse cx="${e.toFixed(0)}" cy="${(t+r/2+8).toFixed(0)}" rx="${(n*.44).toFixed(0)}" ry="${Math.max(14,r*.05).toFixed(0)}" fill="#2b2140" opacity=".16"/>`,Vj={conceptTriptych:{world:[3e3,1800],view:[1920,1080],manifest:[{key:`bgGradient`,default:!0},{key:`bgCircleA`,default:!0},{key:`bgCircleB`,default:!0},{key:`roseBand`,default:!0},{key:`panelA`,default:!0},{key:`panelB`,default:!0},{key:`panelC`,default:!0},{key:`panelShadows`,default:!0},{key:`swoosh`,default:!0},{key:`fgBlobA`,default:!0},{key:`fgBlobB`,default:!0},{key:`focusRing`,default:!1},{key:`hud`,default:!1}],build(e,t){let n=`<defs><linearGradient id="pmbg_ct" x1="0" x2="1"><stop offset="0" stop-color="#f7dca7"/><stop offset="1" stop-color="#d9c5ef"/></linearGradient></defs>`;t(`bgGradient`)&&(n+=`<rect x="-500" y="-300" width="4000" height="2400" fill="url(#pmbg_ct)"/>`),t(`bgCircleA`)&&(n+=`<circle cx="350" cy="320" r="200" fill="#fff5dc" opacity=".65"/>`),t(`bgCircleB`)&&(n+=`<circle cx="2630" cy="420" r="280" fill="#8eddf1" opacity=".55"/>`),t(`roseBand`)&&(n+=`<path d="M-200 1550 Q700 1050 1450 1420 T3200 1200 L3200 2100 H-200Z" fill="#d86d82" opacity=".28"/>`);let r=``;t(`panelA`)&&(r+=`<rect x="120" y="260" width="630" height="520" rx="44" fill="#fff" opacity=".9"/>`),t(`panelB`)&&(r+=`<rect x="1840" y="290" width="720" height="560" rx="44" fill="#fff" opacity=".9"/>`),t(`panelC`)&&(r+=`<rect x="920" y="910" width="730" height="520" rx="44" fill="#fff" opacity=".92"/>`),t(`panelShadows`)&&(r+=`<ellipse cx="480" cy="710" rx="120" ry="30" fill="#2b2140" opacity=".16"/><ellipse cx="2200" cy="790" rx="160" ry="35" fill="#2b2140" opacity=".16"/><ellipse cx="1280" cy="1400" rx="220" ry="45" fill="#2b2140" opacity=".16"/>`);let i=``;return t(`swoosh`)&&(i+=`<path d="M-400 1750 Q350 1180 860 1600 T2050 1510 T3400 1310 L3400 2200 H-400Z" fill="#54379e" opacity=".72"/>`),t(`fgBlobA`)&&(i+=`<circle cx="220" cy="1440" r="150" fill="#25155b" opacity=".35"/>`),t(`fgBlobB`)&&(i+=`<circle cx="2900" cy="1360" r="220" fill="#25155b" opacity=".28"/>`),{planes:[{depth:.24,id:`bg`,svg:n},{depth:1,id:`mid`,svg:r},{depth:1.28,id:`fg`,svg:i}],panels:[{id:`panelA`,x:480,y:500,w:630,h:520},{id:`panelB`,x:2200,y:540,w:720,h:560},{id:`panelC`,x:1280,y:1180,w:730,h:520}],subjects:[{id:`panelA`,x:480,y:500,importance:1.05},{id:`panelB`,x:2200,y:540,importance:1.08},{id:`panelC`,x:1280,y:1180,importance:1.1}]}}},panelRow:Oj(`row`),panelGrid:Oj(`grid`),heroPanelSide:Oj(`hero`),floatingIslands:Oj(`islands`),pinboard:Oj(`pin`),stepsPath:Oj(`steps`),orbitBoard:Oj(`orbit`)},Hj={row:[`#f7dca7`,`#d9c5ef`,`#fff5dc`,`#8eddf1`],grid:[`#e8f0e6`,`#cfe0f0`,`#fff2d6`,`#bfe3d8`],hero:[`#fbe3cf`,`#e6d2f0`,`#ffe6c2`,`#c9d8f2`],islands:[`#dfeafc`,`#f3e2ef`,`#cfe9ff`,`#ffd9ec`],pin:[`#e8d9bf`,`#d3c0a3`,`#fff3d6`,`#d9c19a`],steps:[`#e9f2df`,`#d4e8f0`,`#fff0cf`,`#c7e6d6`],orbit:[`#1b1740`,`#2b2160`,`#5b6ce0`,`#8eddf1`]},Uj=Object.keys(Vj),Wj=e=>Object.prototype.hasOwnProperty.call(Vj,e)}));function Kj(e){return function(t=7){let n=cM[e]||cM.day,r=e+t;return[Z(0,(e,t,r)=>{let i=e.createLinearGradient(0,0,0,r);i.addColorStop(0,n.skyTop),i.addColorStop(1,n.skyBot),e.fillStyle=i,e.fillRect(-500,-500,t+1e3,r+1e3)}),dM(.14,`dfar`+r,n.far,90,150),dM(.3,`dmid`+r,n.mid,80,90),iM(n.ground),dM(.66,`dnear`+r,n.near,70,40),fM(-1,n),fM(1,n)]}}function qj(e,t){return function(n=7,r=`day`){let i=cM[r]||cM.day,a=e+r+n,o=(EM[t]||{}).bias||0;if(e===`room`)return[rM(i.skyBot),Z(.2,(e,t,n,r)=>{e.fillStyle=i.mid,e.fillRect(-500,-500,t+1e3,r+500)}),Z(.28,(e,t,n)=>{e.fillStyle=i.far,e.fillRect(t*.34,n*.15,t*.32,n*.32),e.fillStyle=i.skyTop,e.fillRect(t*.36,n*.17,t*.28,n*.28)}),iM(i.ground),Z(.66,(e,t,n,r,a)=>{e.fillStyle=i.near,e.fillRect(-500,r-14*a,t+1e3,14*a)}),...DM(t,i)];let s=bM[e]||bM.field;return[mM(i),xM(s[0],.14,`far`+a,{col:i.far,bias:o}),xM(s[1],.3,`mid`+a,{col:i.mid,bias:o}),iM(i.ground),xM(s[2],.66,`near`+a,{col:i.near,bias:o}),...DM(t,i)]}}function Jj(e,t){let n=qM[e]||qM[`center.c`];return{x:n.x*t,y:n.y,z:n.z==null?.5:n.z}}function Yj(e){let t={};return e.map((e,n)=>{let r=ZM(e.d);return t[r]=(t[r]||0)+1,{key:`l`+n,default:!0,label:r+(t[r]>1?` `+t[r]:``)}})}function Xj(e){return Wj(e)?Fj(e):Yj((tM[e]||tM.plain)(7,`day`))}function Zj(e,t={}){let n={};Xj(e).forEach(e=>n[e.key]=e.default);for(let r of Object.keys(t))if(!(r in n))throw Error(`unknown element "${r}" for setup "${e}" (has: ${Object.keys(n).join(`, `)})`);return{...n,...t}}function Qj(e,t=7,n=`2.5d`,r=`day`,i={}){let a=(tM[e]||tM.plain)(t,r),o=Zj(XM(e)?e:`plain`,i);return{name:XM(e)?e:`plain`,mode:n,seed:t,palette:r,slots:GM[e]||JM,layers:a,elements:o}}function $j(e,t,n,r,i,a={scale:0,pan:0},o=0){let s=n/eM;t&&t.layers.length&&t.layers.forEach((c,l)=>{if(t.elements&&t.elements[`l`+l]===!1)return;e.save();let u=1+a.scale*c.d,d=a.pan*c.d*s;e.translate(n/2,i),e.scale(u,u),e.translate(-n/2,-i),e.translate(d,0),c.draw(e,n,r,i,s,o),e.restore()})}var eM,tM,Z,nM,rM,iM,aM,oM,sM,cM,lM,uM,dM,fM,pM,mM,hM,gM,_M,vM,yM,bM,xM,SM,CM,wM,TM,EM,DM,OM,kM,AM,jM,MM,NM,PM,FM,IM,LM,RM,zM,BM,VM,HM,UM,WM,GM,KM,qM,JM,YM,XM,ZM,QM=o((()=>{Tk(),Dj(),Gj(),eM=960,tM={plain(){return[]},skyDay(e){let t=vk(`skyDay`+e),n=[];for(let e=0;e<6;e++)n.push({x:t()*eM,y:60+t()*200,s:.7+t()*.9});return[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#3d8fd6`),r.addColorStop(.6,`#8fc4ec`),r.addColorStop(1,`#dceffa`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3),e.fillStyle=`rgba(255,246,214,0.95)`,e.beginPath(),e.arc(t*.8,n*.22,44,0,7),e.fill()}},{d:.18,draw:(e,t,r,i,a)=>{e.fillStyle=`rgba(255,255,255,0.9)`,n.forEach(t=>{let n=t.x*a,i=t.y/540*r,o=26*t.s*a;e.beginPath(),e.arc(n,i,o,0,7),e.arc(n+o,i+4*a,o*.8,0,7),e.arc(n-o,i+4*a,o*.8,0,7),e.arc(n+o*.4,i-o*.6,o*.7,0,7),e.fill()})}}]},skyNight(e){let t=vk(`skyNight`+e),n=[];for(let e=0;e<90;e++)n.push({x:t()*eM,y:t()*480,r:.6+t()*1.8});return[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#0b1430`),r.addColorStop(1,`#26325c`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3),e.fillStyle=`rgba(240,240,220,0.9)`,e.beginPath(),e.arc(t*.24,n*.2,30,0,7),e.fill()}},{d:.12,draw:(e,t,r,i,a)=>{e.fillStyle=`#fdfbe8`,n.forEach(t=>{e.globalAlpha=.5+t.r%1*.5,e.beginPath(),e.arc(t.x*a,t.y/540*r,t.r*a,0,7),e.fill()}),e.globalAlpha=1}}]},city(e){let t=vk(`city`+e),n=[],r=[],i=[],a=-60;for(;a<1020;){let e=26+t()*30,r=80+t()*150;n.push({x:a,w:e,h:r}),a+=e+10}for(a=-80;a<1040;){let e=60+t()*70,n=120+t()*180;r.push({x:a,w:e,h:n}),a+=e+16}for(a=-100;a<1060;){let e=90+t()*80,n=90+t()*120;i.push({x:a,w:e,h:n}),a+=e+70}return[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#bfe3f2`),r.addColorStop(1,`#eaf6fb`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3),e.fillStyle=`rgba(255,255,255,0.55)`,e.beginPath(),e.arc(t*.78,n*.2,46,0,7),e.fill()}},{d:.15,draw:(e,t,r,i,a)=>{e.fillStyle=`#cdd7e6`,n.forEach(t=>e.fillRect(t.x*a,i-t.h*a,t.w*a,t.h*a+260))}},{d:.34,draw:(e,t,n,i,a)=>{r.forEach(t=>{e.fillStyle=`#7d8aa0`,e.fillRect(t.x*a,i-t.h*a,t.w*a,t.h*a),e.fillStyle=`rgba(255,235,170,0.9)`;let n=Math.floor(t.h/22);for(let r=0;r<3;r++)for(let o=0;o<n-1;o++)(r*7+o*13+(t.x|0))%3!=0&&e.fillRect((t.x+8+r*((t.w-16)/3))*a,i-(t.h-14-o*22)*a,((t.w-16)/3-7)*a,10*a)})}},{d:.46,draw:(e,t,n,r)=>{e.fillStyle=`#8e9aac`,e.fillRect(-500,r,t+1e3,n-r+500)}},{d:.78,draw:(e,t,n,r,a)=>{e.fillStyle=`#6a7689`,i.forEach(t=>e.fillRect(t.x*a,r-t.h*a,t.w*a,t.h*a))}}]},nature(e){let t=vk(`nature`+e),n=[],r=20;for(;r<eM;)n.push({x:r,h:70+t()*60}),r+=90+t()*70;return[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#bfe6ef`),r.addColorStop(1,`#eaf8f3`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3),e.fillStyle=`rgba(255,255,255,0.5)`,e.beginPath(),e.arc(t*.76,n*.22,42,0,7),e.fill()}},{d:.16,draw:(e,t,n,r,i)=>{e.fillStyle=`#bfe0a8`,e.beginPath(),e.moveTo(-500,r);for(let n=-500;n<=t+500;n+=36)e.lineTo(n,r-Math.abs(Math.sin(n*.004+1))*90*i-30*i);e.lineTo(t+500,r),e.closePath(),e.fill()}},{d:.34,draw:(e,t,n,r,i)=>{e.fillStyle=`#9fcf9a`,e.beginPath(),e.moveTo(-500,r);for(let n=-500;n<=t+500;n+=36)e.lineTo(n,r-Math.abs(Math.sin(n*.005+3))*60*i-10*i);e.lineTo(t+500,r),e.closePath(),e.fill()}},{d:.46,draw:(e,t,n,r)=>{e.fillStyle=`#7cae5a`,e.fillRect(-500,r,t+1e3,n-r+500)}},{d:.7,draw:(e,t,r,i,a)=>{n.forEach(t=>{let n=t.h;e.fillStyle=`#6b4a2e`,e.fillRect(t.x*a-3*a,i-n*.5*a,6*a,n*.5*a),e.fillStyle=`#3f8f63`,e.beginPath(),e.arc(t.x*a,i-n*.5*a,n*.42*a,0,7),e.fill()})}}]},interior(){return[{d:.1,draw:(e,t,n,r,i)=>{e.fillStyle=`#dcd2c2`,e.fillRect(-500,-500,t+1e3,r+500),e.fillStyle=`#cfc3b0`,e.fillRect(-500,r-30*i,t+1e3,30*i)}},{d:.3,draw:(e,t,n,r,i)=>{for(let r=0;r<3;r++){let a=t*(.24+r*.26),o=n*.3,s=72*i,c=60*i;e.fillStyle=`#fff`,e.fillRect(a-s/2,o-c/2,s,c),e.fillStyle=[`#d98c6a`,`#7c9fd9`,`#7cc08a`][r],e.fillRect(a-s/2+6*i,o-c/2+6*i,s-12*i,c-12*i)}}},{d:.46,draw:(e,t,n,r,i)=>{e.fillStyle=`#b9966f`,e.fillRect(-500,r,t+1e3,n-r+500),e.fillStyle=`#a8865f`;for(let t=-5;t<20;t++)e.fillRect(t*90*i,r,3*i,n-r+300)}}]},abstract(e){let t=vk(`abstract`+e),n=[];for(let e=0;e<8;e++)n.push({x:t()*eM,y:t()*540,r:50+t()*120,d:.12+t()*.72,h:t()});let r=[{d:0,draw:(e,t,n)=>{let r=e.createLinearGradient(0,0,0,n);r.addColorStop(0,`#2a2350`),r.addColorStop(1,`#5b3f8f`),e.fillStyle=r,e.fillRect(-500,-500,t+1e3,n+1e3)}}];return n.sort((e,t)=>e.d-t.d).forEach(e=>r.push({d:e.d,draw:(t,n,r,i,a)=>{t.globalAlpha=.82,t.fillStyle=e.h<.5?`#7c5cff`:`#ff7ab0`,t.beginPath(),t.arc(e.x*a,e.y/540*r,e.r*a,0,7),t.fill(),t.globalAlpha=1}})),r}},Z=(e,t)=>({d:e,draw:t}),nM=(e,t)=>Z(0,(n,r,i)=>{let a=n.createLinearGradient(0,0,0,i);a.addColorStop(0,e),a.addColorStop(1,t),n.fillStyle=a,n.fillRect(-500,-500,r+1e3,i+1e3)}),rM=e=>Z(0,(t,n,r)=>{t.fillStyle=e,t.fillRect(-500,-500,n+1e3,r+1e3)}),iM=(e,t=0)=>Z(.46,(n,r,i,a)=>{n.fillStyle=e,n.fillRect(-500,a+t,r+1e3,i-a+500)}),aM=(e,t,n,r,i,a)=>Z(e,(e,o,s,c,l)=>{let u=vk(t);e.fillStyle=n;for(let t=0;t<r;t++){let t=u()*eM,n=i[0]+u()*i[1],r=a[0]+u()*a[1];e.fillRect(t*l,c-r*l,n*l,r*l)}}),oM=(e,t,n,r)=>Z(e,(e,i,a,o,s)=>{let c=vk(t),l=20;for(;l<eM;){let t=60+c()*70;e.fillStyle=n,e.fillRect(l*s-3*s,o-t*.5*s,6*s,t*.5*s),e.fillStyle=r,e.beginPath(),e.arc(l*s,o-t*.5*s,t*.42*s,0,7),e.fill(),l+=80+c()*70}}),sM=e=>Z(.3,(t,n,r,i,a)=>{for(let i=0;i<3;i++){let o=n*(.22+i*.28),s=r*.28,c=66*a,l=54*a;t.fillStyle=`#fff`,t.fillRect(o-c/2,s-l/2,c,l),t.fillStyle=e[i%e.length],t.fillRect(o-c/2+6*a,s-l/2+6*a,c-12*a,l-12*a)}}),Object.assign(tM,{genericRoom(e){return tM.interior(e)},office(e){return[nM(`#dfe6ee`,`#eef2f6`),sM([`#7c9fd9`,`#3fae6b`]),Z(.34,(e,t,n,r,i)=>{e.fillStyle=`#c9d2da`;for(let t=0;t<3;t++)e.fillRect((120+t*300)*i,r-70*i,200*i,70*i)}),iM(`#c9b79a`)]},classroom(){return[rM(`#e8ede2`),Z(.28,(e,t,n)=>{e.fillStyle=`#3a6b52`,e.fillRect(t*.24,n*.16,t*.52,n*.34),e.strokeStyle=`#2c5240`,e.lineWidth=6,e.strokeRect(t*.24,n*.16,t*.52,n*.34)}),iM(`#c7b79a`)]},workshop(e){return[rM(`#d8d3c6`),aM(.3,`wk`+e,`#9a8b6f`,8,[30,40],[20,60]),iM(`#b09571`)]},kitchen(){return[rM(`#eef1eb`),Z(.34,(e,t,n,r,i)=>{e.fillStyle=`#c7cdb9`,e.fillRect(-500,r-40*i,t+1e3,12*i)}),iM(`#cdbfa4`)]},stagePodium(){return[rM(`#242a34`),Z(.2,(e,t,n)=>{let r=e.createRadialGradient(t/2,n*.3,20,t/2,n*.3,n*.7);r.addColorStop(0,`rgba(255,240,200,.35)`),r.addColorStop(1,`rgba(255,240,200,0)`),e.fillStyle=r,e.fillRect(0,0,t,n)}),iM(`#39414f`)]},corridor(){return[rM(`#dfe1e6`),Z(.3,(e,t,n)=>{e.strokeStyle=`#c3c8d0`,e.lineWidth=3;for(let r=-3;r<=3;r++)e.beginPath(),e.moveTo(t/2+r*t*.16,0),e.lineTo(t/2+r*t*.04,n),e.stroke()}),iM(`#b8bcc6`)]},storeInterior(e){return[rM(`#e9e4da`),aM(.32,`st`+e,`#b79c74`,6,[70,20],[60,40]),iM(`#c3b393`)]},labGeneric(e){return[rM(`#eef3f5`),aM(.32,`lb`+e,`#cdd7dc`,5,[40,50],[30,60]),iM(`#d3dde0`)]},controlRoom(e){return[rM(`#1d2430`),Z(.3,(t,n,r,i,a)=>{vk(`cr`+e);for(let e=0;e<8;e++)t.fillStyle=[`#2b6cb0`,`#2bb3a3`,`#c98a3a`][e%3],t.globalAlpha=.7,t.fillRect((60+e*110)*a,(120+e%2*40)*a,80*a,50*a),t.globalAlpha=1}),iM(`#2a323f`)]},street(e){return[nM(`#bfe3f2`,`#eaf6fb`),aM(.4,`str`+e,`#8e9aac`,10,[50,60],[90,150]),iM(`#7a8391`),Z(.5,(e,t,n,r,i)=>{e.fillStyle=`#5c636e`,e.fillRect(-500,r,t+1e3,n),e.strokeStyle=`#e6c34a`,e.lineWidth=3*i,e.setLineDash([20*i,18*i]),e.beginPath(),e.moveTo(-500,r+(n-r)*.5),e.lineTo(t+500,r+(n-r)*.5),e.stroke(),e.setLineDash([])})]},park(){return[nM(`#bfe6ef`,`#eaf8f3`),iM(`#7cae5a`),oM(.6,`park`,`#6b4a2e`,`#3f8f63`),Z(.5,(e,t,n,r)=>{e.fillStyle=`#cdbd8f`,e.beginPath(),e.moveTo(t*.3,n),e.lineTo(t*.46,r),e.lineTo(t*.54,r),e.lineTo(t*.7,n),e.fill()})]},forest(e){return[nM(`#cfe6d6`,`#eef7ef`),iM(`#5f8f4e`),oM(.4,`f1`+e,`#5a3e26`,`#357a4e`),oM(.7,`f2`+e,`#6b4a2e`,`#3f8f63`)]},mountain(e){return[nM(`#cfe0ef`,`#eef4f9`),Z(.2,(t,n,r,i,a)=>{let o=vk(`mt`+e);t.fillStyle=`#9fb0c4`;for(let e=0;e<5;e++){let n=e*eM/4*a,r=(160+o()*120)*a;t.beginPath(),t.moveTo(n-140*a,i),t.lineTo(n,i-r),t.lineTo(n+140*a,i),t.fill()}}),iM(`#7f9e6f`)]},desertPlain(){return[nM(`#f4dcae`,`#f8eccf`),iM(`#e4c483`),Z(.3,(e,t,n,r,i)=>{e.fillStyle=`#d9b46e`,e.beginPath(),e.moveTo(-500,r);for(let n=-500;n<=t+500;n+=40)e.lineTo(n,r-Math.abs(Math.sin(n*.003))*30*i);e.lineTo(t+500,r),e.fill()})]},coastBeach(){return[nM(`#bfe3f2`,`#e8f6fb`),Z(.34,(e,t,n,r,i)=>{e.fillStyle=`#4aa3c4`,e.fillRect(-500,r-60*i,t+1e3,60*i)}),iM(`#ead9a6`)]},farmField(){return[nM(`#c7e6f0`,`#eef9f3`),iM(`#8bab4e`),Z(.5,(e,t,n,r,i)=>{e.strokeStyle=`#79993f`,e.lineWidth=3*i;for(let n=0;n<6;n++)e.beginPath(),e.moveTo(-500,r+n*20*i),e.lineTo(t+500,r+n*20*i),e.stroke()})]},skylineWide(e){return[nM(`#bcd8ee`,`#eaf4fb`),aM(.2,`sk`+e,`#aebccd`,14,[30,40],[80,160]),aM(.42,`sk2`+e,`#8695a9`,9,[60,60],[60,120]),iM(`#79879a`)]},rooftop(e){return[nM(`#bfe3f2`,`#eaf6fb`),aM(.2,`rf`+e,`#9caabd`,10,[40,50],[60,120]),iM(`#8a8f98`),Z(.5,(e,t,n,r,i)=>{e.fillStyle=`#6f747d`,e.fillRect(-500,r-16*i,t+1e3,16*i)})]},roadHighway(){return[nM(`#bfe3f2`,`#eaf6fb`),iM(`#5c636e`),Z(.5,(e,t,n,r,i)=>{e.strokeStyle=`#eef2f4`,e.lineWidth=4*i,e.setLineDash([26*i,22*i]),[.35,.65].forEach(i=>{e.beginPath(),e.moveTo(-500,r+(n-r)*i),e.lineTo(t+500,r+(n-r)*i),e.stroke()}),e.setLineDash([])})]},oceanSurface(){return[nM(`#a9d6ec`,`#dff1fb`),Z(.4,(e,t,n,r,i)=>{e.fillStyle=`#2f8fc0`,e.fillRect(-500,r-30*i,t+1e3,n),e.strokeStyle=`rgba(255,255,255,.5)`,e.lineWidth=2*i;for(let n=0;n<5;n++){e.beginPath(),e.moveTo(-500,r+n*26*i);for(let a=-500;a<t+500;a+=30)e.lineTo(a,r+n*26*i+Math.sin(a*.03+n)*4*i);e.stroke()}})]},underwater(e){return[nM(`#1f6f9e`,`#0c3f5f`),Z(.3,(t,n,r,i,a)=>{let o=vk(`uw`+e);t.fillStyle=`rgba(255,255,255,.25)`;for(let e=0;e<30;e++)t.beginPath(),t.arc(o()*n,o()*r,(2+o()*6)*a,0,7),t.fill()}),iM(`#b79a5f`)]},skyClouds(){return tM.skyDay(3)},spacePlanet(e){return[nM(`#0a0f22`,`#161f3e`),Z(.12,(t,n,r,i,a)=>{let o=vk(`sp`+e);t.fillStyle=`#fdfbe8`;for(let e=0;e<80;e++)t.fillRect(o()*n,o()*r,2,2)}),Z(.2,(e,t,n,r,i)=>{e.fillStyle=`#c96a5e`,e.beginPath(),e.arc(t*.76,n*.3,60*i,0,7),e.fill(),e.fillStyle=`rgba(255,255,255,.12)`,e.beginPath(),e.arc(t*.72,n*.26,60*i,0,7),e.fill()})]},arcticIce(){return[nM(`#cfe6f2`,`#eef7fb`),iM(`#dfeef4`),Z(.4,(e,t,n,r,i)=>{e.fillStyle=`#bcd7e4`;for(let t=0;t<4;t++){let n=(120+t*260)*i;e.beginPath(),e.moveTo(n-90*i,r),e.lineTo(n,r-70*i),e.lineTo(n+90*i,r),e.fill()}})]},studioPlain(){return[nM(`#eef3f4`,`#dbe8ea`)]},gradientAbstract(e){let t=vk(`ga`+e),n=Math.floor(t()*360);return[Z(0,(e,t,r)=>{let i=e.createLinearGradient(0,0,t,r);i.addColorStop(0,`hsl(${n} 55% 62%)`),i.addColorStop(1,`hsl(${(n+60)%360} 55% 48%)`),e.fillStyle=i,e.fillRect(0,0,t,r)})]},gridBoard(){return[rM(`#f4f7f8`),Z(.2,(e,t,n,r,i)=>{e.strokeStyle=`#dde5e9`,e.lineWidth=1.5;for(let r=0;r<t;r+=40*i)e.beginPath(),e.moveTo(r,0),e.lineTo(r,n),e.stroke();for(let r=0;r<n;r+=40*i)e.beginPath(),e.moveTo(0,r),e.lineTo(t,r),e.stroke()})]},mapStage(e){return[rM(`#dcece2`),Z(.2,(t,n,r,i,a)=>{let o=vk(`mp`+e);t.fillStyle=`#b7d8c1`,t.beginPath(),t.moveTo(n*.2,r*.3);for(let e=0;e<10;e++)t.lineTo(n*(.2+o()*.6),r*(.2+o()*.6));t.closePath(),t.fill()})]},chartStage(){return[rM(`#f6f8f9`),Z(.2,(e,t,n,r,i)=>{e.strokeStyle=`#d7dee3`,e.lineWidth=2,e.beginPath(),e.moveTo(t*.15,n*.2),e.lineTo(t*.15,n*.8),e.lineTo(t*.85,n*.8),e.stroke()})]},timelineBand(){return[rM(`#f4f7f8`),Z(.3,(e,t,n,r,i)=>{e.fillStyle=`#e7edf1`,e.fillRect(0,n*.46,t,n*.08)})]},splitVersus(){return[Z(0,(e,t,n)=>{e.fillStyle=`#dfeaf6`,e.fillRect(0,0,t/2,n),e.fillStyle=`#f6e3df`,e.fillRect(t/2,0,t/2,n),e.strokeStyle=`#c7d0d6`,e.lineWidth=3,e.beginPath(),e.moveTo(t/2,0),e.lineTo(t/2,n),e.stroke()})]},iconField(e){return[rM(`#f2f5f6`),Z(.2,(t,n,r,i,a)=>{let o=vk(`if`+e);t.fillStyle=`#dbe4e8`;for(let e=0;e<24;e++)t.beginPath(),t.arc(o()*n,o()*r,10*a,0,7),t.fill()})]},blueprint(){return[rM(`#123a63`),Z(.2,(e,t,n,r,i)=>{e.strokeStyle=`rgba(255,255,255,.22)`,e.lineWidth=1;for(let r=0;r<t;r+=34*i)e.beginPath(),e.moveTo(r,0),e.lineTo(r,n),e.stroke();for(let r=0;r<n;r+=34*i)e.beginPath(),e.moveTo(0,r),e.lineTo(t,r),e.stroke()})]},spotlightDark(){return[rM(`#171c24`),Z(.1,(e,t,n,r)=>{let i=e.createRadialGradient(t/2,r-120,30,t/2,r-120,t*.6);i.addColorStop(0,`rgba(255,255,255,.16)`),i.addColorStop(1,`rgba(255,255,255,0)`),e.fillStyle=i,e.fillRect(0,0,t,n)}),iM(`#20262f`)]},crowdScene(e){return[nM(`#cfd8e2`,`#eaeff4`),iM(`#9aa2ad`),Z(.6,(t,n,r,i,a)=>{let o=vk(`cw`+e);for(let e=0;e<26;e++){let e=o()*eM*a,n=(50+o()*30)*a;t.fillStyle=`hsl(${Math.floor(o()*360)} 30% 55%)`,t.fillRect(e,i-n,16*a,n),t.beginPath(),t.arc(e+8*a,i-n,9*a,0,7),t.fill()}})]},marketplace(e){return[nM(`#e9d9b0`,`#f4ead0`),iM(`#c9b184`),Z(.5,(t,n,r,i,a)=>{vk(`mk`+e);for(let e=0;e<5;e++){let n=(80+e*200)*a;t.fillStyle=[`#c0563f`,`#3f7fc0`,`#3fae6b`,`#c9a13a`,`#8b5cf6`][e],t.fillRect(n,i-90*a,140*a,20*a),t.fillStyle=`#a9855c`,t.fillRect(n+6*a,i-70*a,6*a,70*a),t.fillRect(n+128*a,i-70*a,6*a,70*a)}})]},constructionSite(e){return[nM(`#cfe0ec`,`#eef4f9`),iM(`#b79a6a`),Z(.4,(e,t,n,r,i)=>{e.strokeStyle=`#e0a52e`,e.lineWidth=6*i,e.strokeRect(t*.3,r-200*i,6*i,200*i),e.beginPath(),e.moveTo(t*.3,r-200*i),e.lineTo(t*.55,r-200*i),e.stroke()})]},harborDock(e){return[nM(`#bfe3f2`,`#eaf6fb`),Z(.4,(e,t,n,r,i)=>{e.fillStyle=`#3f8fb5`,e.fillRect(-500,r-20*i,t+1e3,n)}),iM(`#8a6a45`,20),Z(.3,(e,t,n,r,i)=>{e.strokeStyle=`#c9553f`,e.lineWidth=6*i,e.strokeRect(t*.6,r-150*i,6*i,150*i)})]},weatherStorm(e){return[nM(`#4a5361`,`#6a7484`),Z(.2,(t,n,r,i,a)=>{let o=vk(`ws`+e);t.strokeStyle=`rgba(220,230,240,.4)`,t.lineWidth=2;for(let e=0;e<60;e++){let e=o()*n,i=o()*r;t.beginPath(),t.moveTo(e,i),t.lineTo(e-6*a,i+18*a),t.stroke()}}),iM(`#3c4450`)]}}),cM={day:{skyTop:`#7fb2e0`,skyBot:`#cfe6f5`,far:`#b8cdde`,mid:`#7f93a8`,ground:`#6d8196`,near:`#4f6172`,occluder:`#26323f`},goldenHour:{skyTop:`#f0a35a`,skyBot:`#f7d79a`,far:`#d8b58a`,mid:`#b5876a`,ground:`#8f6a4f`,near:`#5f4636`,occluder:`#2a1c14`},dusk:{skyTop:`#e98a5b`,skyBot:`#f4c78d`,far:`#caa088`,mid:`#9c6f6a`,ground:`#7a5b57`,near:`#513f4a`,occluder:`#241826`},night:{skyTop:`#0b1430`,skyBot:`#26325c`,far:`#33406a`,mid:`#26314f`,ground:`#1b2740`,near:`#141d33`,occluder:`#060a16`},dawn:{skyTop:`#b98db5`,skyBot:`#f3d0c9`,far:`#c9b3c4`,mid:`#9e8ba0`,ground:`#7d7085`,near:`#55495e`,occluder:`#221c2b`},overcast:{skyTop:`#b8bfc6`,skyBot:`#d8dde1`,far:`#b3bcc4`,mid:`#97a2ad`,ground:`#808b95`,near:`#5e6771`,occluder:`#333a42`},desert:{skyTop:`#e6c98a`,skyBot:`#f4ead0`,far:`#dcc59a`,mid:`#c9a56f`,ground:`#b98d5a`,near:`#9a6f45`,occluder:`#4a3520`},arctic:{skyTop:`#a9c9e0`,skyBot:`#eef7fb`,far:`#cddfe9`,mid:`#b6cdd8`,ground:`#cfe0e6`,near:`#93b0bd`,occluder:`#35505e`},underwater:{skyTop:`#1f6f8f`,skyBot:`#0d3f4f`,far:`#2f7f8a`,mid:`#266b70`,ground:`#1b4f52`,near:`#143a3a`,occluder:`#08201f`},space:{skyTop:`#05060f`,skyBot:`#10132a`,far:`#1e2340`,mid:`#191d38`,ground:`#12162c`,near:`#0c0f20`,occluder:`#04050c`},neonNight:{skyTop:`#14082a`,skyBot:`#2a1050`,far:`#7a3fb0`,mid:`#b03f8a`,ground:`#2a1a4a`,near:`#16102e`,occluder:`#080416`},sepiaPast:{skyTop:`#cdb488`,skyBot:`#e6d4ad`,far:`#c4ac82`,mid:`#a98d64`,ground:`#8a7150`,near:`#5f4c34`,occluder:`#2f2419`}},lM=Object.keys(cM),uM={day:`light`,goldenHour:`light`,dusk:`light`,night:`dark`,dawn:`light`,overcast:`light`,desert:`light`,arctic:`light`,underwater:`dark`,space:`dark`,neonNight:`dark`,sepiaPast:`light`},dM=(e,t,n,r,i,a=0)=>Z(e,(e,o,s,c,l)=>{let u=vk(t),d=[];for(let e=0;e<=16;e++)d.push((i+u()*r)*(1+a*.45*(e/8-1)));e.fillStyle=n,e.beginPath(),e.moveTo(-500,c);for(let t=0;t<=16;t++){let n=-200+t/16*(o+400);e.lineTo(n,c-d[t]*l)}e.lineTo(o+500,c),e.closePath(),e.fill()}),fM=(e,t)=>Z(.9,(n,r,i,a,o,s=0)=>{let c=1+Math.sin(s*.55+(e<0?0:1.7))*.02,l=Math.sin(s*.12+e)*22*o,u=r*.24*c,d=e<0?-60+l:r-u+60+l;n.save(),n.globalAlpha=.97,n.fillStyle=t.occluder,n.beginPath(),n.moveTo(d,-60),n.lineTo(d+u,-60),n.lineTo(d+u-26*o,i*.42),n.lineTo(d+u+10*o,i*.64),n.lineTo(d+u-34*o,i+60),n.lineTo(d-60,i+60),n.closePath(),n.fill(),n.restore()}),pM={dioramaDay:Kj(`day`),dioramaDusk:Kj(`dusk`),dioramaNight:Kj(`night`),dioramaDesert:Kj(`desert`),dioramaArctic:Kj(`arctic`)},Object.assign(tM,pM),Object.keys(pM),mM=e=>Z(0,(t,n,r)=>{let i=t.createLinearGradient(0,0,0,r);i.addColorStop(0,e.skyTop),i.addColorStop(1,e.skyBot),t.fillStyle=i,t.fillRect(-500,-500,n+1e3,r+1e3)}),hM=(e,t,n,r,i,a=0)=>Z(e,(e,o,s,c,l)=>{let u=vk(t);e.fillStyle=n,e.beginPath(),e.moveTo(-500,c);for(let t=0;t<=9;t++){let n=-200+t/9*(o+400),s=(t%2?i+u()*r:i*.28)*(1+a*.45*(t/4.5-1));e.lineTo(n,c-s*l)}e.lineTo(o+500,c),e.closePath(),e.fill()}),gM=(e,t,n,r,i,a=0)=>Z(e,(t,o,s,c,l)=>{t.fillStyle=n,t.beginPath(),t.moveTo(-500,c);for(let n=-200;n<=o+400;n+=22){let s=(n+200)/(o+400);t.lineTo(n,c-(i+Math.abs(Math.sin(n*.004+e*3))*r)*(1+a*.45*(s*2-1))*l)}t.lineTo(o+500,c),t.closePath(),t.fill()}),_M=(e,t,n,r,i,a=0)=>Z(e,(e,o,s,c,l)=>{let u=vk(t);e.fillStyle=n;let d=-80;for(;d<o+80;){let t=d/o,n=(r+u()*(i-r))*(1+a*.45*(t*2-1))*l,s=(40+u()*60)*l;e.fillRect(d,c-n,s,n+300),d+=s+(6+u()*14)*l}}),vM=(e,t,n,r,i)=>Z(e,(e,a,o,s,c)=>{let l=vk(t);e.fillStyle=n;let u=-40;for(;u<a+40;){let t=(r+l()*i)*c;e.beginPath(),e.arc(u,s-t*.5,t*.5,0,7),e.fill(),e.fillRect(u-t*.14,s-t*.5,t*.28,t*.5+200),u+=(30+l()*22)*c}}),yM=(e,t)=>Z(e,(e,n,r,i,a)=>{e.fillStyle=t,e.fillRect(-500,i-10*a,n+1e3,r),e.strokeStyle=`rgba(255,255,255,.16)`,e.lineWidth=1.5*a;for(let t=0;t<4;t++){e.beginPath();for(let r=-500;r<n+500;r+=26)e.lineTo(r,i+t*22*a+Math.sin(r*.03+t)*3*a);e.stroke()}}),bM={field:[[`rolling`,60,110],[`rolling`,48,64],[`rolling`,36,28]],hills:[[`rolling`,110,150],[`rolling`,80,88],[`rolling`,56,38]],ridge:[[`jagged`,150,150],[`jagged`,110,86],[`jagged`,78,40]],valley:[[`rolling`,120,150],[`rolling`,44,58],[`rolling`,80,44]],dunes:[[`dune`,70,110],[`dune`,54,66],[`dune`,40,30]],mesa:[[`jagged`,110,150],[`jagged`,84,84],[`jagged`,60,40]],coast:[[`rolling`,56,100],[`water`,0,0],[`rolling`,40,28]],harbor:[[`skyline`,70,140],[`water`,0,0],[`skyline`,56,86]],forest:[[`rolling`,70,110],[`tree`,64,40],[`tree`,48,30]],city:[[`skyline`,90,170],[`skyline`,110,150],[`skyline`,78,110]],plaza:[[`skyline`,80,150],[`rolling`,28,44],[`skyline`,60,84]]},xM=(e,t,n,r)=>{let[i,a,o]=e,s=r.bias||0;return i===`jagged`?hM(t,n,r.col,a,o,s):i===`dune`?gM(t,n,r.col,a,o,s):i===`skyline`?_M(t,n,r.col,o,o+a,s):i===`tree`?vM(t,n,r.col,o,a):i===`water`?yM(t,r.col):dM(t,n,r.col,a,o,s)},SM=e=>1+Math.sin(e*.55)*.02,CM=(e,t)=>Math.sin(e*.12+t)*16,wM={curtain:(e,t)=>Z(.88,(n,r,i,a,o,s=0)=>{let c=r*.15*SM(s),l=CM(s,t)*o,u=t<0?-40+l:r-c+40+l;n.save(),n.globalAlpha=.9,n.fillStyle=e.occluder,n.beginPath(),n.moveTo(u,-60),n.lineTo(u+c,-60),n.lineTo(u+c-20*o,i*.5),n.lineTo(u+c-30*o,i+60),n.lineTo(u-40,i+60),n.closePath(),n.fill(),n.restore()}),foliage:(e,t)=>Z(.9,(n,r,i,a,o,s=0)=>{let c=CM(s,t)*o,l=t<0?-16+c:r+16+c,u=t<0?1:-1;n.save(),n.globalAlpha=.9,n.fillStyle=e.occluder;for(let e=0;e<5;e++){let t=l+u*e*42*o,r=(18+e*22)*o+Math.sin(s*.5+e)*4*o;n.beginPath(),n.arc(t,r,(48-e*4)*o,0,7),n.fill()}n.restore()}),pillar:(e,t)=>Z(.88,(n,r,i,a,o,s=0)=>{let c=CM(s,t)*o*.3,l=r*.085,u=t<0?r*.05+c:r*.865+c;n.save(),n.globalAlpha=.94,n.fillStyle=e.occluder,n.fillRect(u,-40,l,i+80),n.fillStyle=yk(e.occluder,1.35),n.fillRect(u,-40,l*.32,i+80),n.restore()}),archTop:e=>Z(.9,(t,n,r,i,a,o=0)=>{let s=SM(o);t.save(),t.globalAlpha=.94,t.fillStyle=e.occluder,t.beginPath(),t.moveTo(-60,-60),t.lineTo(n+60,-60),t.lineTo(n+60,r*.2*s),t.quadraticCurveTo(n*.5,r*.44*s,-60,r*.2*s),t.closePath(),t.fill(),t.restore()}),ledge:e=>Z(.9,(t,n,r,i,a,o=0)=>{let s=SM(o);t.save(),t.globalAlpha=.94,t.fillStyle=e.occluder,t.fillRect(-60,r-58*a*s,n+120,90*a),t.restore()}),rocks:(e,t)=>Z(.9,(n,r,i,a,o)=>{let s=t<0?r*.03:r*.8;n.save(),n.globalAlpha=.94,n.fillStyle=e.occluder,n.beginPath(),n.moveTo(s-70,i+60),n.lineTo(s,i-66*o),n.lineTo(s+52*o,i-40*o),n.lineTo(s+112*o,i-92*o),n.lineTo(s+190*o,i+60),n.closePath(),n.fill(),n.restore()}),kelp:(e,t)=>Z(.9,(n,r,i,a,o,s=0)=>{let c=t<0?r*.07:r*.9;n.save(),n.globalAlpha=.78,n.strokeStyle=e.occluder,n.lineWidth=13*o,n.lineCap=`round`;for(let e=0;e<2;e++){let t=c+e*24*o;n.beginPath(),n.moveTo(t,i+40);for(let r=i;r>i*.3;r-=28)n.lineTo(t+Math.sin(r*.02+s*.6+e)*20*o,r);n.stroke()}n.restore()}),beam:(e,t)=>Z(.88,(n,r,i,a,o)=>{let s=t<0?1:-1,c=t<0?-40:r+40;n.save(),n.globalAlpha=.9,n.strokeStyle=e.occluder,n.lineWidth=22*o,n.beginPath(),n.moveTo(c,-40),n.lineTo(c+s*r*.5,i*.7),n.stroke(),n.restore()}),crowdFg:e=>Z(.92,(t,n,r,i,a,o=0)=>{t.save(),t.globalAlpha=.9,t.fillStyle=e.occluder;for(let e=0;e<7;e++){let i=(e+.5)*(n/7)+Math.sin(o*.6+e)*4*a;t.beginPath(),t.arc(i,r+34*a,44*a,Math.PI,0),t.fill(),t.beginPath(),t.arc(i,r-18*a,20*a,0,7),t.fill()}t.restore()})},TM={genericRoom:[{kind:`pillar`,side:1}],office:[{kind:`beam`,side:-1}],classroom:[{kind:`pillar`,side:-1}],workshop:[{kind:`beam`,side:1}],kitchen:[{kind:`ledge`}],stagePodium:[{kind:`curtain`,side:-1},{kind:`curtain`,side:1}],corridor:[{kind:`archTop`}],storeInterior:[{kind:`pillar`,side:1}],labGeneric:[],controlRoom:[{kind:`pillar`,side:-1}],courtroomGeneric:[{kind:`pillar`,side:1}],hospitalWard:[],throneHall:[{kind:`pillar`,side:-1},{kind:`pillar`,side:1}],street:[{kind:`curtain`,side:1}],park:[{kind:`foliage`,side:-1}],forest:[{kind:`foliage`,side:-1},{kind:`foliage`,side:1}],mountain:[{kind:`rocks`,side:-1}],desertPlain:[],coastBeach:[{kind:`rocks`,side:1}],farmField:[],skylineWide:[{kind:`curtain`,side:1}],rooftop:[{kind:`ledge`}],roadHighway:[],rooftopNight:[{kind:`ledge`}],ruins:[{kind:`rocks`,side:1}],cave:[{kind:`archTop`}],oceanSurface:[],underwater:[{kind:`kelp`,side:-1},{kind:`kelp`,side:1}],harborDock:[{kind:`beam`,side:1}],skyClouds:[],spacePlanet:[],arcticIce:[{kind:`rocks`,side:-1}],weatherStorm:[{kind:`curtain`,side:-1}],crowdScene:[{kind:`crowdFg`}],marketplace:[{kind:`crowdFg`}],marketStreetDense:[{kind:`crowdFg`}],stadium:[{kind:`crowdFg`}],constructionSite:[{kind:`beam`,side:-1}],openField:[],rollingHills:[{kind:`foliage`,side:-1}],mountainRidge:[{kind:`rocks`,side:1}],valleyStage:[],pineForest:[{kind:`foliage`,side:-1},{kind:`foliage`,side:1}],sandDunes:[],mesaFlats:[{kind:`rocks`,side:-1}],seaCoast:[{kind:`ledge`}],portHarbor:[{kind:`beam`,side:1}],cityscape:[{kind:`curtain`,side:1}],townPlaza:[{kind:`pillar`,side:-1}],interiorRoom:[{kind:`pillar`,side:1}]},[`studioPlain`,`gradientAbstract`,`gridBoard`,`mapStage`,`chartStage`,`timelineBand`,`splitVersus`,`iconField`,`blueprint`,`spotlightDark`].forEach(e=>{TM[e]=[]}),EM={genericRoom:{focal:`left`,bias:1},office:{focal:`right`,bias:-1},classroom:{focal:`right`,bias:-1},workshop:{focal:`left`,bias:1},kitchen:{focal:`center`,bias:0},stagePodium:{focal:`center`,bias:0},corridor:{focal:`center`,bias:0},storeInterior:{focal:`left`,bias:1},labGeneric:{focal:`right`,bias:-1},controlRoom:{focal:`right`,bias:-1},courtroomGeneric:{focal:`left`,bias:1},hospitalWard:{focal:`center`,bias:0},throneHall:{focal:`center`,bias:0},street:{focal:`left`,bias:1},park:{focal:`right`,bias:-1},forest:{focal:`center`,bias:0},mountain:{focal:`right`,bias:1},desertPlain:{focal:`left`,bias:1},coastBeach:{focal:`left`,bias:-1},farmField:{focal:`right`,bias:-1},skylineWide:{focal:`left`,bias:1},rooftop:{focal:`center`,bias:0},roadHighway:{focal:`center`,bias:0},rooftopNight:{focal:`right`,bias:-1},ruins:{focal:`left`,bias:1},cave:{focal:`center`,bias:0},oceanSurface:{focal:`left`,bias:1},underwater:{focal:`center`,bias:0},harborDock:{focal:`left`,bias:1},skyClouds:{focal:`center`,bias:0},spacePlanet:{focal:`right`,bias:-1},arcticIce:{focal:`right`,bias:-1},weatherStorm:{focal:`right`,bias:-1},crowdScene:{focal:`center`,bias:0},marketplace:{focal:`right`,bias:-1},marketStreetDense:{focal:`left`,bias:1},stadium:{focal:`center`,bias:0},constructionSite:{focal:`right`,bias:-1},openField:{focal:`right`,bias:-1},rollingHills:{focal:`right`,bias:-1},mountainRidge:{focal:`left`,bias:1},valleyStage:{focal:`center`,bias:0},pineForest:{focal:`center`,bias:0},sandDunes:{focal:`left`,bias:1},mesaFlats:{focal:`right`,bias:-1},seaCoast:{focal:`left`,bias:1},portHarbor:{focal:`left`,bias:1},cityscape:{focal:`left`,bias:1},townPlaza:{focal:`right`,bias:-1},interiorRoom:{focal:`left`,bias:1}},[`studioPlain`,`gradientAbstract`,`gridBoard`,`mapStage`,`chartStage`,`timelineBand`,`splitVersus`,`iconField`,`blueprint`,`spotlightDark`].forEach(e=>{EM[e]={focal:`center`,bias:0}}),DM=(e,t)=>(TM[e]||[]).map(e=>wM[e.kind]?wM[e.kind](t,e.side||-1):null).filter(Boolean),OM={openField:`field`,rollingHills:`hills`,mountainRidge:`ridge`,valleyStage:`valley`,sandDunes:`dunes`,mesaFlats:`mesa`,seaCoast:`coast`,portHarbor:`harbor`,pineForest:`forest`,cityscape:`city`,townPlaza:`plaza`,interiorRoom:`room`},kM=Object.keys(OM),Object.keys(OM).forEach(e=>{tM[e]=qj(OM[e],e)}),AM=(e,t=.18)=>Z(t,(t,n,r,i)=>{t.fillStyle=e.mid,t.fillRect(-500,-500,n+1e3,i+500)}),jM=e=>Z(.66,(t,n,r,i,a)=>{t.fillStyle=e.near,t.fillRect(-500,i-12*a,n+1e3,12*a)}),MM=(e,t,n)=>Z(0,(r,i,a)=>{let o=n?r.createLinearGradient(0,0,i,a):r.createLinearGradient(0,0,0,a);o.addColorStop(0,e),o.addColorStop(1,t),r.fillStyle=o,r.fillRect(-500,-500,i+1e3,a+1e3)}),NM=(e,t)=>[rM(e.skyBot),AM(e),Z(.3,t(e)),iM(e.ground),jM(e)],PM=(e,t,n,r,i,a,o=0)=>[mM(e),xM(n,.14,`f`+t,{col:e.far,bias:o}),xM(r,.3,`m`+t,{col:e.mid,bias:o}),Z(.46,(t,n,r,i,o,s)=>{t.fillStyle=e.ground,t.fillRect(-500,i,n+1e3,r-i+500),a&&a(e)(t,n,r,i,o,s)}),xM(i,.66,`n`+t,{col:e.near,bias:o})],FM={window:e=>(t,n,r)=>{t.fillStyle=e.far,t.fillRect(n*.34,r*.15,n*.32,r*.34),t.fillStyle=e.skyTop,t.fillRect(n*.36,r*.17,n*.28,r*.3),t.strokeStyle=e.occluder,t.lineWidth=3,t.beginPath(),t.moveTo(n*.5,r*.17),t.lineTo(n*.5,r*.49),t.moveTo(n*.36,r*.32),t.lineTo(n*.64,r*.32),t.stroke()},monitors:e=>(t,n,r)=>{for(let i=0;i<4;i++)t.fillStyle=e.near,t.fillRect(n*(.16+i*.19),r*.24,n*.13,r*.16),t.fillStyle=e.skyTop,t.fillRect(n*(.165+i*.19),r*.25,n*.12,r*.14)},board:e=>(t,n,r)=>{t.fillStyle=`#2f5240`,t.fillRect(n*.22,r*.16,n*.56,r*.34),t.strokeStyle=e.ground,t.lineWidth=6,t.strokeRect(n*.22,r*.16,n*.56,r*.34),t.strokeStyle=`rgba(255,255,255,.4)`,t.lineWidth=2,t.beginPath(),t.moveTo(n*.28,r*.3),t.lineTo(n*.5,r*.3),t.stroke()},pegboard:e=>(t,n,r)=>{t.fillStyle=e.near;for(let e=0;e<6;e++)t.fillRect(n*(.2+e*.1),r*.2,n*.03,r*.22)},counter:e=>(t,n,r,i,a)=>{t.fillStyle=e.near,t.fillRect(-500,i-60*a,n+1e3,14*a),t.fillStyle=e.far;for(let e=0;e<4;e++)t.fillRect(n*(.2+e*.16),r*.2,n*.11,r*.16)},spotlight:e=>(e,t,n,r)=>{let i=e.createRadialGradient(t/2,r-130,20,t/2,r-130,t*.55);i.addColorStop(0,`rgba(255,250,230,.28)`),i.addColorStop(1,`rgba(255,250,230,0)`),e.fillStyle=i,e.fillRect(0,0,t,n)},perspective:e=>(t,n,r)=>{t.strokeStyle=e.near,t.lineWidth=3;for(let e=-3;e<=3;e++)t.beginPath(),t.moveTo(n/2+e*n*.16,0),t.lineTo(n/2+e*n*.04,r),t.stroke()},shelves:e=>(t,n,r,i,a)=>{t.fillStyle=e.near;for(let i=0;i<3;i++){t.fillRect(n*.14,r*(.22+i*.1),n*.72,8*a);for(let o=0;o<8;o++)t.fillStyle=e.far,t.fillRect(n*(.16+o*.088),r*(.22+i*.1)-14*a,n*.05,14*a),t.fillStyle=e.near}},panels:e=>(t,n,r)=>{for(let i=0;i<6;i++)t.fillStyle=i%2?e.far:e.near,t.globalAlpha=.8,t.fillRect(n*(.15+i*.12),r*(.2+i%2*.05),n*.09,r*.14),t.globalAlpha=1},screens:e=>(t,n,r)=>{for(let i=0;i<8;i++)t.fillStyle=[e.skyTop,e.far,e.mid][i%3],t.globalAlpha=.8,t.fillRect(n*(.1+i%4*.21),r*(.18+Math.floor(i/4)*.16),n*.17,r*.12),t.globalAlpha=1},bench:e=>(t,n,r,i,a)=>{t.fillStyle=e.near,t.fillRect(n*.3,i-90*a,n*.4,60*a),t.fillStyle=e.far,t.fillRect(n*.44,r*.2,n*.12,r*.2)},beds:e=>(t,n,r,i,a)=>{for(let r=0;r<3;r++)t.fillStyle=e.near,t.fillRect(n*(.14+r*.28),i-44*a,n*.2,44*a),t.fillStyle=`#e8edf1`,t.fillRect(n*(.14+r*.28),i-44*a,n*.2,16*a)},columns:e=>(t,n,r,i,a)=>{for(let a=0;a<5;a++)t.fillStyle=e.far,t.fillRect(n*(.1+a*.2),r*.1,n*.05,i-r*.1);t.fillStyle=e.near,t.fillRect(n*.42,i-80*a,n*.16,80*a)}},IM=bM,LM=(e,t)=>Z(.16,(n,r,i,a,o,s=0)=>{let c=vk(`cl`+t);n.fillStyle=e.far;for(let e=0;e<6;e++){let t=c()*r+Math.sin(s*.1+e)*10,a=i*(.12+c()*.3),l=(24+c()*26)*o;n.globalAlpha=.85,n.beginPath(),n.arc(t,a,l,0,7),n.arc(t+l,a+4,l*.8,0,7),n.arc(t-l,a+4,l*.8,0,7),n.fill()}n.globalAlpha=1}),RM=(e,t)=>Z(.1,(n,r,i)=>{let a=vk(`st`+t);n.fillStyle=`#fdfbe8`;for(let e=0;e<90;e++)n.globalAlpha=.4+a()*.6,n.fillRect(a()*r,a()*i*.8,2,2);n.globalAlpha=1,n.fillStyle=e.near,n.beginPath(),n.arc(r*.76,i*.3,54,0,7),n.fill(),n.fillStyle=e.far,n.globalAlpha=.5,n.beginPath(),n.arc(r*.72,i*.26,54,0,7),n.fill(),n.globalAlpha=1}),zM=(e,t,n,r,i)=>Z(e,(e,t,a,o,s,c=0)=>{let l=vk(`cw`+n);e.fillStyle=r;for(let n=0;n<22;n++){let r=l()*(t+80)-40,a=(i+l()*20)*s,u=Math.sin(c*1.2+n)*2;e.fillRect(r+u,o-a,15*s,a),e.beginPath(),e.arc(r+u+7.5*s,o-a,9*s,0,7),e.fill()}}),BM=(e,t,n,r)=>Z(e,(e,i,a,o,s)=>{vk(`mk`+n);for(let n=0;n<r;n++){let a=40+i/r*n;e.fillStyle=[t.far,t.mid,t.near][n%3],e.fillRect(a,o-80*s,i/r*.7,18*s),e.fillStyle=t.near,e.fillRect(a+4*s,o-62*s,6*s,62*s),e.fillRect(a+i/r*.7-10*s,o-62*s,6*s,62*s)}}),VM={genericRoom:e=>NM(e,FM.window),office:e=>NM(e,FM.monitors),classroom:e=>NM(e,FM.board),workshop:e=>NM(e,FM.pegboard),kitchen:e=>NM(e,FM.counter),stagePodium:e=>NM(e,FM.spotlight),corridor:e=>NM(e,FM.perspective),storeInterior:e=>NM(e,FM.shelves),labGeneric:e=>NM(e,FM.panels),controlRoom:e=>NM(e,FM.screens),street:(e,t,n)=>PM(e,t,IM.city[0],IM.city[1],[`skyline`,60,90],e=>(e,t,n,r,i)=>{e.strokeStyle=`#e6c34a`,e.lineWidth=3*i,e.setLineDash([20*i,18*i]),e.beginPath(),e.moveTo(-500,r+(n-r)*.5),e.lineTo(t+500,r+(n-r)*.5),e.stroke(),e.setLineDash([])},n),park:(e,t,n)=>PM(e,t,IM.field[0],[`tree`,60,40],[`tree`,46,30],null,n),forest:(e,t,n)=>PM(e,t,[`tree`,70,50],[`tree`,60,44],[`tree`,50,34],null,n),mountain:(e,t,n)=>PM(e,t,IM.ridge[0],IM.ridge[1],IM.ridge[2],null,n),desertPlain:(e,t,n)=>PM(e,t,IM.dunes[0],IM.dunes[1],IM.dunes[2],null,n),coastBeach:(e,t,n)=>PM(e,t,IM.coast[0],[`water`,0,0],IM.coast[2],null,n),farmField:(e,t,n)=>PM(e,t,IM.field[0],IM.field[1],IM.field[2],e=>(t,n,r,i,a)=>{t.strokeStyle=e.near,t.lineWidth=2*a;for(let e=0;e<6;e++)t.beginPath(),t.moveTo(-500,i+e*18*a),t.lineTo(n+500,i+e*18*a),t.stroke()},n),skylineWide:(e,t,n)=>PM(e,t,[`skyline`,90,150],[`skyline`,110,130],[`skyline`,70,100],null,n),rooftop:(e,t,n)=>PM(e,t,[`skyline`,80,140],[`skyline`,100,120],[`skyline`,60,90],null,n),roadHighway:(e,t,n)=>PM(e,t,IM.field[0],[`rolling`,30,40],IM.field[2],e=>(e,t,n,r,i)=>{e.fillStyle=`#5c636e`,e.beginPath(),e.moveTo(t*.38,r),e.lineTo(t*.5,n),e.lineTo(t*.62,r),e.fill(),e.strokeStyle=`#eef2f4`,e.lineWidth=3*i,e.setLineDash([26*i,22*i]),e.beginPath(),e.moveTo(t*.5,r),e.lineTo(t*.5,n),e.stroke(),e.setLineDash([])},n),oceanSurface:(e,t,n)=>[mM(e),xM(IM.coast[0],.14,`f`+t,{col:e.far,bias:n}),yM(.4,e.mid),iM(e.ground)],underwater:(e,t)=>[MM(e.skyTop,e.occluder),Z(.2,(e,n,r)=>{let i=vk(`uw`+t);e.fillStyle=`rgba(255,255,255,.16)`;for(let t=0;t<26;t++)e.beginPath(),e.arc(i()*n,i()*r,2+i()*6,0,7),e.fill()}),iM(e.ground)],skyClouds:(e,t)=>[mM(e),LM(e,t),LM(e,t+`b`)],spacePlanet:(e,t)=>[MM(e.skyTop,e.skyBot),RM(e,t)],arcticIce:(e,t,n)=>PM(e,t,[`jagged`,90,120],[`jagged`,70,80],[`jagged`,50,40],null,n),studioPlain:e=>[MM(e.skyBot,yk(e.skyBot,.92))],gradientAbstract:e=>[MM(e.skyTop,e.mid,!0)],gridBoard:e=>[rM(e.skyBot),Z(.2,(e,t,n,r,i)=>{e.strokeStyle=`rgba(0,0,0,.08)`,e.lineWidth=1;for(let r=0;r<t;r+=40*i)e.beginPath(),e.moveTo(r,0),e.lineTo(r,n),e.stroke();for(let r=0;r<n;r+=40*i)e.beginPath(),e.moveTo(0,r),e.lineTo(t,r),e.stroke()})],mapStage:(e,t)=>[rM(e.skyBot),Z(.2,(n,r,i)=>{let a=vk(`mp`+t);n.fillStyle=e.mid,n.globalAlpha=.8,n.beginPath(),n.moveTo(r*.2,i*.3);for(let e=0;e<10;e++)n.lineTo(r*(.2+a()*.6),i*(.2+a()*.6));n.closePath(),n.fill(),n.globalAlpha=1})],chartStage:e=>[rM(e.skyBot),Z(.2,(t,n,r)=>{t.strokeStyle=e.near,t.lineWidth=2,t.beginPath(),t.moveTo(n*.15,r*.2),t.lineTo(n*.15,r*.8),t.lineTo(n*.85,r*.8),t.stroke()})],timelineBand:e=>[rM(e.skyBot),Z(.3,(t,n,r)=>{t.fillStyle=e.mid,t.globalAlpha=.5,t.fillRect(0,r*.46,n,r*.08),t.globalAlpha=1})],splitVersus:e=>[Z(0,(t,n,r)=>{t.fillStyle=e.skyTop,t.fillRect(0,0,n/2,r),t.fillStyle=e.mid,t.fillRect(n/2,0,n/2,r),t.strokeStyle=e.near,t.lineWidth=3,t.beginPath(),t.moveTo(n/2,0),t.lineTo(n/2,r),t.stroke()})],iconField:(e,t)=>[rM(e.skyBot),Z(.2,(n,r,i)=>{let a=vk(`if`+t);n.fillStyle=e.mid,n.globalAlpha=.4;for(let e=0;e<24;e++)n.beginPath(),n.arc(a()*r,a()*i,10,0,7),n.fill();n.globalAlpha=1})],blueprint:e=>[rM(e.occluder),Z(.2,(e,t,n,r,i)=>{e.strokeStyle=`rgba(255,255,255,.22)`,e.lineWidth=1;for(let r=0;r<t;r+=34*i)e.beginPath(),e.moveTo(r,0),e.lineTo(r,n),e.stroke();for(let r=0;r<n;r+=34*i)e.beginPath(),e.moveTo(0,r),e.lineTo(t,r),e.stroke()})],spotlightDark:e=>[rM(e.occluder),Z(.1,(e,t,n,r)=>{let i=e.createRadialGradient(t/2,r-120,30,t/2,r-120,t*.6);i.addColorStop(0,`rgba(255,255,255,.16)`),i.addColorStop(1,`rgba(255,255,255,0)`),e.fillStyle=i,e.fillRect(0,0,t,n)}),iM(e.near)],crowdScene:(e,t)=>[mM(e),zM(.2,e,t+`a`,e.far,40),iM(e.ground),zM(.55,e,t+`b`,e.near,54)],marketplace:(e,t,n)=>[mM(e),xM([`skyline`,60,80],.14,`f`+t,{col:e.far,bias:n}),iM(e.ground),BM(.5,e,t,5)],constructionSite:(e,t,n)=>[mM(e),xM([`skyline`,70,110],.14,`f`+t,{col:e.far,bias:n}),iM(e.ground),Z(.5,(e,t,n,r,i)=>{e.strokeStyle=`#e0a52e`,e.lineWidth=6*i,e.strokeRect(t*.3,r-200*i,6*i,200*i),e.beginPath(),e.moveTo(t*.3,r-200*i),e.lineTo(t*.58,r-200*i),e.stroke(),e.beginPath(),e.moveTo(t*.55,r-200*i),e.lineTo(t*.55,r-120*i),e.stroke()})],harborDock:(e,t,n)=>[mM(e),xM([`skyline`,60,90],.14,`f`+t,{col:e.far,bias:n}),yM(.4,e.mid),iM(e.ground)],weatherStorm:(e,t)=>[MM(e.occluder,e.mid),Z(.2,(e,n,r)=>{let i=vk(`ws`+t);e.strokeStyle=`rgba(220,230,240,.35)`,e.lineWidth=2;for(let t=0;t<50;t++){let t=i()*n,a=i()*r;e.beginPath(),e.moveTo(t,a),e.lineTo(t-6,a+18),e.stroke()}}),iM(e.near)],stadium:(e,t)=>[mM(e),Z(.14,(t,n,r,i,a)=>{t.fillStyle=e.far;for(let e=0;e<4;e++)t.fillRect(-500,i-(140-e*30)*a,n+1e3,26*a)}),zM(.3,e,t,e.mid,18),iM(e.ground)],courtroomGeneric:e=>NM(e,FM.bench),hospitalWard:e=>NM(e,FM.beds),throneHall:e=>NM(e,FM.columns),cave:e=>[rM(e.occluder),Z(.2,(t,n,r,i)=>{let a=t.createRadialGradient(n/2,i-80,40,n/2,i-80,n*.5);a.addColorStop(0,e.skyBot),a.addColorStop(1,e.occluder),t.fillStyle=a,t.beginPath(),t.ellipse(n/2,i-40,n*.3,r*.4,0,0,7),t.fill()}),iM(e.near)],ruins:(e,t,n)=>[mM(e),xM([`rolling`,50,90],.14,`f`+t,{col:e.far,bias:n}),Z(.4,(n,r,i,a,o)=>{let s=vk(`ru`+t);n.fillStyle=e.mid;for(let e=0;e<5;e++){let t=(60+s()*90)*o;n.fillRect(r*(.12+e*.19),a-t,20*o,t)}}),iM(e.ground)],rooftopNight:(e,t,n)=>PM(e,t,[`skyline`,100,160],[`skyline`,120,140],[`skyline`,70,100],null,n),marketStreetDense:(e,t)=>[mM(e),xM([`skyline`,70,110],.14,`f`+t,{col:e.far}),BM(.3,e,t+`a`,6),iM(e.ground),BM(.58,e,t+`b`,4)]},HM=Object.keys(VM),Object.keys(VM).forEach(e=>{let t=VM[e];tM[e]=(n=7,r=`day`)=>{let i=cM[r]||cM.day,a=(EM[e]||{}).bias||0;return[...t(i,`:`+r+n,a),...DM(e,i)]}}),UM=e=>Object.prototype.hasOwnProperty.call(VM,e)||Object.prototype.hasOwnProperty.call(OM,e),Object.assign(tM,{mapBoard:Sj,warRoomTable:Cj}),WM=[`groundL`,`groundC`,`groundR`,`midL`,`midR`,`skyL`,`skyR`,`skyBand`],GM={plain:[`center.c`],skyDay:[`sky.c`,`ground.c`],skyNight:[`sky.c`,`ground.c`],city:[`ground.c`,`wall.a`,`wall.b`],nature:[`ground.c`,`tree.a`],interior:[`wall.a`,`wall.b`,`wall.c`,`table.c`],abstract:[`center.c`],dioramaDay:WM,dioramaDusk:WM,dioramaNight:WM,dioramaDesert:WM,dioramaArctic:WM,mapBoard:[`center.c`],warRoomTable:[`tableFrontL`,`tableFrontR`,`tableBack`,`tableMap`]},kM.forEach(e=>{GM[e]=WM}),HM.forEach(e=>{GM[e]=WM}),KM={plain:`light`,skyDay:`light`,skyNight:`dark`,city:`light`,nature:`light`,interior:`light`,abstract:`dark`,stagePodium:`dark`,controlRoom:`dark`,underwater:`dark`,spacePlanet:`dark`,blueprint:`dark`,spotlightDark:`dark`,weatherStorm:`dark`,gradientAbstract:`dark`,dioramaDay:`light`,dioramaDusk:`light`,dioramaNight:`dark`,dioramaDesert:`light`,dioramaArctic:`light`,mapBoard:`dark`,warRoomTable:`dark`},qM={"center.c":{x:.5,y:300,z:.5},"ground.c":{x:.5,y:520,z:.5},"table.c":{x:.5,y:470,z:.42},"wall.a":{x:.28,y:180,z:.62},"wall.b":{x:.5,y:168,z:.62},"wall.c":{x:.72,y:180,z:.62},"sky.c":{x:.5,y:120,z:.85},"tree.a":{x:.72,y:430,z:.55},left:{x:.2,y:300,z:.5},right:{x:.8,y:300,z:.5},hover:{x:.5,y:250,z:.5},lowerThird:{x:.5,y:500,z:.5},skyBand:{x:.5,y:110,z:.9},groundL:{x:.22,y:500,z:.45},groundC:{x:.5,y:500,z:.45},groundR:{x:.78,y:500,z:.45},midL:{x:.3,y:430,z:.62},midR:{x:.7,y:430,z:.62},skyL:{x:.28,y:150,z:.82},skyR:{x:.72,y:150,z:.82},tableFrontL:{x:.4,y:560,z:.42},tableFrontR:{x:.6,y:560,z:.42},tableBack:{x:.5,y:470,z:.6},tableMap:{x:.5,y:500,z:.45}},JM=[`center.c`,`ground.c`,`left`,`right`],YM=Object.keys(tM),XM=e=>Object.prototype.hasOwnProperty.call(tM,e)||Wj(e),ZM=e=>e<=.12?`sky`:e<=.3?`back`:e<=.5?`mid`:`near`}));function $M(e,t,n){let r=typeof e==`string`?e:e&&e.type,i=sN[r];return i?i(typeof e==`object`?e:{type:r},t,n):``}var eN,tN,nN,rN,iN,aN,oN,sN,cN=o((()=>{Tk(),eN=640,tN=Math.sin,nN=Math.cos,rN=Math.floor,iN=e=>{let t=tN(e*127.1)*43758.5453;return t-rN(t)},aN=[`rain`,`snow`,`wind`,`fog`,`heatShimmer`,`lightning`],oN=e=>e.intensity===`storm`||typeof e.intensity==`number`&&e.intensity>.6,sN={rain(e,t,n){let r=oN(e),i=r?92:54,a=r?34:24,o=r?1180:820,s=r?9:4,c=``;for(let e=0;e<i;e++){let r=iN(e)*(n+80)-40,i=(iN(e+9)*700+t*o)%700-30,l=r+i/eN*s*3;c+=`M${l.toFixed(1)} ${i.toFixed(1)} l${s} ${a} `}let l=``;for(let e=0;e<(r?16:9);e++){let r=iN(e+40)*n,i=(t*3+iN(e+40)*5)%1,a=i*11;l+=`<circle cx="${r.toFixed(1)}" cy="598" r="${a.toFixed(1)}" fill="none" stroke="rgba(200,220,235,${(.5*(1-i)).toFixed(2)})" stroke-width="1.5"/>`}return`${r?`<rect x="0" y="0" width="${n}" height="${eN}" fill="#20303f" opacity="0.16"/>`:``}<path d="${c}" stroke="rgba(190,214,232,${r?.52:.4})" stroke-width="${r?2:1.5}" stroke-linecap="round"/>${l}`},snow(e,t,n){let r=oN(e)?96:68,i=``;for(let e=0;e<r;e++){let r=(iN(e+3)*680+t*(56+iN(e)*64))%680-20,a=iN(e+7)*n+tN(t*(.6+iN(e))+e)*18,o=1.5+iN(e+5)*2.4;i+=`<circle cx="${a.toFixed(1)}" cy="${r.toFixed(1)}" r="${o.toFixed(1)}" fill="rgba(255,255,255,${(.55+iN(e+1)*.4).toFixed(2)})"/>`}return`<rect x="0" y="0" width="${n}" height="${eN}" fill="#dfeaf2" opacity="0.10"/><rect x="0" y="614" width="${n}" height="26" fill="#f2f7fb" opacity="0.5"/>${i}`},wind(e,t,n){let r=n+140,i=``;for(let e=0;e<28;e++){let n=(iN(e+2)*r+t*(250+iN(e)*180))%r-70,a=110+iN(e+4)*410+tN(t*3+e)*16,o=(t*200+e*63)%360;i+=`<g transform="translate(${n.toFixed(1)} ${a.toFixed(1)}) rotate(${o.toFixed(0)})"><path d="M0 0 q6 -5 12 0 q-6 5 -12 0Z" fill="${[`#c98b52`,`#9bb06a`,`#b9863f`][e%3]}" opacity="0.85"/></g>`}let a=``;for(let e=0;e<6;e++){let r=90+eN/7*e,i=(t*420+e*210)%(n+320)-160;a+=`<path d="M${i.toFixed(1)} ${r.toFixed(1)} q60 -8 140 0" stroke="rgba(232,237,242,0.22)" stroke-width="2" fill="none"/>`}return a+i},fog(e,t,n){let r=tN(t*.3)*34,i=nN(t*.22)*44,a=oN(e)?.4:.28;return`<rect x="0" y="0" width="${n}" height="${eN}" fill="#c9d4dc" opacity="${a.toFixed(2)}"/><ellipse cx="${(n*.35+r).toFixed(1)}" cy="${eN*.72}" rx="${(n*.6).toFixed(0)}" ry="120" fill="#dde5eb" opacity="0.35"/><ellipse cx="${(n*.7+i).toFixed(1)}" cy="${eN*.86}" rx="${(n*.7).toFixed(0)}" ry="150" fill="#eef3f6" opacity="0.4"/>`},heatShimmer(e,t,n){let r=``;for(let e=0;e<9;e++){let i=eN*.48+e*18,a=tN(t*3+e*.7)*7;r+=`<rect x="${a.toFixed(1)}" y="${i.toFixed(0)}" width="${n}" height="11" fill="rgba(255,246,214,0.06)"/>`}return r},lightning(e,t,n){let r=3.2,i=t%r/r;if(i>.16)return``;let a=Y(i<.05?i/.05:1-(i-.05)/.11,0,1),o=``;if(i<.09){let e=n*(.3+iN(rN(t/r))*.4),i=`M${e.toFixed(1)} 0`,s=0,c=e;for(;s<eN*.62;)s+=40+iN(s)*30,c+=(iN(s+1)-.5)*64,i+=` L${c.toFixed(1)} ${s.toFixed(1)}`;o=`<path d="${i}" stroke="#fdfbef" stroke-width="3" fill="none" opacity="${a.toFixed(2)}"/>`}return`<rect x="0" y="0" width="${n}" height="${eN}" fill="#f4f2e2" opacity="${(a*.5).toFixed(2)}"/>${o}`}}}));function lN(e){let t=e>>>0;return function(){t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function uN(e,t,n,r,i){let a=i*i,o=a*i;return .5*(2*t+(-e+n)*i+(2*e-5*t+4*n-r)*a+(-e+3*t-3*n+r)*o)}function dN(e,t,n,r){let i=e[Math.max(0,t-1)][r],a=e[t][r],o=e[Math.min(e.length-1,t+1)][r],s=e[Math.min(e.length-1,t+2)][r];return uN(i,a,o,s,n)}function fN(e,t){let n=[...e].sort((e,t)=>e.time-t.time);if(!n.length)throw Error(`PanMaster requires at least one camera point.`);return n[0].time>0&&n.unshift({...n[0],time:0}),n[n.length-1].time<t&&n.push({...n[n.length-1],time:t}),n.map((e,t)=>({time:e.time,x:e.x??0,y:e.y??0,scale:e.scale??1,rotation:e.rotation??0,subjectId:e.subjectId??null,ease:e.ease||`smoother`,index:t}))}function pN({duration:e=5,subjects:t=[],seed:n=1,viewW:r=1920,viewH:i=1080,worldW:a=2800,worldH:o=1700,style:s=`editorial`,styleCustom:c=null}={}){let l=lN(n),u=r*.22,d=i*.2,f={editorial:{zoom:[1,1.22],rot:[-1.2,1.2],wander:150},calm:{zoom:[1.02,1.14],rot:[-.6,.6],wander:90},energetic:{zoom:[1.04,1.32],rot:[-2.2,2.2],wander:210},dramatic:{zoom:[1.08,1.42],rot:[-2.8,2.8],wander:170}},p=s===`custom`&&c?{zoom:c.zoom,rot:c.rot,wander:c.wander}:f[s]||f.editorial,m=t.length?t:[{id:`center`,x:a/2,y:o/2,importance:1}],h=Math.max(4,Math.min(7,Math.round(e*1.05))),g=[];for(let t=0;t<h;t++){let n=t/(h-1),r=m[t%m.length],i=t%2==0?1:-1,s=Math.sin(n*Math.PI*1.7)*p.wander*i,c=(l()-.5)*p.wander*.55,f=(l()-.5)*p.wander*.38,_=yN(r.x+s+c,u,a-u),v=yN(r.y+Math.cos(n*Math.PI*1.6)*p.wander*.42+f,d,o-d),y=Math.sin(n*Math.PI*2.1)*.5+.5,b=bN(p.zoom[0],p.zoom[1],.28+.72*y)*(r.importance||1),x=bN(p.rot[0],p.rot[1],l());g.push({time:n*e,x:_,y:v,scale:b,rotation:x,subjectId:r.id})}return g[0].scale=Math.min(g[0].scale,1.08),g[g.length-1].rotation*=.25,{duration:e,points:fN(g,e),viewW:r,viewH:i,worldW:a,worldH:o,seed:n,style:s}}function mN(e,t){let n=e.points,r=e.duration,i=yN(t,0,r),a=0;for(;a<n.length-2&&i>n[a+1].time;)a++;let o=n[a],s=n[Math.min(a+1,n.length-1)],c=Math.max(1e-4,s.time-o.time),l=yN((i-o.time)/c);return l=o.ease===`linear`?l:o.ease===`smooth`?xN(l):SN(l),{x:dN(n,a,l,`x`),y:dN(n,a,l,`y`),scale:dN(n,a,l,`scale`),rotation:dN(n,a,l,`rotation`),subjectId:l<.5?o.subjectId:s.subjectId,progress:i/r}}function hN(e,t=1,n=1920,r=1080){let i=yN(t,0,1.6),a=1+(e.scale-1)*i,o=bN(n/2,e.x,i),s=bN(r/2,e.y,i),c=e.rotation*i*.55;return`translate(${n/2} ${r/2}) rotate(${-c}) scale(${a}) translate(${-o} ${-s})`}function gN({duration:e,points:t=[],viewW:n=1920,viewH:r=1080,worldW:i=2800,worldH:a=1700,zoomMin:o=CN,zoomMax:s=3}){let c=[];for(let e of t){let t=yN(e.zoom==null?e.scale==null?1:e.scale:e.zoom,o,s),n={time:e.time,x:e.x,y:e.y,scale:t,rotation:e.rotation||0,ease:e.ease||`smoother`,subjectId:e.subjectId??null};c.push(n),e.hold&&c.push({...n,time:e.time+e.hold})}let l=e??Math.max(...c.map(e=>e.time),.001);return{duration:l,points:fN(c,l),viewW:n,viewH:r,worldW:i,worldH:a,mode:`manual`}}function _N(e,t=[]){let n=pN(e),r=n.points.map(e=>({time:e.time,x:e.x,y:e.y,zoom:e.scale,rotation:e.rotation,ease:e.ease,subjectId:e.subjectId}));return t.forEach(e=>{e.index!=null&&r[e.index]&&Object.assign(r[e.index],e)}),gN({duration:n.duration,points:r,viewW:n.viewW,viewH:n.viewH,worldW:n.worldW,worldH:n.worldH})}function vN(e,t={}){let n=t.worldW==null?e.worldW||2800:t.worldW,r=t.worldH==null?e.worldH||1700:t.worldH,i=t.viewW==null?e.viewW||1920:t.viewW,a=t.viewH==null?e.viewH||1080:t.viewH,o=e.duration==null?t.duration:e.duration;return e.mode===`manual`?gN({duration:o,points:e.points||[],viewW:i,viewH:a,worldW:n,worldH:r,zoomMin:e.zoomMin,zoomMax:e.zoomMax}):e.mode===`hybrid`?_N({duration:o,subjects:e.subjects||t.subjects||[],seed:e.seed||1,viewW:i,viewH:a,worldW:n,worldH:r,style:e.style||`editorial`,styleCustom:e.styleCustom},e.edits||[]):pN({duration:o,subjects:e.subjects||t.subjects||[],seed:e.seed||1,viewW:i,viewH:a,worldW:n,worldH:r,style:e.style||`editorial`,styleCustom:e.styleCustom})}var yN,bN,xN,SN,CN,wN=o((()=>{yN=(e,t=0,n=1)=>Math.max(t,Math.min(n,e)),bN=(e,t,n)=>e+(t-e)*n,xN=e=>e*e*(3-2*e),SN=e=>e*e*e*(e*(e*6-15)+10),CN=.5}));function TN(e){let t=e.type,n=UN.includes(t)?null:e.swapWindow||JN[t]||[.45,.55];return{type:t,durationMs:e.durationMs==null?1200:e.durationMs,ease:WN.includes(e.ease)?e.ease:`smoother`,direction:e.direction||YN[t]||`L2R`,colorMode:e.colorMode||`bridge`,colors:e.colors||[],swapWindow:n,carrySubject:e.carrySubject||null,params:{...qN[t]||{},...e.params||{}}}}function EN(e,t,n=0){let r=t.bridge&&t.bridge[0]||`#141c24`,i=t.bridge&&t.bridge[1]||`#0d1220`;return e.colorMode===`custom`&&e.colors.length?e.colors[FN(n,e.colors.length-1)]:e.colorMode===`token`?`#0d1220`:e.colorMode===`incoming`?i:bk(r,i,.5)}function DN(e,t,n){let r=t>0?Y(e/t,0,1):1,i=n<1?Y((e-n)/(1-n),0,1):0;return FN(r,1-i)}function ON(e,t,n,r,i,a=1){return`<rect x="${e.toFixed(1)}" y="${t.toFixed(1)}" width="${n.toFixed(1)}" height="${r.toFixed(1)}" fill="${i}" opacity="${a}"/>`}function kN(e,t,n,r){if(!e.carrySubject)return null;let i=n.subjectFrom||{x:r*.5,y:Q*.6},a=n.subjectTo||{x:r*.5,y:Q*.6};return{x:xk(i.x,a.x,t),y:xk(i.y,a.y,t)}}function AN(e,t,n={}){let r=TN(e),i=n.VBW||1138,a=Y(t,0,1),o=KN[r.ease](a),s=XN[r.type],c=s?s(r,o,a,n,i):{svg:``,alpha:0},l,u,d=1,f=1,p=null,m=null,h=null,g=null;if(r.swapWindow)h=r.swapWindow[0],l=a<h,u=a>=h;else if(r.type===`fade`)l=!0,u=!0,d=1-o,f=o;else{l=!0,u=!0;let e=r.direction===`R2L`||r.direction===`B2T`?-1:1,t=(eP[r.type]||eP.carryTravel)(o,e,i,Q,r.params,n.subject);p=t.fromT,m=t.toT,g={blur:t.blur||0,flip:!!t.flip,split:t.split,axis:t.axis,over:!!t.over,shadow:!!t.shadow,dir:e},t.flip&&(l=a<.5,u=a>=.5)}return{resolved:r,cover:c.svg,coverAlpha:c.alpha,fromShown:l,toShown:u,fromOpacity:d,toOpacity:f,fromTransform:p,toTransform:m,motion:g,swapWindow:r.swapWindow,swapAt:h,subject:kN(r,o,n,i)}}var Q,jN,MN,NN,PN,FN,IN,LN,RN,zN,BN,VN,HN,UN,WN,GN,KN,qN,JN,YN,XN,ZN,QN,$N,eP,tP=o((()=>{Tk(),Q=640,jN=Math.sin,MN=Math.cos,NN=Math.PI,PN=Math.hypot,FN=Math.min,IN=Math.max,LN=.1,RN=[`fade`,`irisObject`,`strokeSweep`,`slabWipe`,`curtainFall`,`lightWash`,`bandWipe`,`carryTravel`],zN=[`blindsFlip`,`checkerFlip`,`inkBlot`,`smokeConceal`,`particleStorm`,`paperTear`,`shapeStampede`,`typeMask`,`silhouetteWalkWipe`,`pushOff`,`slideOver`,`splitBarn`,`whipPan`,`spinCard`,`zoomThrough`,`pullBackReveal`,`elevatorRise`],BN=[`flashImpact`,`dipToColor`,`silhouettePass`,`dayNightSweep`,`spotlightShift`,`matchMorph`,`pixelMosaic`,`lineArtRebuild`,`stackShuffle`,`ripplePortal`,`doorPass`,`waveCrash`,`pageFlip`,`lightSpeedStreak`,`glitchCut`],VN=[...RN,...zN,...BN],HN=[`carryTravel`,`pushOff`,`slideOver`,`splitBarn`,`whipPan`,`spinCard`,`zoomThrough`,`pullBackReveal`,`elevatorRise`,`stackShuffle`],UN=[`fade`,...HN],WN=[`linear`,`smooth`,`smoother`],GN=e=>VN.includes(e),KN={linear:e=>e,smooth:e=>e*e*(3-2*e),smoother:e=>e*e*e*(e*(e*6-15)+10)},qN={fade:{mode:`direct`},irisObject:{shape:`circle`,origin:`center`,grow:`out`},strokeSweep:{pathPreset:`arc`,glow:!0},slabWipe:{edge:`straight`},curtainFall:{pairedPaletteShift:!0},lightWash:{mode:`radial`,origin:`center`},bandWipe:{bands:3,staggerPct:.08,slantDeg:14,edgeProfile:`straight`},carryTravel:{vector:`L2R`,ms:1200},blindsFlip:{slats:8,axis:`h`},checkerFlip:{grid:6,order:`sweep`},inkBlot:{blobs:3,wobble:.25},smokeConceal:{density:1},particleStorm:{particleType:`confetti`},paperTear:{tearJaggedness:22},shapeStampede:{iconRef:`coin`,count:40},typeMask:{text:`NEXT`},silhouetteWalkWipe:{castRef:null,scale:1,action:`walk`},pushOff:{},slideOver:{shadowEdge:!0},splitBarn:{axis:`v`},whipPan:{blurPx:9},spinCard:{axis:`y`,perspectiveFake:!0},zoomThrough:{targetElement:null,overshoot:1},pullBackReveal:{frameElement:null},elevatorRise:{},flashImpact:{tint:`#ffffff`},dipToColor:{color:null,holdMs:200},silhouettePass:{holdMs:200},dayNightSweep:{},spotlightShift:{origin:`subject`},matchMorph:{fromRef:null,toRef:null},pixelMosaic:{blockPx:48,order:`random`},lineArtRebuild:{strokeColor:`#243038`},stackShuffle:{cardShadow:!0},ripplePortal:{origin:`center`,rings:5},doorPass:{portalElement:null},waveCrash:{foam:!0},pageFlip:{corner:`tr`},lightSpeedStreak:{streakColor:`#bcd4ff`},glitchCut:{intensity:1}},JN={irisObject:[.42,.58],strokeSweep:[.44,.56],slabWipe:[.46,.56],curtainFall:[.46,.56],lightWash:[.42,.58],bandWipe:[.48,.62]},YN={curtainFall:`T2B`,bandWipe:`L2R`,slabWipe:`L2R`,carryTravel:`L2R`},XN={fade(e,t,n,r,i){if(e.params.mode===`toColor`){let t=jN(Y(n,0,1)*NN),a=i*LN;return{svg:ON(-a,-64,i+2*a,768,e.colors[0]||EN(e,r),t),alpha:t}}return{svg:``,alpha:0}},irisObject(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=DN(n,a,o),c=EN(e,r),l=e.params.origin===`subject`&&r.subject?r.subject:{x:i/2,y:Q/2},u=PN(i,Q)*.5*1.2,d=(e.params.grow===`in`?1-s:s)*u;if(e.params.shape!==`circle`){let e=d/120;return{svg:`<path transform="translate(${l.x.toFixed(1)} ${l.y.toFixed(1)}) scale(${e.toFixed(3)})" d="M0 -120 C70 -120 120 -60 120 10 C120 80 60 120 0 120 C-60 120 -120 80 -120 10 C-120 -60 -70 -120 0 -120 Z" fill="${c}"/>`,alpha:s}}return{svg:`<circle cx="${l.x.toFixed(1)}" cy="${l.y.toFixed(1)}" r="${d.toFixed(1)}" fill="${c}"/>`,alpha:s}},strokeSweep(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=DN(n,a,o),c=EN(e,r),l=s*PN(i,Q)*1.15,u=e.params.pathPreset,d=u===`S`?`M -60 ${Q*.2} C ${i*.4} 0, ${i*.6} ${Q} , ${i+60} ${Q*.8}`:u===`bolt`?`M -60 ${Q*.1} L ${i*.45} ${Q*.5} L ${i*.35} ${Q*.55} L ${i+60} ${Q*.95}`:u===`wave`?`M -60 ${Q/2} Q ${i*.25} ${Q*.1}, ${i*.5} ${Q/2} T ${i+60} ${Q/2}`:`M -60 ${Q*.85} Q ${i/2} -224, ${i+60} ${Q*.85}`;return{svg:(e.params.glow?`<path d="${d}" fill="none" stroke="${c}" stroke-width="${(l*1.25).toFixed(1)}" stroke-linecap="round" opacity="0.35"/>`:``)+`<path d="${d}" fill="none" stroke="${c}" stroke-width="${l.toFixed(1)}" stroke-linecap="round"/>`,alpha:s}},slabWipe(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=EN(e,r),u=e.direction!==`T2B`&&e.direction!==`B2T`,d=e.direction===`R2L`||e.direction===`B2T`,f=s,p=c,m=d?1-f:p,h=d?1-p:f,g=e.params.edge===`rounded`?26:0,_=i*LN,v=f-p;if(u){let e=m<=1e-6?-_:m*i,t=h>=1-1e-6?i+_:h*i;return{svg:`<rect x="${e.toFixed(1)}" y="${(-64).toFixed(1)}" width="${(t-e).toFixed(1)}" height="${768 .toFixed(1)}" rx="${g}" fill="${l}"/>`,alpha:v}}let y=m<=1e-6?-64:m*Q,b=h>=1-1e-6?704:h*Q;return{svg:`<rect x="${(-_).toFixed(1)}" y="${y.toFixed(1)}" width="${(i+2*_).toFixed(1)}" height="${(b-y).toFixed(1)}" rx="${g}" fill="${l}"/>`,alpha:v}},curtainFall(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=e.direction===`B2T`,u=e.params.pairedPaletteShift?bk(EN(e,r),`#0a1020`,.4):EN(e,r),d=s,f=c,p=l?1-d:f,m=l?1-f:d,h=i*LN,g=p<=1e-6?-64:p*Q,_=m>=1-1e-6?704:m*Q;return{svg:`<rect x="${(-h).toFixed(1)}" y="${FN(g,_).toFixed(1)}" width="${(i+2*h).toFixed(1)}" height="${Math.abs(_-g).toFixed(1)}" fill="${u}"/>`,alpha:s-c}},lightWash(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=DN(n,a,o),c=e.colors[0]||EN(e,r),l=i*LN;if(e.params.mode===`linear`)return{svg:ON(-l,-64,i+2*l,768,c,s),alpha:s};let u=e.params.origin===`subject`&&r.subject?r.subject:{x:i/2,y:Q/2},d=PN(i,Q)*(.34+.75*s);return{svg:`<defs><radialGradient id="lw" cx="${(u.x/i).toFixed(3)}" cy="${(u.y/Q).toFixed(3)}" r="0.8"><stop offset="0" stop-color="${c}" stop-opacity="${s.toFixed(3)}"/><stop offset="1" stop-color="${c}" stop-opacity="${(s*s).toFixed(3)}"/></radialGradient></defs><circle cx="${u.x.toFixed(1)}" cy="${u.y.toFixed(1)}" r="${d.toFixed(1)}" fill="url(#lw)"/>${ON(-l,-64,i+2*l,768,c,s*s*.9)}`,alpha:s}},bandWipe(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=Y(e.params.bands|0||3,2,5),c=e.params.staggerPct||.08,l=(e.params.slantDeg||0)*NN/180,u=Math.tan(l)*Q,d=o<1?Y((n-o)/(1-o),0,1):0,f=r.bridge&&r.bridge[0]||`#141c24`,p=r.bridge&&r.bridge[1]||`#0d1220`,m=i*LN,h=768/s,g=``,_=1;for(let t=0;t<s;t++){let r=t*c,o=a-r>0?Y((n-r)/(a-r),0,1):1,l=FN(o,1-d);_=FN(_,l);let v=e.direction===`R2L`?-1:1,y=l*(i+2*m+Math.abs(u)),b=bk(f,p,s>1?t/(s-1):.5),x=v>0?-m-Math.abs(u):i+m-y+Math.abs(u),S=-64+t*h;g+=`<path d="M ${x.toFixed(1)} ${S.toFixed(1)} l ${y.toFixed(1)} 0 l ${u.toFixed(1)} ${h.toFixed(1)} l ${(-y).toFixed(1)} 0 Z" fill="${b}"/>`}return{svg:g,alpha:_}},carryTravel(e,t,n,r,i){return{svg:``,alpha:0}}},ZN=e=>{let t=jN(e*91.7)*43758.5453;return t-Math.floor(t)},QN=(e,t,n,r,i,a=1,o=0)=>`<rect x="${e.toFixed(1)}" y="${t.toFixed(1)}" width="${n.toFixed(1)}" height="${r.toFixed(1)}" rx="${o}" fill="${i}" opacity="${a}"/>`,Object.assign(XN,{blindsFlip(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=Y(e.params.slats||8,4,16),c=(e.params.axis||`h`)!==`v`,l=i*LN,u=``,d=(c?768:i+2*l)/s;for(let e=0;e<s;e++){let t=d*a;u+=c?QN(-l,-64+e*d+d/2-t/2,i+2*l,t,o):QN(-l+e*d+d/2-t/2,-64,t,768,o)}return{svg:u,alpha:a}},checkerFlip(e,t,n,r,i){let a=EN(e,r),o=Y(e.params.grid||6,3,10),s=i/o,c=Q/o,l=DN(n,e.swapWindow[0],e.swapWindow[1]),u=``,d=1;for(let t=0;t<o;t++)for(let n=0;n<o;n++){let r=e.params.order===`spiral`?(Math.abs(n-(o-1)/2)+Math.abs(t-(o-1)/2))/o:e.params.order===`random`?ZN(n*7+t*13+1):(n+t)/(2*o),i=Y(l*1.7-r*.7,0,1);d=FN(d,i),u+=QN(n*s+s/2-s*i/2,t*c+c/2-c*i/2,s*i,c*i,a)}return{svg:u,alpha:d}},inkBlot(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=Y(e.params.blobs||3,1,6),c=e.params.wobble==null?.25:e.params.wobble,l=QN(-i*LN,-640*LN,i*1.2,Q*1.2,o,a*a*.5);for(let e=0;e<s;e++){let t=i*(.2+.6*ZN(e+1)),n=Q*(.25+.5*ZN(e+5)),r=a*PN(i,Q)*.5,s=`M ${(t+r).toFixed(1)} ${n.toFixed(1)}`;for(let i=1;i<=12;i++){let a=i/12*2*NN,o=r*(1+c*(ZN(e*20+i)-.5));s+=` L ${(t+MN(a)*o).toFixed(1)} ${(n+jN(a)*o).toFixed(1)}`}l+=`<path d="${s} Z" fill="${o}"/>`}return{svg:l,alpha:a}},smokeConceal(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=``;for(let e=0;e<14;e++){let t=i*ZN(e+2),n=Q*ZN(e+8),r=a*PN(i,Q)*(.24+.14*ZN(e));s+=`<circle cx="${t.toFixed(1)}" cy="${n.toFixed(1)}" r="${r.toFixed(1)}" fill="${o}" opacity="${(.5+.5*a).toFixed(2)}"/>`}return{svg:s+QN(-i*LN,-640*LN,i*1.2,Q*1.2,o,a*a),alpha:a}},particleStorm(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=Math.round(120*a),s=e.params.particleType===`snow`?[`#fff`,`#e8eef4`]:e.params.particleType===`debris`?[`#6b5a44`,`#413424`]:[EN(e,r),`#f2b134`,`#ff6b5e`,`#5b6ce0`],c=QN(-i*LN,-640*LN,i*1.2,Q*1.2,EN(e,r),a*a*.85);for(let e=0;e<o;e++){let t=i*ZN(e+1),n=Q*ZN(e*3+2),r=4+5*ZN(e);c+=QN(t,n,r,r,s[e%s.length],.9,2)}return{svg:c,alpha:a}},paperTear(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=EN(e,r),u=e.params.tearJaggedness==null?22:e.params.tearJaggedness,d=e.direction===`R2L`,f=(d?1-s:s)*i,p=d?`M ${i+i*LN} ${-640*LN} L ${f} ${-640*LN}`:`M ${-i*LN} ${-640*LN} L ${f} ${-640*LN}`;for(let e=0;e<=Q;e+=24)p+=` L ${(f+(ZN(e)-.5)*u).toFixed(1)} ${e}`;return p+=d?` L ${i+i*LN} 704 Z`:` L ${-i*LN} 704 Z`,{svg:`<path d="${p}" fill="${l}"/>`,alpha:s-c}},shapeStampede(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=e.params.iconRef||`coin`,c=Math.round((e.params.count||40)*a),l=QN(-i*LN,-640*LN,i*1.2,Q*1.2,o,a*a*.7);for(let e=0;e<c;e++){let t=i*ZN(e+1),n=Q*ZN(e*5+3),r=14+8*ZN(e);l+=s===`star`?`<path transform="translate(${t.toFixed(0)} ${n.toFixed(0)})" d="M0 -${r} L${r*.3} -${r*.3} L${r} 0 L${r*.3} ${r*.3} L0 ${r} L-${r*.3} ${r*.3} L-${r} 0 L-${r*.3} -${r*.3} Z" fill="#f2b134"/>`:`<circle cx="${t.toFixed(0)}" cy="${n.toFixed(0)}" r="${r.toFixed(0)}" fill="#f2b134" stroke="${$N(o)}" stroke-width="2"/>`}return{svg:l,alpha:a}},typeMask(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=e.params.text||`NEXT`,c=e.direction===`R2L`?-1:1,l=i/2+c*(1-a)*i*.7;return{svg:QN(-i*LN,-640*LN,i*1.2,Q*1.2,o,a*a)+`<text x="${l.toFixed(1)}" y="${(Q*.62).toFixed(0)}" text-anchor="middle" font-family="Nunito,system-ui" font-weight="900" font-size="${(Q*.7*(.6+.4*a)).toFixed(0)}" fill="${o}">${s}</text>`,alpha:a}},silhouetteWalkWipe(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=EN(e,r),u=(e.direction===`R2L`?-1:1)>0?-i*.4+s*i*1.4:i*1.4-s*i*1.4,d=i*.9;return{svg:(s>=1&&c<1?QN(-i*LN,-640*LN,i*1.2,Q*1.2,l,1-c):``)+`<g transform="translate(${u.toFixed(1)} 0)"><ellipse cx="0" cy="${Q*.28}" rx="${d*.28}" ry="${d*.3}" fill="${l}"/><rect x="${-d*.32}" y="${Q*.42}" width="${d*.64}" height="${Q*.7}" rx="${d*.2}" fill="${l}"/></g>`,alpha:IN(DN(n,a,o),s*.7)}},flashImpact(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]);return{svg:QN(-i*LN,-640*LN,i*1.2,Q*1.2,e.params.tint||`#ffffff`,a**.5),alpha:a}},dipToColor(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]);return{svg:QN(-i*LN,-640*LN,i*1.2,Q*1.2,e.params.color||e.colors[0]||EN(e,r),a),alpha:a}},silhouettePass(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]);return{svg:QN(-i*LN,-640*LN,i*1.2,Q*1.2,`#1b2230`,a),alpha:a}},dayNightSweep(e,t,n,r,i){let a=EN(e,r),o=e.swapWindow[0],s=e.swapWindow[1],c=o>0?Y(n/o,0,1):1,l=s<1?Y((n-s)/(1-s),0,1):0,u=l*i,d=c*i;return{svg:`<defs><linearGradient id="dns"><stop offset="0" stop-color="${a}"/><stop offset="1" stop-color="${bk(a,`#0a1020`,.5)}"/></linearGradient></defs>`+QN(u,-640*LN,d-u,Q*1.2,`url(#dns)`),alpha:c-l}},spotlightShift(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=e.params.origin===`subject`&&r.subject?r.subject:{x:i/2,y:Q*.45},s=(1-a)*PN(i,Q)*.4+30;return{svg:`<defs><radialGradient id="sp" cx="${(o.x/i).toFixed(3)}" cy="${(o.y/Q).toFixed(3)}" r="${(s/i+.001).toFixed(3)}" gradientUnits="userSpaceOnUse" fx="${o.x}" fy="${o.y}" r="${s}"><stop offset="0.7" stop-color="#000" stop-opacity="0"/><stop offset="1" stop-color="#050810" stop-opacity="${(.4+.6*a).toFixed(2)}"/></radialGradient></defs><rect x="${-i*LN}" y="${-640*LN}" width="${i*1.2}" height="${Q*1.2}" fill="#050810" opacity="${(a*a).toFixed(2)}"/>`,alpha:a}},matchMorph(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=i/2,c=Q/2,l=40+a*PN(i,Q)*.55,u=a>.5?l*(1-(a-.5)*1.2):l;return{svg:`<rect x="${(s-l).toFixed(1)}" y="${(c-l).toFixed(1)}" width="${(2*l).toFixed(1)}" height="${(2*l).toFixed(1)}" rx="${Math.max(0,u).toFixed(1)}" fill="${o}"/>`,alpha:a}},pixelMosaic(e,t,n,r,i){let a=EN(e,r),o=Y(e.params.blockPx||48,20,120),s=Math.ceil(i/o),c=Math.ceil(Q/o),l=DN(n,e.swapWindow[0],e.swapWindow[1]),u=``,d=1;for(let e=0;e<c;e++)for(let t=0;t<s;t++){let n=ZN(t*3+e*7+1),r=+(l*1.5-n*.5>=.5);d=FN(d,l>=.99?1:r),r&&(u+=QN(t*o,e*o,o+1,o+1,a))}return{svg:u,alpha:l}},lineArtRebuild(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=e.params.strokeColor||`#243038`,c=QN(-i*LN,-640*LN,i*1.2,Q*1.2,o,a*a);for(let e=0;e<8;e++){let t=Q*(e+.5)/8,n=i*a;c+=`<line x1="0" y1="${t.toFixed(1)}" x2="${n.toFixed(1)}" y2="${t.toFixed(1)}" stroke="${s}" stroke-width="2" opacity="${(.5+.5*(1-a)).toFixed(2)}"/>`}return{svg:c,alpha:a}},ripplePortal(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=e.params.origin&&r.subject?r.subject:{x:i/2,y:Q/2},c=Y(e.params.rings||5,2,8),l=`<circle cx="${s.x}" cy="${s.y}" r="${(a*PN(i,Q)*.6).toFixed(1)}" fill="${o}"/>`;for(let e=0;e<c;e++){let t=a*PN(i,Q)*.6+e*26;l+=`<circle cx="${s.x}" cy="${s.y}" r="${t.toFixed(1)}" fill="none" stroke="${bk(o,`#fff`,.3)}" stroke-width="3" opacity="${(.6*(1-a)).toFixed(2)}"/>`}return{svg:l,alpha:a}},doorPass(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=EN(e,r);i/2*(1-c)*s;let u=i/2*c;return{svg:QN(-i*LN,-640*LN,i/2*s+i*LN-u,Q*1.2,l)+QN(i/2+u,-640*LN,i/2*s+i*LN-u,Q*1.2,l),alpha:s-c}},waveCrash(e,t,n,r,i){let a=e.swapWindow[0],o=e.swapWindow[1],s=a>0?Y(n/a,0,1):1,c=o<1?Y((n-o)/(1-o),0,1):0,l=bk(EN(e,r),`#2b6cb0`,.5),u=s*760-60,d=c*760-60,f=`M ${-i*LN} ${d.toFixed(1)}`;for(let e=0;e<=i;e+=40)f+=` L ${e} ${(u+jN(e/i*6+n*6)*26).toFixed(1)}`;f+=` L ${i+i*LN} ${d.toFixed(1)} Z`;let p=e.params.foam===!1?``:`<path d="${f.replace(/Z$/,``)}" fill="none" stroke="#eaf4ff" stroke-width="6" opacity="0.6"/>`;return{svg:`<path d="${f}" fill="${l}"/>${p}`,alpha:s-c}},pageFlip(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=EN(e,r),s=a*(i+Q);return{svg:`<path d="M ${i} 0 L ${(i-s).toFixed(1)} 0 L ${i} ${s.toFixed(1)} Z" fill="${o}"/><path d="M ${(i-s).toFixed(1)} 0 L ${i} ${s.toFixed(1)} L ${(i-s*.7).toFixed(1)} ${(s*.7).toFixed(1)} Z" fill="${bk(o,`#fff`,.25)}"/>`,alpha:a}},lightSpeedStreak(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=e.params.streakColor||`#bcd4ff`,s=i/2,c=Q/2,l=QN(-i*LN,-640*LN,i*1.2,Q*1.2,`#050813`,a*a);for(let e=0;e<40;e++){let t=ZN(e+1)*2*NN,n=20+ZN(e)*40,r=n+a*PN(i,Q)*.7;l+=`<line x1="${(s+MN(t)*n).toFixed(1)}" y1="${(c+jN(t)*n).toFixed(1)}" x2="${(s+MN(t)*r).toFixed(1)}" y2="${(c+jN(t)*r).toFixed(1)}" stroke="${o}" stroke-width="2" opacity="${(.4+.6*a).toFixed(2)}"/>`}return{svg:l,alpha:a}},glitchCut(e,t,n,r,i){let a=DN(n,e.swapWindow[0],e.swapWindow[1]),o=e.params.intensity||1,s=(ZN(Math.floor(n*30))-.5)*20*o,c=QN(-i*LN,-640*LN,i*1.2,Q*1.2,EN(e,r),a*(.4+.6*ZN(Math.floor(n*40))));for(let e=0;e<6;e++){let t=Q*ZN(e*3+1),n=8+30*ZN(e);c+=QN(s,t,i,n,e%2?`#ff2d6a`:`#2dffea`,.35*a)}return{svg:c,alpha:a}}}),$N=e=>bk(e,`#000`,.4),eP={carryTravel:(e,t,n,r)=>({fromT:`translate(${(-t*e*n).toFixed(1)} 0)`,toT:`translate(${(t*(1-e)*n).toFixed(1)} 0)`}),pushOff:(e,t,n,r)=>({fromT:`translate(${(-t*e*n).toFixed(1)} 0)`,toT:`translate(${(t*(1-e)*n).toFixed(1)} 0)`}),slideOver:(e,t,n,r)=>({fromT:``,toT:`translate(${(t*(1-e)*n).toFixed(1)} 0)`,over:!0}),whipPan:(e,t,n,r,i)=>({fromT:`translate(${(-t*e*n*1.25).toFixed(1)} 0)`,toT:`translate(${(t*(1-e)*n*1.25).toFixed(1)} 0)`,blur:jN(e*NN)*(i.blurPx||9)}),spinCard:(e,t,n,r)=>{let i=MN(e*NN);return{fromT:`translate(${n/2} ${r/2}) scale(${e<.5?Math.max(.001,i).toFixed(3):.001} 1) translate(${-n/2} ${-r/2})`,toT:`translate(${n/2} ${r/2}) scale(${e>=.5?Math.max(.001,-i).toFixed(3):.001} 1) translate(${-n/2} ${-r/2})`,flip:!0}},zoomThrough:(e,t,n,r,i,a)=>{let o=a?a.x:n/2,s=a?a.y:r*.42;return{fromT:`translate(${o} ${s}) scale(${(1+e*5).toFixed(3)}) translate(${-o} ${-s})`,toT:`translate(${n/2} ${r/2}) scale(${(.15+.85*e).toFixed(3)}) translate(${-n/2} ${-r/2})`,flip:!0}},pullBackReveal:(e,t,n,r)=>({fromT:`translate(${n/2} ${r/2}) scale(${(1-e*.86).toFixed(3)}) translate(${-n/2} ${-r/2})`,toT:`translate(${n/2} ${r/2}) scale(${(1.7-.7*e).toFixed(3)}) translate(${-n/2} ${-r/2})`,flip:!0}),elevatorRise:(e,t,n,r)=>({fromT:`translate(0 ${(t*e*r).toFixed(1)})`,toT:`translate(0 ${(t*(1-e)*r-t*r).toFixed(1)})`}),stackShuffle:(e,t,n,r,i)=>({fromT:`translate(${(t*e*n).toFixed(1)} ${(e*40).toFixed(1)}) rotate(${(t*e*4).toFixed(1)} ${n/2} 200)`,toT:``,shadow:i.cardShadow!==!1}),splitBarn:(e,t,n,r,i)=>({split:e,axis:i.axis||`v`})}}));function nP(e){e=Y(e,0,1);for(let t=0;t<iP.length-1;t++)if(e<=iP[t+1]){let n=(e-iP[t])/(iP[t+1]-iP[t]);return xk(aP[t],aP[t+1],n)}return aP[aP.length-1]}function rP(e,t){return t===`2d`?{scale:1,yShift:0,opacity:1,blur:0,w:nP(.5)}:{scale:oP(e),yShift:sP(e),opacity:cP(e),blur:lP(e),w:nP(e)}}var iP,aP,oP,sP,cP,lP,uP=o((()=>{Tk(),iP=[0,.25,.5,.75,1],aP=[1.45,1.28,1,.24,.15],oP=e=>1+(.5-e)*.72,sP=e=>-(e-.5)*165,cP=e=>1-Y(e-.42,0,.58)*.78,lP=e=>Y(e-.55,0,.45)*6}));function dP(e,t){let n=t/2/Math.max(.001,e.zoom);return n>=t/2?{...e,cx:t/2}:{...e,cx:Y(e.cx,n,t-n)}}function fP(e,t,n,r,i){let a=i*i,o=a*i;return .5*(2*t+(-e+n)*i+(2*e-5*t+4*n-r)*a+(-e+3*t-3*n+r)*o)}function pP(e,t){if(e.length===1)return e[0];let n=Y(Math.floor(t),0,e.length-2),r=t-n,i=e[Math.max(0,n-1)],a=e[n],o=e[n+1],s=e[Math.min(e.length-1,n+2)];return fP(i,a,o,s,r)}function mP(e,t,n,r,i,a,o){let s=TP[o]||TP.editorial,c=t.zoom;if(e===`locked`)return{...t};if(e===`drift`)return{cx:t.cx+40*s.amp*Math.sin(n*.25*s.speed),cy:t.cy,zoom:c};let l=vk(i+`:cam`),u=a&&a.length?a:[{rigX:t.cx}],d=[t.cx],f=[c],p=Math.max(3,Math.min(6,u.length+2));for(let e=0;e<p;e++){let e=u[Math.floor(l()*u.length)];d.push(t.cx+(e.rigX-t.cx)*s.amp+(l()-.5)*60*s.amp),f.push(c+l()*.08*s.amp)}d.push(t.cx),f.push(c);let m=n/Math.max(.001,r)*(d.length-1)*s.speed%(d.length-1);return{cx:pP(d,m),cy:t.cy-6,zoom:pP(f,m)}}function hP(e,t){let n=wP(t.VBW,t.frame),r=(e||[]).find(e=>e.idle)||{idle:`focusFlow`},i=[],a=n,o=(e||[]).filter(e=>e.directive&&(e.atPhrase!=null||e.atMs!=null)).map(e=>({d:e,t:e.atMs==null?t.phrases[e.atPhrase].t:e.atMs/1e3})).sort((e,t)=>e.t-t.t),s=t.frame&&t.frame.cy>350;return o.forEach((e,r)=>{let c=e.d,l=e.t,u=r+1<o.length?o[r+1].t:t.sceneT1,d=(c.ms||(c.directive===`snapZoom`?280:c.directive===`punchTo`?620:1100))/1e3,f=xP[c.ease]||(s?wk:Ck),p=(c.hold||0)/1e3,m=a,h={...n};if(c.directive===`panTo`){let e=t.resolveTarget(c.target);h={cx:e.x+(c.offset&&c.offset.x||0),cy:e.y+(c.offset&&c.offset.y||0),zoom:c.zoom||1.3}}else if(c.directive===`punchTo`){let e=t.resolveTarget(c.target);h={cx:e.x+(c.offset&&c.offset.x||0),cy:e.y+(c.offset&&c.offset.y||0),zoom:c.zoom||1.55}}else if(c.directive===`snapZoom`){let e=t.resolveTarget(c.target);h={cx:e.x+(c.offset&&c.offset.x||0),cy:e.y+(c.offset&&c.offset.y||0),zoom:c.zoom||1.75}}else if(c.directive===`orbitLite`){let e=t.resolveTarget(c.target);h={cx:e.x,cy:e.y,zoom:c.zoom||1.2}}else if(c.directive===`zoomOut`||c.directive===`establish`)h=wP(t.VBW,t.frame);else if(c.directive===`follow`)h=m;else if(c.directive===`travel`)h={cx:m.cx+(c.viewportWidths||1)*t.VBW*.6,cy:m.cy,zoom:c.zoom||m.zoom||1};else if(c.directive===`hop`){let e=t.resolveTarget((c.targets||[])[0]);e&&(h={cx:e.x,cy:e.y,zoom:c.zoom||1.3})}i.push({d:c,t0:l,tNext:u,ms:d,ease:f,hold:p,from:m,to:h}),a=c.then===`return`?n:h}),{base:n,idle:r,shots:i}}function gP(e,t,n){n={...n,frame:n.frame||CP(e)};let r=hP(e.camera,n),i=null;for(let e of r.shots)t>=e.t0-1e-9&&t<e.tNext&&(i=e);let a;if(i){let e=i.d,o=t-i.t0;if(i._dir=e.directive,e.directive===`follow`){let t=n.resolveTarget(e.target),i=Y(e.tightness==null?.6:e.tightness,.05,1),o=e.leadRoom?40:0;a={cx:xk(r.base.cx,t.x+o,i),cy:r.base.cy,zoom:e.zoom||1.15,active:!0}}else if(e.directive===`hop`&&e.targets&&e.targets.length){let t=(e.dwell||900)/1e3,r=e.targets.length*t,i=Y(Math.floor(o%r/t),0,e.targets.length-1),s=(o%r-i*t)/t,c=n.resolveTarget(e.targets[i]),l=n.resolveTarget(e.targets[Math.min(i+1,e.targets.length-1)]),u=Ck(Y(s*2,0,1));a={cx:xk(c.x,l.x,u),cy:xk(c.y,l.y,u),zoom:e.zoom||1.3,active:!0}}else if(e.directive===`orbitLite`){let t=n.resolveTarget(e.target),i=(e.deg||8)/8*n.VBW*.06,s=Math.sin(o*(e.speed||.8));a={cx:t.x+s*i,cy:r.base.cy,zoom:e.zoom||1.2,active:!0}}else{let t=i.ease(Y(o/i.ms,0,1)),n=xk(i.from.cx,i.to.cx,t),s=xk(i.from.cy,i.to.cy,t),c=xk(i.from.zoom,i.to.zoom,t);if(e.then===`return`){let e=i.tNext-i.t0,t=Math.min(i.ms,e*.5),a=Math.max(i.ms,e-t);if(o>=a){let e=i.ease(Y((o-a)/t,0,1));n=xk(i.to.cx,r.base.cx,e),s=xk(i.to.cy,r.base.cy,e),c=xk(i.to.zoom,r.base.zoom,e)}}a={cx:n,cy:s,zoom:c,active:!0},e.directive===`snapZoom`&&(a.whip=Y(1-o/.28,0,1))}}else{let e=r.base;for(let n of r.shots)t>=n.t0&&(e=n.d.then===`return`?r.base:n.to);a={...mP(r.idle.idle||`focusFlow`,e,t-n.sceneT0,n.sceneT1-n.sceneT0,n.seed,n.cast,r.idle.stylePreset),active:!1}}return a.directive=i?i.d.directive:`idle`,dP(a,n.VBW)}function _P(e,t){let n=hP(e.camera,t),r=new Set(n.shots.map(e=>e.d.directive)),i=n.shots.map(e=>e.to.zoom).concat([1]),a=Math.max(...i)-Math.min(...i);return Y(r.size*.22+n.shots.length*.1+a*.6,0,1)}function vP(e,t){let n=e.rotation?` rotate(${(-e.rotation).toFixed(3)})`:``;return`translate(${(t/2).toFixed(2)} 300)${n} scale(${e.zoom.toFixed(4)}) translate(${(-e.cx).toFixed(2)} ${(-e.cy+300).toFixed(2)})`}function yP(e,t){return{pan:(t/2-e.cx)*(960/t),scale:e.zoom-1}}function bP(e,t){let n=hP(e.camera,t),r=Math.max(.001,t.sceneT1-t.sceneT0),i=0;return n.shots.forEach(e=>{let t=Math.min(e.tNext,e.t0+e.ms+e.hold);i+=Math.max(0,t-e.t0)}),Y(i/r,0,1)}var xP,SP,CP,wP,TP,EP=o((()=>{Tk(),xP={linear:Sk,smooth:Ck,smoother:wk},SP={default:{cy:300,zoom:1},warfilm:{cy:560,zoom:1}},CP=e=>{let t=null;return(e&&e.camera||[]).forEach(e=>{e.stylePreset&&(t=e.stylePreset)}),SP[t]||SP.default},wP=(e,t=SP.default)=>({cx:e/2,cy:t.cy,zoom:t.zoom}),TP={editorial:{amp:1,zoom:1.06,speed:1},energetic:{amp:1.7,zoom:1.13,speed:1.6},calm:{amp:.5,zoom:1.03,speed:.6},doc:{amp:.8,zoom:1.05,speed:.8},documentary:{amp:.8,zoom:1.05,speed:.8},dramatic:{amp:1.2,zoom:1.18,speed:.7},warfilm:{amp:1.5,zoom:1.02,speed:1.4}}}));function DP(e,t,n){let r=LP[e.type];return r?r(e,Y(t,0,1),n):``}var OP,kP,AP,jP,MP,NP,PP,FP,IP,LP,RP,zP,BP=o((()=>{Tk(),OP=`#243038`,kP=`#2BB3A3`,AP=`#FF6B5E`,jP=`#8794a0`,MP=`#F2B134`,NP=`#5B6CE0`,PP=(e,t,n=`#fff`)=>`<rect x="${-e/2}" y="${-t/2}" width="${e}" height="${t}" rx="${t/2}" fill="${n}" stroke="rgba(20,40,50,.08)"/>`,FP=(e,t)=>`<rect x="${-e/2}" y="${-t/2}" width="${e}" height="${t}" rx="14" fill="#fff" stroke="rgba(20,40,50,.08)"/>`,IP=(e,t,n,r,i=OP,a=800,o=`middle`)=>`<text x="${e}" y="${t}" font-family="Nunito,system-ui,sans-serif" font-size="${n}" font-weight="${a}" text-anchor="${o}" fill="${i}">${r}</text>`,LP={counter(e,t){let n=wk(t),r=e.value==null?0:e.value,i=(Number.isInteger(r)?Math.round(r*n):(r*n).toFixed(1))+(e.unit||``);return e.variant===`chip`?`${PP(Math.max(90,i.length*22+40),56)}${IP(0,9,30,(e.label?e.label+` `:``)+i,OP,900)}`:`${IP(0,6,62,i,kP,900)}${e.label?IP(0,40,20,e.label,jP,800):``}`},proportionFill(e,t){let n=Y(e.value||0,0,100),r=n/100*260*wk(t);return`${FP(296,74)}${e.label?IP(0,-18,20,e.label,OP,800):``}<rect x="-130" y="2" width="260" height="18" rx="9" fill="#e7edf1"/><rect x="-130" y="2" width="${r}" height="18" rx="9" fill="${kP}"/>${IP(134,17,18,Math.round(n*wk(t))+`%`,OP,900,800,`start`)}`},barsCompare(e,t){let n=e.values||[40,70,55],r=e.labels||[],i=[kP,NP,AP,MP],a=Math.max(...n,1),o=n.length*60,s=wk(t),c=n.map((e,t)=>{let n=e/a*120*s,c=-o/2+t*60+10;return`<rect x="${c}" y="${-n}" width="40" height="${n}" rx="6" fill="${i[t%4]}"/>${r[t]?IP(c+20,22,15,r[t],jP,800):``}`}).join(``);return`<line x1="${-o/2-6}" y1="0" x2="${o/2+6}" y2="0" stroke="#d7dee3" stroke-width="2"/>${c}`},trendLine(e,t){let n=e.points||[30,42,38,58,74,68,90],r=wk(t),i=n.length,a=Math.max(...n,1),o=n.map((e,t)=>[-130+t/(i-1)*260,-(e/a)*90]),s=Math.max(2,Math.round(2+(i-2)*r)),c=o.slice(0,s).map((e,t)=>(t?`L`:`M`)+e[0].toFixed(1)+` `+e[1].toFixed(1)).join(` `),l=o[s-1];return`${FP(300,150)}<polyline points="${o.map(e=>e.join(`,`)).join(` `)}" fill="none" stroke="#e7edf1" stroke-width="2"/><path d="${c}" fill="none" stroke="${kP}" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><circle cx="${l[0].toFixed(1)}" cy="${l[1].toFixed(1)}" r="5" fill="${kP}"/>${e.label?IP(0,67,18,e.label,OP,800):``}`},labelChip(e,t){let n=.6+.4*wk(t),r=(e.text||`label`).length*12+34;return`<g transform="scale(${n})" opacity="${t.toFixed(2)}">${PP(r,44,e.tone===`accent`?AP:`#fff`)}${IP(0,7,20,e.text||`label`,e.tone===`accent`?`#fff`:OP,900)}</g>`},mapLite(e,t){let n=(1-wk(t))*40;return`<path d="M-70 20 Q-80 -30 -30 -40 Q10 -60 50 -34 Q86 -20 70 20 Q30 44 -20 40 Q-56 40 -70 20 Z" fill="#cfe3d3" stroke="#a9c6ad" stroke-width="2"/><g transform="translate(${e.px||20} ${-10-n})" opacity="${Y(t*1.4,0,1).toFixed(2)}"><path d="M0 0 C-14 -18 -10 -34 0 -34 C10 -34 14 -18 0 0 Z" fill="${AP}"/><circle cx="0" cy="-24" r="5" fill="#fff"/></g>`},timelineStrip(e,t){let n=e.count||5,r=wk(t),i=Math.round(n*r),a=`<line x1="-130" y1="0" x2="130" y2="0" stroke="#d7dee3" stroke-width="3"/><line x1="-130" y1="0" x2="${-130+260*r}" y2="0" stroke="${kP}" stroke-width="3"/>`;for(let e=0;e<n;e++){let t=-130+e/(n-1)*260;a+=`<circle cx="${t}" cy="0" r="7" fill="${e<i?kP:`#e7edf1`}" stroke="#fff" stroke-width="2"/>`}return a},iconBurst(e,t){let n=wk(t),r=``;for(let e=0;e<8;e++){let t=e/8*Math.PI*2,i=20+34*n;r+=`<circle cx="${(Math.cos(t)*i).toFixed(1)}" cy="${(Math.sin(t)*i).toFixed(1)}" r="${(5*n+2).toFixed(1)}" fill="${[kP,MP,AP,NP][e%4]}" opacity="${(1-n*.5).toFixed(2)}"/>`}return`<circle cx="0" cy="0" r="16" fill="${MP}"/>${r}`},gauge(e,t){let n=Y(e.value||0,0,100),r=wk(t),i=Math.PI,a=Math.PI-n/100*Math.PI*r,o=(e,t,n,r)=>{let i=Math.cos(e)*70,a=-Math.sin(e)*70,o=Math.cos(t)*70,s=-Math.sin(t)*70;return`<path d="M${i.toFixed(1)} ${a.toFixed(1)} A70 70 0 0 1 ${o.toFixed(1)} ${s.toFixed(1)}" fill="none" stroke="${n}" stroke-width="${r}" stroke-linecap="round"/>`};return`${o(i,0,`#e7edf1`,14)}${o(i,a,kP,14)}${IP(0,-6,40,Math.round(n*r)+(e.unit||``),OP,900)}${e.label?IP(0,24,18,e.label,jP,800):``}`},quoteCard(e,t){return`<g opacity="${t.toFixed(2)}">${FP(300,110)}${IP(-132,-15,44,`“`,kP,900,800,`start`)}<foreignObject x="-110" y="-41" width="240" height="86"><div xmlns="http://www.w3.org/1999/xhtml" style="font:800 17px Nunito,system-ui;color:${OP};line-height:1.25">${e.text||``}</div></foreignObject></g>`},xOut(e,t){let n=wk(t);return`<circle cx="0" cy="0" r="34" fill="none" stroke="${AP}" stroke-width="6"/><line x1="${-34*.7*n}" y1="${-34*.7*n}" x2="${34*.7*n}" y2="${34*.7*n}" stroke="${AP}" stroke-width="7" stroke-linecap="round"/><line x1="${34*.7*n}" y1="${-34*.7*n}" x2="${-34*.7*n}" y2="${34*.7*n}" stroke="${AP}" stroke-width="7" stroke-linecap="round"/>`},connectionLink(e,t){let n=-110+220*wk(t);return`<circle cx="-110" cy="0" r="9" fill="${kP}"/><line x1="-110" y1="0" x2="${n}" y2="0" stroke="${kP}" stroke-width="4" stroke-dasharray="2 8" stroke-linecap="round"/><circle cx="110" cy="0" r="9" fill="${t>.9?kP:`#e7edf1`}"/>`},morph(e,t){return`<rect x="-40" y="-40" width="80" height="80" rx="${(40-32*wk(t)).toFixed(1)}" fill="${kP}"/>`},pieSlice(e,t){let n=Y(e.value==null?60:e.value,0,100)/100*wk(t),r=n*2*Math.PI,i=Math.sin(r)*40,a=-Math.cos(r)*40;return`<circle cx="0" cy="0" r="40" fill="#e7edf1"/><path d="M0 0 L0 -40 A40 40 0 ${+(n>.5)} 1 ${i.toFixed(1)} ${a.toFixed(1)} Z" fill="${kP}"/>${IP(0,6,20,Math.round(n*100)+`%`,OP,900)}`},statCallout(e,t){let n=e.value==null?``:Math.round(e.value*wk(t));return`${IP(0,-2,52,n+(e.unit||``),kP,900)}${e.label?IP(0,30,18,e.label,jP,800):``}`},checklist(e,t){let n=e.count||3,r=Math.round(n*wk(t)),i=``;for(let t=0;t<n;t++){let a=-n*15+t*30;i+=`<rect x="-96" y="${a-13}" width="192" height="26" rx="7" fill="#fff" stroke="rgba(20,40,50,.08)"/><circle cx="-78" cy="${a}" r="9" fill="${t<r?kP:`#e7edf1`}"/>${t<r?`<path d="M-82 ${a} l3 4 l7 -8" stroke="#fff" stroke-width="2.5" fill="none"/>`:``}${IP(-60,a+5,15,e.labels&&e.labels[t]||`item `+(t+1),OP,800,800,`start`)}`}return i},arrow(e,t){let n=wk(t),r=-70+140*n;return`<line x1="-70" y1="0" x2="${r.toFixed(1)}" y2="0" stroke="${AP}" stroke-width="6" stroke-linecap="round"/><path d="M${r.toFixed(1)} 0 l-14 -9 M${r.toFixed(1)} 0 l-14 9" stroke="${AP}" stroke-width="6" fill="none" stroke-linecap="round" opacity="${n.toFixed(2)}"/>`},highlightRing(e,t){return`<circle cx="0" cy="0" r="${(30+8*Math.sin(t*Math.PI)).toFixed(1)}" fill="none" stroke="${MP}" stroke-width="5"/>`},badge(e,t){return`<g transform="scale(${(.7+.3*wk(t)).toFixed(2)})"><path d="M0 -44 L38 -30 L38 6 Q38 34 0 46 Q-38 34 -38 6 L-38 -30 Z" fill="${kP}"/>${IP(0,6,22,e.text||`A+`,`#fff`,900)}</g>`},ratingStars(e,t){let n=Y(e.value==null?4:e.value,0,5)*wk(t),r=(e,t)=>`<path transform="translate(${e} 0) scale(0.85)" d="M0 -16 L5 -5 L17 -4 L8 4 L11 16 L0 9 L-11 16 L-8 4 L-17 -4 L-5 -5 Z" fill="${t}"/>`,i=``;for(let e=0;e<5;e++)i+=r(-88+e*44,e<n?MP:`#e7edf1`);return i},deltaBadge(e,t){let n=(e.value||0)>=0,r=Math.abs(Math.round((e.value||0)*wk(t)));return`${PP(130,52,n?`#e6f7f0`:`#fdecea`)}${IP(-32,8,24,n?`▲`:`▼`,n?kP:AP,900)}${IP(20,8,24,r+(e.unit||``),n?kP:AP,900)}`},keyValue(e,t){return`${FP(230,60)}${IP(-100,7,18,e.label||`key`,jP,800,800,`start`)}${IP(100,7,22,(e.text==null?e.value||``:e.text)+(e.unit||``),OP,900,800,`end`)}`},progressRing(e,t){let n=Y(e.value||0,0,100)/100*wk(t),r=2*Math.PI*40;return`<circle cx="0" cy="0" r="40" fill="none" stroke="#e7edf1" stroke-width="10"/><circle cx="0" cy="0" r="40" fill="none" stroke="${kP}" stroke-width="10" stroke-linecap="round" stroke-dasharray="${r.toFixed(1)}" stroke-dashoffset="${(r*(1-n)).toFixed(1)}" transform="rotate(-90)"/>${IP(0,7,24,Math.round(n*100)+`%`,OP,900)}`},flowStep(e,t){let n=Math.min(2,Math.floor(wk(t)*3)),r=``;for(let t=0;t<3;t++){let i=-100+t*100;r+=`<rect x="${i-34}" y="-22" width="68" height="44" rx="8" fill="${t<=n?kP:`#e7edf1`}"/>${IP(i,7,16,e.labels&&e.labels[t]||`step `+(t+1),t<=n?`#fff`:jP,800)}${t<2?`<path d="M${i+40} 0 l16 0 M${i+52} -5 l6 5 l-6 5" stroke="#c7d0d6" stroke-width="3" fill="none"/>`:``}`}return r},tally(e,t){let n=Math.round((e.value||7)*wk(t)),r=``;for(let e=0;e<n;e++){let t=Math.floor(e/5),n=e%5,i=-90+t*46+n*8;r+=n===4?`<line x1="${i-34}" y1="-16" x2="${i-2}" y2="16" stroke="${OP}" stroke-width="3"/>`:`<line x1="${i}" y1="-16" x2="${i}" y2="16" stroke="${OP}" stroke-width="3"/>`}return r},thermometer(e,t){let n=Y(e.value||0,0,100)/100*wk(t);return`<rect x="-12" y="-110" width="24" height="110" rx="12" fill="#e7edf1"/><rect x="-12" y="${(-110*n).toFixed(1)}" width="24" height="${(110*n).toFixed(1)}" rx="12" fill="${AP}"/><circle cx="0" cy="14" r="18" fill="${AP}"/>${IP(30,-110*n+6,18,Math.round(n*100)+`%`,OP,900,800,`start`)}`},sparkbars(e,t){let n=e.points||[3,6,4,8,5,9,7],r=wk(t),i=Math.max(...n,1),a=``;return n.forEach((e,t)=>{let o=e/i*60*r,s=-n.length*15/2+t*15;a+=`<rect x="${s}" y="${-o}" width="12" height="${o}" rx="3" fill="${kP}"/>`}),a},ribbon(e,t){return`<g transform="scale(${(.7+.3*wk(t)).toFixed(2)})"><circle cx="0" cy="-20" r="26" fill="${MP}"/><circle cx="0" cy="-20" r="18" fill="#fff" opacity=".85"/>${IP(0,-13,22,e.text||`1`,OP,900)}<path d="M-14 0 L-20 40 L-6 30 L0 42 L6 30 L20 40 L14 0 Z" fill="${AP}"/></g>`},calloutBox(e,t){return`<g opacity="${t.toFixed(2)}">${FP(220,70)}<path d="M-14 35 l14 18 l14 -18 Z" fill="#fff"/>${IP(0,6,18,e.text||``,OP,800)}</g>`},comparisonBar(e,t){let n=Y(e.value==null?60:e.value,0,100),r=wk(t),i=n/100*260*r;return`<rect x="-130" y="-12" width="260" height="24" rx="12" fill="${NP}"/><rect x="-130" y="-12" width="${i.toFixed(1)}" height="24" rx="12" fill="${kP}"/>${IP(-122,7,16,Math.round(n*r)+`%`,`#fff`,900,800,`start`)}${IP(122,7,16,100-Math.round(n*r)+`%`,`#fff`,900,800,`end`)}`}},LP.highlightRegion=function(e,t,n){let r=wk(t),i=e.tint||MP,a=(26+18*(.5+.5*Math.sin((n||0)*3)))*r,o=e.label?`<g transform="translate(0 -50)">${PP(e.label.length*12+30,38)}${IP(0,6,18,e.label,OP,900)}</g>`:``;return`<circle r="${a.toFixed(1)}" fill="none" stroke="${i}" stroke-width="3" opacity="${(.7*r).toFixed(2)}"/><circle r="${(12*r).toFixed(1)}" fill="${i}" opacity="0.9"/>${o}`},LP.sweepArrow=function(e,t){let n=e.bx==null?160:e.bx,r=e.by==null?-60:e.by,i=wk(t),a=e.tint||AP,o=n*.5,s=Math.min(0,r)-90,c=2*(1-i)*i*o+i*i*n,l=2*(1-i)*i*s+i*i*r,u=`<path d="M 0 0 Q ${o.toFixed(1)} ${s.toFixed(1)} ${c.toFixed(1)} ${l.toFixed(1)}" fill="none" stroke="${a}" stroke-width="5" stroke-linecap="round"/>`,d=``;if(i>.82){let e=Math.atan2(l-s,c-o);d=`<path d="M ${c.toFixed(1)} ${l.toFixed(1)} L ${(c+Math.cos(e+2.6)*18).toFixed(1)} ${(l+Math.sin(e+2.6)*18).toFixed(1)} M ${c.toFixed(1)} ${l.toFixed(1)} L ${(c+Math.cos(e-2.6)*18).toFixed(1)} ${(l+Math.sin(e-2.6)*18).toFixed(1)}" stroke="${a}" stroke-width="5" stroke-linecap="round" fill="none"/>`}return u+d},LP.dropPlate=function(e,t){let n=(1-wk(t))*-24,r=e.label||e.text||`REGION`,i=r.length*14+78;return`<g transform="translate(0 ${n.toFixed(1)})" opacity="${t.toFixed(2)}"><rect x="${(-i/2).toFixed(1)}" y="-26" width="${i.toFixed(1)}" height="52" rx="12" fill="#fff" stroke="rgba(20,40,50,.1)"/><circle cx="${(-i/2+28).toFixed(1)}" cy="0" r="16" fill="${e.tint||AP}"/><circle cx="${(-i/2+28).toFixed(1)}" cy="0" r="16" fill="none" stroke="rgba(0,0,0,.14)"/>${IP((-i/2+52).toFixed(1),7,21,r,OP,900,800,`start`)}</g>`},LP.entrantPlate=function(e,t){let n=(1-wk(t))*-140,r=e.label||e.text||`ENTRANT`,i=r.length*20+116;return`<g transform="translate(${n.toFixed(1)} 0)" opacity="${t.toFixed(2)}"><rect x="${(-i/2).toFixed(1)}" y="-34" width="${i.toFixed(1)}" height="68" rx="14" fill="#1b2432" stroke="rgba(255,255,255,.14)"/><circle cx="${(-i/2+36).toFixed(1)}" cy="0" r="22" fill="${e.tint||AP}"/><circle cx="${(-i/2+36).toFixed(1)}" cy="0" r="22" fill="none" stroke="rgba(255,255,255,.22)"/>`+IP((-i/2+68).toFixed(1),e.value==null?8:-4,26,r,`#fff`,900,800,`start`)+(e.value==null?``:IP((-i/2+68).toFixed(1),20,15,e.value+(e.unit||``),`#9fb0c4`,800,800,`start`))+`</g>`},LP.vsCard=function(e,t){let n=wk(t),r=e.labels||[`A`,`B`],i=70*n,a=r[0].length*16+54,o=r[1].length*16+54;return`<g opacity="${t.toFixed(2)}"><g transform="translate(${(-70-i).toFixed(1)} 0)">${PP(a,62,`#dfeaf6`)}${IP(0,8,24,r[0],OP,900)}</g><g transform="translate(${(70+i).toFixed(1)} 0)">${PP(o,62,`#f6e3df`)}${IP(0,8,24,r[1],OP,900)}</g><circle r="26" fill="${AP}"/><circle r="26" fill="none" stroke="#fff" stroke-width="2"/>${IP(0,9,24,`VS`,`#fff`,900)}</g>`},LP.rangeBand=function(e,t){let n=wk(t),r=e.min==null?0:e.min,i=e.max==null?100:e.max,a=Y(e.value==null?(r+i)/2:e.value,r,i),o=-140+280*((a-r)/(i-r||1));return`${e.label?IP(0,-30,20,e.label,OP,800):``}<rect x="-140" y="-8" width="280" height="16" rx="8" fill="#e7edf1"/><rect x="${(-50.39999999999999).toFixed(1)}" y="-8" width="${100.8.toFixed(1)}" height="16" rx="8" fill="#cdeee7"/><g transform="translate(${(-140+(o+140)*n).toFixed(1)} 0)"><line x1="0" y1="-20" x2="0" y2="20" stroke="${kP}" stroke-width="4" stroke-linecap="round"/><circle cx="0" cy="0" r="7" fill="${kP}"/></g>`+IP(-140,34,14,``+r,jP,800)+IP(140,34,14,``+i,jP,800,`middle`)+IP(0,34,15,Math.round(a*n)+(e.unit||``),OP,900)},LP.podium=function(e,t){let n=wk(t),r=e.labels||[`1st`,`2nd`,`3rd`],i=e.values||[],a=r.map((e,t)=>({label:e,val:i[t]}));i.length&&(a=a.slice().sort((e,t)=>(t.val||0)-(e.val||0))),a=a.slice(0,3);let o=[1,0,2],s=[130,96,74],c=[MP,jP,`#c98b52`];return a.map((t,r)=>{let i=o[r],a=s[r]*n,l=-66+i*66,u=r+1;return`<rect x="${l}" y="${-a}" width="62" height="${a}" rx="6" fill="${c[r]}"/>${IP(l+31,-a+30,26,``+u,`#fff`,900)}`+(t.label?IP(l+31,24,14,t.label,OP,800):``)+(t.val==null?``:IP(l+31,-a-10,16,t.val+(e.unit||``),OP,900))}).join(``)},LP.rankBadge=function(e,t){let n=.7+.3*wk(t),r=e.value==null?1:e.value,i=r===1?MP:r===2?`#b8c0c8`:r===3?`#c98b52`:kP;return`<g transform="scale(${n.toFixed(2)})"><circle cx="0" cy="0" r="34" fill="${i}"/><circle cx="0" cy="0" r="27" fill="#fff" opacity=".9"/>${IP(0,3,30,`#`+r,OP,900)}<path d="M-16 26 L-22 58 L-8 48 L0 60 L8 48 L22 58 L16 26 Z" fill="${i}"/>${e.label?IP(0,-46,16,e.label,jP,800):``}</g>`},LP.progressRail=function(e,t){let n=wk(t),r=e.count||(e.labels?e.labels.length:4),i=e.value==null?n:Y(e.value,0,100)/100,a=-140+280*i,o=`<rect x="-140" y="-4" width="280" height="8" rx="4" fill="#e7edf1"/><rect x="-140" y="-4" width="${(280*i).toFixed(1)}" height="8" rx="4" fill="${kP}"/>`;for(let t=0;t<r;t++){let n=-140+t/(r-1)*280,i=n<=a+1;o+=`<circle cx="${n.toFixed(1)}" cy="0" r="6" fill="${i?kP:`#fff`}" stroke="${i?kP:`#d7dee3`}" stroke-width="2"/>${e.labels&&e.labels[t]?IP(n,26,13,e.labels[t],i?OP:jP,800):``}`}return o+`<g transform="translate(${a.toFixed(1)} 0)"><circle cx="0" cy="0" r="11" fill="${kP}" stroke="#fff" stroke-width="3"/></g>`},LP.ticker=function(e,t,n){let r=(e.labels||[e.text||`BREAKING`]).join(` • `)+` • `,i=r.length*9.2,a=-((n||0)*70%i),o=e.label||`LIVE`;return`<clipPath id="tk"><rect x="-160" y="-20" width="320" height="40" rx="8"/></clipPath><rect x="-160" y="-20" width="320" height="40" rx="8" fill="#1b2432"/><g clip-path="url(#tk)"><text x="${(-148+a).toFixed(1)}" y="6" font-family="Nunito,system-ui" font-size="18" font-weight="800" fill="#fff">${r}${r}</text></g><rect x="-160" y="-20" width="74" height="40" rx="8" fill="${AP}"/>${IP(-123,6,16,o,`#fff`,900)}<g opacity="${t.toFixed(2)}"></g>`},LP.scoreboard=function(e,t){let n=e.labels||[`HOME`,`AWAY`],r=e.values||[0,0],i=wk(t),a=Math.round(r[0]*i),o=Math.round(r[1]*i);return`<g opacity="${t.toFixed(2)}"><rect x="-150" y="-42" width="300" height="84" rx="12" fill="#1b2432"/><rect x="-150" y="-42" width="8" height="84" fill="${kP}"/><rect x="142" y="-42" width="8" height="84" fill="${AP}"/>`+IP(-90,-12,18,n[0],`#9fb0c4`,900)+IP(-90,24,40,``+a,`#fff`,900)+IP(90,-12,18,n[1],`#9fb0c4`,900)+IP(90,24,40,``+o,`#fff`,900)+`<line x1="0" y1="-30" x2="0" y2="30" stroke="rgba(255,255,255,.14)" stroke-width="2"/>`+(e.text?IP(0,-8,16,e.text,MP,900):IP(0,8,26,`:`,`#fff`,900))+`</g>`},LP.checkmark=function(e,t){let n=wk(t),r=46*(1-n);return`<circle cx="0" cy="0" r="30" fill="${kP}" opacity="${(.15+.85*n).toFixed(2)}"/><path d="M-14 1 l9 11 l19 -22" fill="none" stroke="#fff" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="46" stroke-dashoffset="${r.toFixed(1)}"/>${e.label?IP(0,54,18,e.label,OP,900):``}`},LP.bracketSync=function(e,t){let n=wk(t),r=e.labels||[`Seed A`,`Seed B`,`Winner`],i=Y(n*1.4,0,1),a=(e,t,n,r)=>`<g transform="translate(${e} ${t})">${PP(96,40,r?`#dfeff6`:`#fff`)}${IP(0,6,16,n,OP,900)}</g>`;return a(-96,-40,r[0],!0)+a(-96,40,r[1],!0)+`<path d="M-48 -40 H-20 V40 H-48 M-20 0 H48" fill="none" stroke="${kP}" stroke-width="3" stroke-dasharray="220" stroke-dashoffset="${(220*(1-n)).toFixed(1)}"/><g opacity="${i.toFixed(2)}">${a(96,0,r[2],!0)}</g>`},LP.lowerThird=function(e,t){let n=(1-wk(t))*-260,r=e.text||`Name`,i=e.label||``,a=Math.max(r.length,i.length)*13+90;return`<g transform="translate(${n.toFixed(1)} 0)" opacity="${Y(t*1.4,0,1).toFixed(2)}"><rect x="${-a/2}" y="-30" width="${a}" height="60" rx="8" fill="#1b2432"/><rect x="${-a/2}" y="-30" width="7" height="60" fill="${kP}"/>`+IP(-a/2+22,-2,24,r,`#fff`,900,800,`start`)+(i?IP(-a/2+22,20,15,i,kP,800,800,`start`):``)+`</g>`},LP.annotationArrow=function(e,t){let n=wk(t),r=e.dir||`up`,i={up:[0,-96],down:[0,96],left:[-120,0],right:[120,0]}[r]||[0,-96],a=i[0]*.6+(r===`up`||r===`down`?40:0),o=i[1]*.6+(r===`left`||r===`right`?-34:0),s=2*(1-n)*n*a+n*n*i[0],c=2*(1-n)*n*o+n*n*i[1],l=``;if(n>.85){let e=Math.atan2(c-o,s-a);l=`<path d="M${s.toFixed(1)} ${c.toFixed(1)} L${(s+Math.cos(e+2.6)*16).toFixed(1)} ${(c+Math.sin(e+2.6)*16).toFixed(1)} M${s.toFixed(1)} ${c.toFixed(1)} L${(s+Math.cos(e-2.6)*16).toFixed(1)} ${(c+Math.sin(e-2.6)*16).toFixed(1)}" stroke="${AP}" stroke-width="5" stroke-linecap="round" fill="none"/>`}let u=e.text?`<g transform="translate(${(-i[0]*.1).toFixed(1)} ${(-i[1]*.1).toFixed(1)})">${PP(e.text.length*11+28,38,`#fff`)}${IP(0,6,17,e.text,OP,900)}</g>`:``;return`<path d="M0 0 Q${a.toFixed(1)} ${o.toFixed(1)} ${s.toFixed(1)} ${c.toFixed(1)}" fill="none" stroke="${AP}" stroke-width="5" stroke-linecap="round"/>${l}${u}`},LP.circleHighlight=function(e,t,n){let r=wk(t),i=e.value==null?52:e.value,a=i*.74,o=300*(1-r);return`<g transform="rotate(-8) scale(${(1+.02*Math.sin((n||0)*4)).toFixed(3)})"><path d="M${i} -6 C${i} ${-a*1.1} ${-i*.4} ${-a*1.25} ${-i} ${-a*.3} C${-i*1.3} ${a*.7} ${-i*.3} ${a*1.25} ${i*.5} ${a} C${i*1.25} ${a*.75} ${i*1.05} ${-a*.2} ${i*.9} ${-a*.9}" fill="none" stroke="${e.tint||MP}" stroke-width="5" stroke-linecap="round" stroke-dasharray="300" stroke-dashoffset="${o.toFixed(1)}"/></g>${e.label?IP(0,a+30,18,e.label,OP,900):``}`},LP.floorPlanBoard=function(e,t){let n=(1-wk(t))*28,r=`<g transform="translate(${e.px==null?0:e.px} ${((e.py==null?-30:e.py)-20-n).toFixed(1)})" opacity="${Y(t*1.4,0,1).toFixed(2)}"><path d="M0 0 C-13 -17 -9 -32 0 -32 C9 -32 13 -17 0 0 Z" fill="${e.tint||AP}"/><circle cx="0" cy="-22" r="5" fill="#fff"/></g>`,i=e.label?`<g transform="translate(0 -110)">${PP(e.label.length*12+28,38)}${IP(0,6,18,e.label,OP,900)}</g>`:``;return`<g opacity="${t.toFixed(2)}"><rect x="-140" y="-90" width="280" height="180" rx="10" fill="#f4f7f8" stroke="#c7d3d9" stroke-width="3"/><line x1="0" y1="-90" x2="0" y2="50" stroke="#c7d3d9" stroke-width="3"/><line x1="-140" y1="10" x2="0" y2="10" stroke="#c7d3d9" stroke-width="3"/><line x1="0" y1="-20" x2="140" y2="-20" stroke="#c7d3d9" stroke-width="3"/><rect x="-8" y="86" width="16" height="8" fill="#f4f7f8" stroke="none"/>${i}</g>${r}`},LP.titleCard=function(e,t){return`<g transform="translate(0 ${((1-wk(t))*22).toFixed(1)})" opacity="${Y(t*1.3,0,1).toFixed(2)}"><line x1="-290" y1="-56" x2="290" y2="-56" stroke="${kP}" stroke-width="3"/>`+IP(0,6,62,e.text||`Title`,OP,900)+(e.label?IP(0,52,24,e.label,jP,800):``)+`<line x1="-290" y1="86" x2="290" y2="86" stroke="${kP}" stroke-width="3"/></g>`},LP.chapterCard=function(e,t){let n=wk(t),r=Y(n*1.2,0,1),i=e.value==null?1:e.value;return`<g opacity="${t.toFixed(2)}"><rect x="-280" y="-58" width="${(560*r).toFixed(1)}" height="116" rx="12" fill="#1b2432"/>`+IP(-234,18,68,``+i,kP,900,800,`start`)+(r>.6?IP(-160,-6,20,`CHAPTER`,`#9fb0c4`,900,800,`start`)+IP(-160,26,30,e.text||``,`#fff`,900,800,`start`):``)+`</g>`},LP.ctaCard=function(e,t,n){let r=wk(t),i=1+.03*Math.sin((n||0)*4),a=Math.max(320,(e.text||`Get started`).length*20+120);return`<g transform="scale(${(r*i).toFixed(3)})" opacity="${t.toFixed(2)}">`+(e.label?IP(0,-58,24,e.label,OP,800):``)+`<rect x="${-a/2}" y="-34" width="${a}" height="68" rx="34" fill="${AP}"/>${IP(0,9,28,e.text||`Get started`,`#fff`,900)}<path d="M${a/2-44} -8 l16 8 l-16 8" stroke="#fff" stroke-width="4" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g>`},LP.endCard=function(e,t){let n=wk(t);return`<g opacity="${Y(t*1.3,0,1).toFixed(2)}"><circle cx="0" cy="-64" r="${(30*n).toFixed(1)}" fill="${kP}"/>${n>.5?`<path d="M-11 -64 l7 8 l14 -16" stroke="#fff" stroke-width="5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`:``}`+IP(0,8,52,e.text||`The End`,OP,900)+(e.label?IP(0,48,22,e.label,jP,800):``)+`<line x1="-220" y1="76" x2="220" y2="76" stroke="#e7edf1" stroke-width="2"/></g>`},LP.recapCarousel=function(e,t){let n=e.labels||[`One`,`Two`,`Three`],r=Math.min(n.length,4),i=wk(t),a=r*150+(r-1)*18,o=e.label?IP(0,-96,24,e.label,OP,900):``;for(let e=0;e<r;e++){let t=Y(i*r-e,0,1),s=-a/2+75+e*168,c=(1-t)*16;o+=`<g transform="translate(${s.toFixed(1)} ${c.toFixed(1)})" opacity="${t.toFixed(2)}"><rect x="-75" y="-56" width="150" height="112" rx="12" fill="#fff" stroke="rgba(20,40,50,.1)"/><circle cx="0" cy="-22" r="16" fill="${[kP,MP,AP,NP][e%4]}"/>${IP(0,-15,18,``+(e+1),`#fff`,900)}`+IP(0,30,16,n[e],OP,800)+`</g>`}return o},RP=Object.keys(LP),zP=[`titleCard`,`chapterCard`,`ctaCard`,`endCard`,`recapCarousel`]}));function VP(e){return eF[(e||``).toLowerCase()]||eF.default}function HP(e,t){return{dx:Math.sin(e*.18+t)*26,dy:Math.sin(e*.9+t)*6}}function UP(e){let[t,n]=QP[e.size]||QP.M,r=e.depthScale==null?1:e.depthScale,i=t*r,a=n*r,o=e.tint||VP(e.label),s=e.silhouette==null?e.z!=null&&e.z>.72:e.silhouette,c=Math.min(16*r,a*.18),l=s?0:Math.min(12*r,a*.16),u=e.shadow===!1?``:`<ellipse cx="0" cy="4" rx="${(i*.56).toFixed(1)}" ry="${(9*r).toFixed(1)}" fill="#000" opacity="${s?.1:.16}"/>`,d=`<rect x="${(-i/2).toFixed(1)}" y="${(-a).toFixed(1)}" width="${i.toFixed(1)}" height="${a.toFixed(1)}" rx="${c.toFixed(1)}" fill="${s?yk(o,.42):o}"/>`,f=l?`<rect x="${(-i/2+3).toFixed(1)}" y="${(-a+2).toFixed(1)}" width="${(i-6).toFixed(1)}" height="${l.toFixed(1)}" rx="${(c*.5).toFixed(1)}" fill="${yk(o,1.24)}" opacity="0.85"/>`:``,p=s?``:`<rect x="${(-i/2).toFixed(1)}" y="${(-a*.28).toFixed(1)}" width="${i.toFixed(1)}" height="${(a*.28).toFixed(1)}" rx="${c.toFixed(1)}" fill="${yk(o,.78)}" opacity="0.5"/>`,m=Y(Math.round(15*r),8,22);return`${u}${d}${p}${f}${s?``:`<text x="0" y="${(-a/2).toFixed(1)}" text-anchor="middle" dominant-baseline="central" font-family="Nunito,system-ui,sans-serif" font-weight="800" font-size="${m}" fill="#f2f5f8" opacity="0.92" letter-spacing="0.5">${(e.label||``).toString().slice(0,12).toUpperCase()}</text>`}`}function WP(e,t){let[n,r]=QP[e.size]||QP.M,i=e.depthScale==null?1:e.depthScale,a=n*i,o=r*i,s=e.silhouette==null?e.z!=null&&e.z>.72:e.silhouette,c=e.shadow===!1?``:`<ellipse cx="0" cy="4" rx="${(a*.56).toFixed(1)}" ry="${(9*i).toFixed(1)}" fill="#000" opacity="${s?.1:.16}"/>`,l=`0 0 ${t.w||100} ${t.h||100}`,u=s?` style="filter:brightness(0.28) saturate(0.4)"`:``;return`${c}${`<svg x="${(-a/2).toFixed(1)}" y="${(-o).toFixed(1)}" width="${a.toFixed(1)}" height="${o.toFixed(1)}" viewBox="${l}" preserveAspectRatio="xMidYMax meet" overflow="visible"${u}>${t.inner}</svg>`}`}function GP(e){let[t,n]=QP[e.size]||QP.M,r=e.depthScale==null?1:e.depthScale,i=t*r,a=n*r;return{muzzle:{dx:i*.5,dy:-a*.62},smoke:{dx:0,dy:-a},center:{dx:0,dy:-a*.5}}}function KP(e){let t=e.depthScale||1,n=(rF[e.size]||94)*t/2,r=e.tint||VP(e.label),i=e.silhouette,a=(e.label||``).toString().slice(0,5).toUpperCase();return oF(t,n*.9,e.shadow)+`<circle cx="0" cy="${-n}" r="${n.toFixed(1)}" fill="${i?yk(r,.45):r}"/><circle cx="0" cy="${-n}" r="${n.toFixed(1)}" fill="none" stroke="rgba(0,0,0,.16)"/>`+(i?``:`<text x="0" y="${(-n+aF(t)*.36).toFixed(1)}" text-anchor="middle" dominant-baseline="middle" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${aF(t,16)}" fill="#fff">${a}</text>`)}function qP(e){let t=e.depthScale||1,n=(rF[e.size]||94)*t/2,r=e.tint||`#8aa0b5`,i=e.silhouette,a=iF(e.label);return oF(t,n*.9,e.shadow)+`<circle cx="0" cy="${-n}" r="${(n+3*t).toFixed(1)}" fill="none" stroke="${i?yk(r,.5):r}" stroke-width="${(3.5*t).toFixed(1)}"/><circle cx="0" cy="${-n}" r="${n.toFixed(1)}" fill="${i?yk(`#c9b7a6`,.5):`#d9c7b6`}"/>`+(i?``:`<text x="0" y="${(-n+aF(t)*.36).toFixed(1)}" text-anchor="middle" dominant-baseline="middle" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${aF(t,18)}" fill="${r}">${a}</text>`)}function JP(e){let[t,n]=QP[e.size]||QP.M,r=e.depthScale||1,i=t*r,a=n*r,o=e.tint||`#7a8794`,s=e.silhouette,c=(e.label||`IMAGE`).toString().slice(0,12).toUpperCase(),l=`<rect x="${-i/2}" y="${-a}" width="${i.toFixed(1)}" height="${a.toFixed(1)}" rx="6" fill="${s?yk(o,.42):`#eef1f4`}" stroke="${s?yk(o,.3):o}" stroke-width="${(3*r).toFixed(1)}"/>`,u=s?``:`<line x1="${-i/2+6}" y1="-6" x2="${i/2-6}" y2="${-a+8}" stroke="${o}" stroke-width="1.5" opacity="0.5"/><line x1="${-i/2+6}" y1="${-a+8}" x2="${i/2-6}" y2="-6" stroke="${o}" stroke-width="1.5" opacity="0.5"/><rect x="${-i/2}" y="${-a*.26}" width="${i.toFixed(1)}" height="${(a*.26).toFixed(1)}" rx="0" fill="${o}" opacity="0.9"/><text x="0" y="${(-a*.1).toFixed(1)}" text-anchor="middle" font-family="Nunito,system-ui,sans-serif" font-weight="800" font-size="${aF(r,13)}" fill="#fff">${c}</text>`;return oF(r,i*.5,e.shadow)+l+u}function YP(e){let t=e.depthScale||1,n=(rF[e.size]||94)*.7*t,r=e.tint||VP(e.label),i=e.silhouette,a=iF(e.label).slice(0,1)||`A`;return oF(t,n*.6,e.shadow)+`<rect x="${-n/2}" y="${-n}" width="${n.toFixed(1)}" height="${n.toFixed(1)}" rx="${(n*.22).toFixed(1)}" fill="${i?yk(r,.45):r}"/>`+(i?``:`<text x="0" y="${(-n/2+aF(t)*.36).toFixed(1)}" text-anchor="middle" dominant-baseline="middle" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${aF(t,22)}" fill="#fff">${a}</text>`)}function XP(e){switch(e.face){case`flagRoundel`:return KP(e);case`portraitCircle`:return qP(e);case`imageFrame`:return JP(e);case`logoTile`:return YP(e);default:return UP(e)}}function ZP(e){if(!e.face||e.face===`assetBox`)return GP(e);let t=e.depthScale==null?1:e.depthScale;if(e.face===`imageFrame`){let[n,r]=QP[e.size]||QP.M,i=n*t,a=r*t;return{muzzle:{dx:i*.5,dy:-a*.5},smoke:{dx:0,dy:-a},center:{dx:0,dy:-a*.5}}}let n=(rF[e.size]||94)*t,r=n/2;return{muzzle:{dx:r*.8,dy:-r},smoke:{dx:0,dy:-n},center:{dx:0,dy:-r}}}var QP,$P,eF,tF,nF,rF,iF,aF,oF,sF=o((()=>{Tk(),QP={S:[78,54],M:[128,88],L:[198,134]},$P=[`ground`,`hover`,`mounted`],eF={default:`#4a5a6b`,tank:`#59636f`,jet:`#6b7686`,hq:`#6a5a72`,monument:`#7a6a54`,ship:`#496072`,arty:`#6b5a4a`,wall:`#5c5750`,truck:`#5a6a5a`},tF=[`assetBox`,`flagRoundel`,`portraitCircle`,`imageFrame`,`logoTile`],nF=e=>tF.includes(e),rF={S:64,M:94,L:132},iF=e=>(e||``).toString().trim().split(/\s+/).map(e=>e[0]||``).join(``).slice(0,3).toUpperCase()||(e||`?`).slice(0,2).toUpperCase(),aF=(e,t=15,n=8,r=22)=>Y(Math.round(t*e),n,r),oF=(e,t,n)=>n===!1?``:`<ellipse cx="0" cy="4" rx="${t.toFixed(1)}" ry="${(8*e).toFixed(1)}" fill="#000" opacity="0.14"/>`}));function cF(e,t,n){let r=hF[e.type];return r?r(e,t,n):``}var lF,uF,dF,fF,pF,mF,hF,gF=o((()=>{lF=[`flashImpact`,`smokeColumn`,`emberField`,`tracerArc`,`burst`,`speedLines`,`muzzleFlash`,`dustPuff`,`splash`,`ripple`,`glowPulse`,`shockwaveRing`,`confetti`,`sparkleGlint`,`coinBurst`,`heartsPuff`,`steamWisp`],uF=[`burst`,`flashImpact`,`shockwaveRing`],dF={flashImpact:`screen`,speedLines:`screen`},fF={flashImpact:.16,muzzleFlash:.22,burst:.75,tracerArc:.7,smokeColumn:4,emberField:4,speedLines:1.5,dustPuff:.6,splash:.6,ripple:.9,glowPulse:2,shockwaveRing:.5,confetti:1.8,sparkleGlint:.7,coinBurst:.9,heartsPuff:1.6,steamWisp:3},pF=e=>dF[e]||`world`,mF=(e,t=.12,n=.25)=>Math.max(0,Math.min(1,e/t,(1-e)/n)),hF={smokeColumn(e,t,n){let r=e.tint||`#8b909a`,i=e.scale||1,a=mF(t,.15,.35),o=``;for(let e=0;e<6;e++){let t=(n*.4+e/6)%1,s=-t*160*i,c=(10+t*34)*i,l=a*(1-t)*.5;o+=`<circle cx="${(Math.sin(t*3+e)*10*i).toFixed(1)}" cy="${s.toFixed(1)}" r="${c.toFixed(1)}" fill="${r}" opacity="${l.toFixed(3)}"/>`}return o},emberField(e,t,n){let r=e.scale||1,i=mF(t,.2,.4),a=``;for(let e=0;e<14;e++){let t=(n*.6+e*.137)%1,o=(Math.sin(e*2.3)*40+Math.sin(n+e)*6)*r,s=-t*180*r,c=i*(1-t);a+=`<circle cx="${o.toFixed(1)}" cy="${s.toFixed(1)}" r="${((2+Math.sin(e)*1)*r).toFixed(1)}" fill="#ffb24a" opacity="${c.toFixed(3)}"/>`}return a},tracerArc(e,t){let n=e.bx==null?120:e.bx,r=e.by==null?-40:e.by,i=Math.min(1,t/.6),a=n*.5,o=Math.min(0,r)-70,s=2*(1-i)*i*a+i*i*n,c=2*(1-i)*i*o+i*i*r,l=1-Math.max(0,(t-.6)/.4);return`<path d="M 0 0 Q ${a.toFixed(1)} ${o.toFixed(1)} ${s.toFixed(1)} ${c.toFixed(1)}" stroke="#ffe07a" stroke-width="3" fill="none" opacity="${l.toFixed(3)}" stroke-linecap="round"/>`+(t>.6?`<circle cx="${n.toFixed(1)}" cy="${r.toFixed(1)}" r="${(6+(t-.6)*44).toFixed(1)}" fill="#fff6c8" opacity="${(1-(t-.6)/.4).toFixed(3)}"/>`:``)},burst(e,t){let n=1-t,r=e.scale||1,i=`<circle r="${((6+t*70)*r).toFixed(1)}" fill="none" stroke="#ffcaa0" stroke-width="${(4*n).toFixed(1)}" opacity="${(n*.8).toFixed(3)}"/>`;for(let e=0;e<10;e++){let a=e/10*6.283,o=(20+t*90)*r;i+=`<line x1="${(Math.cos(a)*10*r).toFixed(1)}" y1="${(Math.sin(a)*10*r).toFixed(1)}" x2="${(Math.cos(a)*o).toFixed(1)}" y2="${(Math.sin(a)*o).toFixed(1)}" stroke="#ffd85e" stroke-width="${(3*n).toFixed(1)}" opacity="${n.toFixed(3)}"/>`}return i},muzzleFlash(e,t){let n=Math.max(0,1-t*3),r=e.scale||1;return n<=0?``:`<circle r="${((10+t*6)*r).toFixed(1)}" fill="#fff2b0" opacity="${n.toFixed(3)}"/><path d="M0 0 L ${(28*r).toFixed(1)} ${(-4*r).toFixed(1)} L ${(30*r).toFixed(1)} ${(4*r).toFixed(1)} Z" fill="#ffd85e" opacity="${n.toFixed(3)}"/>`},flashImpact(e,t){let n=Math.max(0,1-t*1.4);return`<rect x="-80" y="-80" width="${(e.VBW||1138)+160}" height="800" fill="${e.tint||`#ffffff`}" opacity="${(n*(e.intensity||.9)).toFixed(3)}"/>`},speedLines(e,t,n){let r=mF(t,.1,.3),i=e.VBW||1138,a=``;for(let e=0;e<9;e++){let t=e/9*640+20,o=(n*320+e*61)%(i+200);a+=`<line x1="${(o-180).toFixed(1)}" y1="${t.toFixed(1)}" x2="${o.toFixed(1)}" y2="${t.toFixed(1)}" stroke="#ffffff" stroke-width="2" opacity="${(r*.32).toFixed(3)}"/>`}return a}},Object.assign(hF,{dustPuff(e,t){let n=1-t,r=e.scale||1,i=``;for(let e=0;e<5;e++){let a=e/5*6.283,o=(10+t*46)*r;i+=`<circle cx="${(Math.cos(a)*o).toFixed(1)}" cy="${(-Math.sin(a)*o*.5).toFixed(1)}" r="${((10+t*16)*r).toFixed(1)}" fill="#b9ad97" opacity="${(n*.5).toFixed(2)}"/>`}return i},splash(e,t){let n=e.scale||1,r=1-t,i=`<path d="M ${(-24*n).toFixed(1)} 0 Q 0 ${(-30*(1-Math.abs(t-.4))*n).toFixed(1)} ${(24*n).toFixed(1)} 0" fill="none" stroke="#8fd0e0" stroke-width="${(3*r).toFixed(1)}" opacity="${r.toFixed(2)}"/>`;for(let e=0;e<6;e++){let a=e/6*Math.PI,o=(14+t*40)*n;i+=`<circle cx="${(Math.cos(a)*o).toFixed(1)}" cy="${(-Math.sin(a)*o).toFixed(1)}" r="${(3*r).toFixed(1)}" fill="#7fb2e0" opacity="${r.toFixed(2)}"/>`}return i},ripple(e,t){let n=e.scale||1,r=``;for(let e=0;e<3;e++){let i=t-e*.18;i<=0||(r+=`<ellipse cx="0" cy="0" rx="${(i*70*n).toFixed(1)}" ry="${(i*24*n).toFixed(1)}" fill="none" stroke="#9fd0e8" stroke-width="2" opacity="${((1-i)*.7).toFixed(2)}"/>`)}return r},glowPulse(e,t){let n=.5+.5*Math.sin(t*Math.PI*4),r=(26+n*14)*(e.scale||1),i=e.tint||`#ffe07a`;return`<circle r="${r.toFixed(1)}" fill="${i}" opacity="${(.18+n*.16).toFixed(2)}"/><circle r="${(r*.5).toFixed(1)}" fill="${i}" opacity="${(.2+n*.2).toFixed(2)}"/>`},shockwaveRing(e,t){let n=e.scale||1,r=1-t;return`<circle r="${(t*130*n).toFixed(1)}" fill="none" stroke="#ffffff" stroke-width="${(8*r).toFixed(1)}" opacity="${(r*.8).toFixed(2)}"/>`},confetti(e,t,n){let r=e.scale||1,i=[`#ff6b5e`,`#2bb3a3`,`#f2b134`,`#5b6ce0`,`#ff7ab0`],a=``;for(let e=0;e<16;e++){let o=(e*37%100-50)*r,s=(-40+t*120+e%5*8)*r,c=(n*6+e)%6.283;a+=`<rect x="${o.toFixed(1)}" y="${s.toFixed(1)}" width="${(7*r).toFixed(1)}" height="${(11*r).toFixed(1)}" fill="${i[e%5]}" transform="rotate(${(c*57).toFixed(0)} ${o.toFixed(1)} ${s.toFixed(1)})" opacity="${(1-t*.6).toFixed(2)}"/>`}return a},sparkleGlint(e,t,n){let r=e.scale||1,i=``;for(let e=0;e<4;e++){let a=e/4*6.283,o=22*r,s=.5+.5*Math.sin(n*8+e*2),c=(5+s*5)*r,l=Math.cos(a)*o,u=Math.sin(a)*o;i+=`<path transform="translate(${l.toFixed(1)} ${u.toFixed(1)})" d="M0 ${-c} L ${c*.3} ${-c*.3} L ${c} 0 L ${c*.3} ${c*.3} L 0 ${c} L ${-c*.3} ${c*.3} L ${-c} 0 L ${-c*.3} ${-c*.3} Z" fill="#fff2b0" opacity="${(s*(1-t)).toFixed(2)}"/>`}return i},coinBurst(e,t,n){let r=e.scale||1,i=``;for(let e=0;e<8;e++){let a=e/8*6.283,o=Math.sin(t*Math.PI),s=Math.cos(a)*t*60*r,c=(-o*70+t*40)*r;i+=`<ellipse cx="${s.toFixed(1)}" cy="${c.toFixed(1)}" rx="${((7+3*Math.sin(n*8+e))*r).toFixed(1)}" ry="${(9*r).toFixed(1)}" fill="#f2b134" stroke="#c98a3a" stroke-width="1" opacity="${(1-t*.7).toFixed(2)}"/>`}return i},heartsPuff(e,t,n){let r=e.scale||1,i=``;for(let e=0;e<5;e++){let a=(t+e*.18)%1,o=(Math.sin(n+e*2)*20+(e-2)*12)*r,s=-a*90*r;i+=`<path transform="translate(${o.toFixed(1)} ${s.toFixed(1)}) scale(${((.5+(1-a)*.5)*r).toFixed(2)})" d="M0 3 C -7 -8 -20 0 0 14 C 20 0 7 -8 0 3 Z" fill="#ff6b8a" opacity="${(1-a).toFixed(2)}"/>`}return i},steamWisp(e,t,n){let r=e.scale||1,i=mF(t,.2,.4),a=``;for(let e=0;e<2;e++){let t=(e?12:-12)*r;a+=`<path d="M ${t} 0 ${[0,1,2,3].map(i=>`Q ${(t+Math.sin(n*1.2+i+e)*14*r).toFixed(1)} ${(-20*(i+.5)*r).toFixed(1)} ${(t+Math.sin(n*1.2+i+1+e)*10*r).toFixed(1)} ${(-20*(i+1)*r).toFixed(1)}`).join(` `)}" fill="none" stroke="#dfeaf2" stroke-width="${(6*r).toFixed(1)}" stroke-linecap="round" opacity="${(i*.4).toFixed(2)}"/>`}return a}})}));function _F(e,t){let n=[],r=Math.max(1,t|0);if(e===`column`){for(let e=0;e<r;e++)n.push({nx:e%2?.16:-.16,row:e,depthRank:r>1?e/(r-1):0});return n}if(e===`line`){for(let e=0;e<r;e++)n.push({nx:r>1?e/(r-1)*2-1:0,row:0,depthRank:0});return n}if(e===`wedge`){let e=0,t=0;for(;e<r;){let i=t*2+1;for(let a=0;a<i&&e<r;a++)n.push({nx:i>1?a/(i-1)*2-1:0,row:t,depthRank:0}),e++;t++}let i=t-1;return n.forEach(e=>e.depthRank=i>0?e.row/i:0),n}let i=Math.ceil(Math.sqrt(r)),a=Math.ceil(r/i);for(let e=0;e<r;e++){let t=e%i,r=Math.floor(e/i);n.push({nx:i>1?t/(i-1)*2-1:0,row:r,depthRank:a>1?r/(a-1):0})}return n}function vF(e,t){let n=e.depthScale||1,r=e.tier===`far`,i=e.cycle||`march`,a=t*(i===`run`||i===`flee`?8:i===`idle`?1.5:5)+(e.phase||0),o=i===`idle`?2:i===`cheer`?1:i===`run`||i===`flee`?20:13,s=Math.sin(a)*o,c=Math.sin(a+Math.PI)*o,l=i===`cheer`,u=i===`flee`?22:i===`idle`?3:9,d=Math.sin(a+Math.PI)*u,f=Math.sin(a)*u,p=i===`run`||i===`flee`?6:0,m=i===`flee`?-3*n:0,h=108*n,g=-h*.42,_=-h*.72,v=-h*.86,y=6*n,b=r?`#2b333f`:yF(`#5c6b52`,e.tone||0),x=r?b:yF(`#c99a6a`,(e.tone||0)*.5),S=Math.max(2,7*n),C=Math.max(2,5.5*n),w=(e,t)=>`<line x1="${e.toFixed(1)}" y1="${g.toFixed(1)}" x2="${(e+t*n+p*n).toFixed(1)}" y2="0" stroke="${b}" stroke-width="${S.toFixed(1)}" stroke-linecap="round"/>`,T=(e,t)=>l?`<line x1="${e.toFixed(1)}" y1="${(_+3*n).toFixed(1)}" x2="${(e+Math.sign(e)*10*n).toFixed(1)}" y2="${(_-20*n).toFixed(1)}" stroke="${b}" stroke-width="${C.toFixed(1)}" stroke-linecap="round"/>`:`<line x1="${e.toFixed(1)}" y1="${(_+3*n).toFixed(1)}" x2="${(e+t*n).toFixed(1)}" y2="${(_+24*n).toFixed(1)}" stroke="${b}" stroke-width="${C.toFixed(1)}" stroke-linecap="round"/>`,E=`<ellipse cx="0" cy="2" rx="${(15*n).toFixed(1)}" ry="${(4*n).toFixed(1)}" fill="#000" opacity="0.12"/>`,D=`<rect x="${(-9*n).toFixed(1)}" y="${_.toFixed(1)}" width="${(18*n).toFixed(1)}" height="${(g-_+4*n).toFixed(1)}" rx="${(6*n).toFixed(1)}" fill="${b}"/>`,O=`<circle cx="${m.toFixed(1)}" cy="${v.toFixed(1)}" r="${(9*n).toFixed(1)}" fill="${x}"/>`+(r?``:`<path d="M ${(m-10*n).toFixed(1)} ${(v-3*n).toFixed(1)} q ${(10*n).toFixed(1)} ${(-12*n).toFixed(1)} ${(20*n).toFixed(1)} 0 z" fill="${b}"/>`);return`<g opacity="${(e.opacity==null?1:e.opacity).toFixed(3)}">${E}${w(-y,s)}${w(y,c)}${D}${T(-10*n,d)}${T(10*n,f)}${O}</g>`}var yF,bF=o((()=>{Tk(),yF=(e,t)=>yk(e,1+t)}));function xF(e,t){return(e||[]).map(e=>DF[e]?DF[e](t):``).join(``)}var SF,CF,wF,TF,EF,DF,OF=o((()=>{SF=[`wet`,`cold`,`hot`,`dirty`,`sleepy`,`inLove`,`confused`,`injured`],CF=(e,t=1)=>e.toFixed(t),wF=(e,t,n,r,i=`#ff6b8a`)=>`<path transform="translate(${CF(e)} ${CF(t)}) scale(${CF(n,3)})" d="M0 3 C -7 -8 -20 0 0 14 C 20 0 7 -8 0 3 Z" fill="${i}" opacity="${CF(r,2)}"/>`,TF=(e,t,n,r,i)=>`<line x1="${CF(e)}" y1="${CF(t)}" x2="${CF(e)}" y2="${CF(t+n)}" stroke="${r}" stroke-width="3" stroke-linecap="round" opacity="${CF(i,2)}"/>`,EF=(e,t,n,r,i,a=1)=>`<text x="${CF(e)}" y="${CF(t)}" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${CF(n)}" text-anchor="middle" fill="${i}" opacity="${CF(a,2)}">${r}</text>`,DF={wet:e=>{let t=``;for(let n=0;n<5;n++){let r=(e*.8+n*.2)%1,i=-34+n*17;t+=TF(i,30+r*70,8,`#7fb2e0`,1-r)}return t},cold:e=>{let t=e*.55%1;return`<ellipse cx="20" cy="6" rx="${CF(5+t*12)}" ry="${CF(3+t*7)}" fill="#e6eef4" opacity="${CF(.55*(1-t),2)}"/>`+TF(-24,-34,6,`#bcd7e4`,.8)+TF(24,-30,6,`#bcd7e4`,.8)},hot:e=>{let t=``;for(let n=0;n<2;n++){let r=(e*.7+n*.5)%1;t+=`<path transform="translate(${CF(n?26:-26)} ${CF(-24+r*30)})" d="M0 -6 C 5 0 5 8 0 8 C -5 8 -5 0 0 -6 Z" fill="#8fd0e0" opacity="${CF(1-r,2)}"/>`}return t},dirty:()=>{let e=``;return[[-20,34,10],[16,46,8],[-6,60,7],[24,30,6]].forEach(([t,n,r])=>e+=`<circle cx="${t}" cy="${n}" r="${r}" fill="#6b5a45" opacity="0.5"/>`),e},sleepy:e=>{let t=``;for(let n=0;n<3;n++){let r=(e*.5+n*.33)%1;t+=EF(18+r*30,-30-r*40,12+r*10,`Z`,`#5b6ce0`,1-r)}return t},inLove:e=>{let t=``;for(let n=0;n<3;n++){let r=(e*.6+n*.34)%1;t+=wF(-14+n*16+Math.sin(e*2+n)*6,-26-r*50,.7+(1-r)*.5,1-r)}return t},confused:e=>EF(0,-38+Math.sin(e*2.5)*4,30,`?`,`#c98a3a`)+`<circle cx="14" cy="-14" r="3" fill="#c98a3a" opacity="${CF(.5+.5*Math.sin(e*4),2)}"/>`,injured:()=>`<rect x="-18" y="-16" width="36" height="12" rx="3" fill="#e8dcc0" transform="rotate(-16)"/><rect x="-3" y="-22" width="6" height="12" fill="#c05050" transform="rotate(-16)"/><rect x="-9" y="-16" width="12" height="4" fill="#c05050" transform="rotate(-16)"/>`}}));function kF(e,t,n,r){let i=e.enter;if(!i||i.type===`carryOver`)return{};let a=i.type,o=i.atPhrase==null?n:t[i.atPhrase].t,s=o+YF,c=e.pos&&e.pos.x||.5,l=a===`walkIn`||a===`runIn`;if(r<o)return l?{opacity:1,xOverride:XF(i.from),forceWalk:a===`walkIn`,forceRun:a===`runIn`}:a===`dropIn`?{opacity:0,yOverride:-280}:a===`riseFrom`?{opacity:0,yOverride:220}:{opacity:0};if(r>=s)return{};let u=Ck((r-o)/YF);if(l)return{opacity:1,xOverride:xk(XF(i.from),c,u),forceWalk:a===`walkIn`,forceRun:a===`runIn`};if(a===`popIn`){let e=Ck(Y((r-o)/.3,0,1));return{opacity:e,scaleMul:.55+.45*e+Math.max(0,Math.sin(e*Math.PI))*.15}}return a===`dropIn`?{opacity:Y(u*2,0,1),yOverride:xk(-280,0,u)}:a===`riseFrom`?{opacity:Y(u*2,0,1),yOverride:xk(220,0,u)}:{opacity:u}}function AF(e,t){let n=_k(e||`x`),r=7+n%5,i=.5+.5*Math.sin(t*(2.3+n%3)),a=Y(i*(.55+.45*Math.sin(t*r))*(Math.sin(t*1.9+n%7)>-.4?1:.15),0,1);return{mOpen:1+a*14,mWidth:12+a*16,mCurve:2+Math.sin(t*4.6)*5}}function jF(e){if(!e||!Array.isArray(e.phrases))throw new nI(`audio.phrases must be an array`);let t=e.phrases.map((e,t)=>{if(typeof e==`string`){let n=e.match(/^(\d+):(\d+(?:\.\d+)?)\s+(.*)$/);if(!n)throw new nI(`phrase ${t} is not "M:SS.d text": ${JSON.stringify(e)}`);return{t:n[1]*60+parseFloat(n[2]),text:n[3]}}if(e&&typeof e==`object`&&typeof e.t==`number`&&typeof e.text==`string`)return{t:e.t,text:e.text};throw new nI(`phrase ${t} must be "M:SS.d text" or {t:Number,text:String}`)});if(t.sort((e,t)=>e.t-t.t),!t.length)throw new nI(`audio.phrases is empty`);return t}function MF(e,t){return e.meta&&typeof e.meta.durationMs==`number`?e.meta.durationMs/1e3:t[t.length-1].t+tI}function NF(e,t){let n=0;for(let r=0;r<e.length;r++)e[r].t<=t+1e-9&&(n=r);return n}function PF(e,t,n){let r=e.map((e,t)=>({s:e,i:t})).sort((e,t)=>e.s.startPhrase-t.s.startPhrase);return r.map((e,i)=>{let a=t[e.s.startPhrase].t,o=i+1<r.length?t[r[i+1].s.startPhrase].t:n;return{scene:e.s,t0:a,t1:o}})}function FF(e,t){let n=vk(e),r=1.2+n()*2;for(;r<=t+.14;){if(t>=r&&t<r+.14)return Math.sin(Math.PI*(t-r)/.14);r+=2.64+n()*3}return 0}function IF(e,t,n,r){let i=`idle`,a=r,o=`idle`,s=r,c=null,l=(e.track||[]).filter(e=>e.action).sort((e,t)=>e.atPhrase-t.atPhrase);for(let e of l)e.atPhrase<=n&&(o=i,s=a,i=e.action,a=t[e.atPhrase].t,c=e);let u={};return c&&(c.speed&&(u.speed=c.speed),c.intensity&&(u.intensity=c.intensity),c.target!=null&&(u.target=c.target)),{action:i,start:a,prevAction:o,prevStart:s,opts:u}}function LF(e,t,n,r){let i=e.facing||`front`,a=-99,o=(e.track||[]).slice().sort((e,t)=>e.atPhrase-t.atPhrase);for(let e of o)if(e.atPhrase<=n&&(e.facing||e.action===`turn`)){let n=e.facing||i;(n!==i||e.action===`turn`)&&(n!==i&&(i=n),a=t[e.atPhrase].t)}let s=Math.abs(r-a),c=a>=0&&s<QF?.15+s/QF*.85:1;return{facing:i,squash:c}}function RF(e,t,n,r,i){let a=nF(e.face)?e.face:`assetBox`,o=e.plane==null?.5:e.plane,s=rP(o,r),c=e.x==null?.5:e.x,l=$P.includes(e.placement)?e.placement:`ground`,u=c*n,d;if(l===`hover`){let n=HP(t,_k(e.label||`x`)%20*.31);u+=n.dx,d=205+s.yShift*.35+n.dy}else d=l===`mounted`?480+s.yShift:GF+s.yShift;let f={kind:`placeholder`,face:a,id:e.id||null,label:e.label||``,size:e.size||`M`,placement:l,source:e.source||`placeholder`,z:o,x:u,y:d,depthScale:s.scale,opacity:s.opacity,blur:s.blur,tint:e.tint||(a===`assetBox`||a===`flagRoundel`||a===`logoTile`?VP(e.label):null),silhouette:o>.72},p=ZP({face:a,size:f.size,depthScale:f.depthScale});return f.anchors={muzzle:{x:u+p.muzzle.dx,y:d+p.muzzle.dy},smoke:{x:u+p.smoke.dx,y:d+p.smoke.dy},center:{x:u+p.center.dx,y:d+p.center.dy}},f.emits=e.emits||[],f}function zF(e,t,n,r,i){let a=Y(e.count|0,1,60),o=KF.includes(e.shape)?e.shape:`grid`,s=qF.includes(e.cycle)?e.cycle:`march`,c=e.plane==null?.6:e.plane,l=e.x==null?.5:e.x,u=(e.width==null?.55:e.width)*n,d=vk(i+`:form:`+(e.id||e.ref||`s`)),f=_F(o,a).map(e=>{let t=Y(c+e.depthRank*.16,0,.98),i=rP(t,r),a=1+(d()-.5)*.08,o=(d()-.5)*.16,f=l*n+e.nx*u*.5*(1-e.depthRank*.14)+(d()-.5)*12,p=GF+i.yShift-e.depthRank*6,m=t>.72?`far`:t>.52?`mid`:`near`;return{x:f,y:p,z:t,depthScale:i.scale*a,opacity:i.opacity,phase:d()*6.283,cycle:s,tone:o,tier:m}}).sort((e,t)=>t.z-e.z);return{kind:`formation`,z:f.reduce((e,t)=>e+t.z,0)/Math.max(1,f.length),id:e.id||null,count:f.length,cycle:s,units:f}}function BF(e,t,n,r,i){let a=Y(e.count|0,1,50),o=e.plane==null?.62:e.plane,s=e.dir===`left`?-1:1,c=(e.speed||1)*42,l=n*1.3,u=-n*.15,d=qF.includes(e.cycle)?e.cycle:`march`,f=vk(i+`:flow:`+(e.id||e.ref||`f`)),p=[];for(let e=0;e<a;e++){let e=((f()*l+t*c*s)%l+l)%l,n=u+e,i=Y(Math.min(e/(l*.08),(l-e)/(l*.08),1),0,1),a=Y(o+(f()-.5)*.08,0,.98),m=rP(a,r);p.push({x:n,y:GF+m.yShift,z:a,depthScale:m.scale*(1+(f()-.5)*.06),opacity:m.opacity*i,phase:f()*6.283,cycle:d,tone:(f()-.5)*.16,tier:a>.72?`far`:a>.52?`mid`:`near`})}return p.sort((e,t)=>t.z-e.z),{kind:`formation`,z:o,id:e.id||null,count:a,cycle:d,units:p}}function VF(e,t,n,r){let i=e.pos&&typeof e.pos.x==`number`?e.pos.x:.5,a=(e.track||[]).filter(e=>e.action===`walk`&&e.to&&typeof e.to.x==`number`).sort((e,t)=>e.atPhrase-t.atPhrase);for(let e=0;e<a.length;e++){let o=a[e],s=t[o.atPhrase].t,c=a[e+1]?t[a[e+1].atPhrase].t:Math.min(s+2.2,n),l=o.to.x;if(r>=c)i=l;else if(r>=s){i=xk(i,l,Ck((r-s)/Math.max(.001,c-s)));break}else break}return i}function HF(e,t){let n=jF(e.audio),r=MF(e,n),i=Y(t,0,r),a=e.meta&&e.meta.aspect||`16:9`,o=Ek(a),s=e.meta&&e.meta.seed||42,c=e.meta&&e.meta.style||{},l=c.bob!==!1,u=c.shadow!==!1,d=NF(n,i),f=PF(e.scenes,n,r),p=f[0];for(let e of f)i>=e.t0-1e-9&&(p=e);let m=null,h=1;if(i<p.t0+eI){let e=f[f.indexOf(p)-1];e&&(m=UF(e.scene),h=Y((i-p.t0)/eI,0,1))}let g=UF(p.scene),_=e.meta&&e.meta.palette||`auto`,v={};e.cast.forEach(e=>v[e.id]=sj(e.params||{},_));let y=p.scene,b={},x=[],S=[],C=UM(y.setup.name)?uM[y.setup.palette||`day`]||`light`:KM[y.setup.name]||`light`;(y.dialogue||[]).forEach(e=>{e.phrase===d&&(e.style===`narrationCard`?S.push({text:e.text||n[e.phrase].text,anchor:e.anchor||`skyBand`,tone:C}):e.style===`fullCard`?S.push({text:e.text||n[e.phrase].text,tone:C,full:!0}):(b[e.speaker]=!0,x.push({ref:e.speaker,text:e.text||n[e.phrase].text,tStart:n[e.phrase].t})))});let w=y.cast||[],T={};w.forEach(e=>{let t=kF(e,n,p.t0,i),a=t.xOverride==null?VF(e,n,r,i):t.xOverride,s=e.pos&&typeof e.pos.z==`number`?e.pos.z:.5,{facing:c,squash:l}=LF(e,n,d,i);T[e.ref]={xn:a,rigX:a*o,z:s,facing:c,squash:l,enterOpacity:t.opacity,forceWalk:t.forceWalk,forceRun:t.forceRun,yOverride:t.yOverride,scaleMul:t.scaleMul}});let E=(e,t)=>{let n=T[e];if(!n)return{aimDX:0,aimDY:0};let r=n.rigX,i=n.z;if(t&&typeof t==`object`&&typeof t.x==`number`)r=t.x*o,typeof t.z==`number`&&(i=t.z);else if(typeof t==`string`){let e=T[t.replace(/^cast:/,``)];e&&(r=e.rigX,i=e.z)}return{aimDX:Y((r-n.rigX)/(o*.35),-1,1),aimDY:Y((n.z-i)*1.4,-1,1)}},D=w.map(e=>{let t=T[e.ref],r=IF(e,n,d,p.t0),a=t.forceRun?`run`:t.forceWalk?`walk`:r.action,o=t.forceWalk||t.forceRun?{speed:t.forceRun?1.5:1.15}:r.opts,u=t.forceWalk||t.forceRun?p.t0:r.start,f={...o};if(eA.includes(a)&&o.target!=null){let t=E(e.ref,o.target);f.aimDX=t.aimDX,f.aimDY=t.aimDY}let m=WF(Wk(a,i,f)),h=WF(Wk(r.prevAction,r.prevStart,r.opts)),g=Ck(Y((i-u)/$F,0,1)),_={};for(let e of Object.keys(Nk))_[e]=xk(h[e],m[e],g);_.blink=FF(s+`:`+e.ref,i);let S=!!b[e.ref];if(S){_=qk(_,Kk(i));let t=x.find(t=>t.ref===e.ref);Object.assign(_,c.mouth===`amplitude`&&t?AF(t.text,i-t.tStart):Gk(i))}!l&&ZF.includes(a)&&(_.bob=0);let C=rP(t.z,y.setup.mode);return{ref:e.ref,params:v[e.ref]||{},pose:_,states:e.state||[],xNorm:t.xn,rigX:t.rigX,z:t.z,facing:t.facing,squash:t.squash,depthScale:C.scale*(t.scaleMul||1),yShift:C.yShift+(t.yOverride||0),opacity:C.opacity*(t.enterOpacity==null?1:t.enterOpacity),blur:C.blur,action:a,speaking:S}}).sort((e,t)=>t.z-e.z);x.forEach(e=>{let t=T[e.ref];e.z=t?t.z:.5,e.facing=t?t.facing:`front`});let O={};(e.props||[]).forEach(e=>O[e.id]=e);let k=(y.setup&&y.setup.dress||[]).map(e=>{let t=O[e.ref]||{id:e.ref,source:`coded`,ref:e.ref},n=e.presentation||`onSurface`,r,i,a;if(n===`heldBy`){let t=(e.slot||``).replace(/^(cast:|hand:)/,``),n=T[t];if(n)r=n.rigX+(n.facing===`left`?-46:46),i=344,a=n.z;else{let t=Jj(e.slot,o);r=t.x,i=t.y,a=t.z}}else{let t=Jj(e.slot,o);r=t.x,i=t.y,a=t.z}return{id:e.ref,spec:t,slot:e.slot,x:r,y:i,z:a,presentation:n,depthScale:rP(a,y.setup.mode).scale}}),A=[];(y.entities||[]).forEach(e=>{e.type===`assetBox`?A.push(RF({...e,face:`assetBox`},i,o,y.setup.mode,s)):e.type===`placeholder`?A.push(RF(e,i,o,y.setup.mode,s)):e.type===`formation`?A.push(zF(e,i,o,y.setup.mode,s)):e.type===`crowdFlow`&&A.push(BF(e,i,o,y.setup.mode,s))});let j=e=>{if(e&&typeof e==`object`&&typeof e.x==`number`)return{x:e.x*o,y:e.y==null?300:e.y};if(typeof e==`string`){if(e.startsWith(`region:`)){let t=xj(e.slice(7),o);return{x:t.x,y:t.y,tint:t.tint}}if(e.startsWith(`prop:`)){let t=k.find(t=>t.id===e.slice(5));if(t)return{x:t.x,y:t.y-40}}if(e.includes(`.`)){let t=Jj(e,o);return{x:t.x,y:t.y}}let t=T[e.replace(/^cast:/,``)];if(t)return{x:t.rigX,y:240};let n=Jj(e,o);return{x:n.x,y:n.y}}return{x:o/2,y:300}},M=(y.overlays||[]).map(e=>{let t=e.atMs==null?n[e.atPhrase==null?d:e.atPhrase].t:e.atMs/1e3,r=(e.hold==null?4:e.hold/1e3)+.6;if(i<t||i>t+r)return null;let a,s={};if(e.region){let t=xj(e.region,o);a={x:t.x,y:t.y},s.tint=e.tint||t.tint}else a=j(e.anchor||`skyBand`);if(e.from&&e.to){let t=j(e.from),n=j(e.to);a=t,s.bx=n.x-t.x,s.by=n.y-t.y,s.tint=e.tint||t.tint||n.tint}return{...e,...s,p:Y((i-t)/.5,0,1),x:a.x,y:a.y}}).filter(Boolean),N=(y.sfx||[]).map(e=>{let t=e.atMs==null?n[e.atPhrase==null?d:e.atPhrase].t:e.atMs/1e3;return{name:e.name,t0:t,gain:e.gain==null?1:e.gain,firing:i>=t&&i<t+.12}}),P=(y.extras||[]).map((e,t)=>{let n=e.z==null?.78:e.z,r=rP(n,y.setup.mode);return{x:(e.x==null?.5:e.x)*o,z:n,depthScale:r.scale,yShift:r.yShift,opacity:r.opacity,shirt:e.shirt||`#98a4b0`,phase:t*1.7%6.28}}),F=null;{let e=f[f.indexOf(p)-1],t=e&&e.scene.transitionOut,n=e=>{let t=cM[e.setup&&e.setup.palette||`day`];return t&&t.ground||`#3a4657`};if(t&&t.type===`flash`)i<p.t0+JF&&(F={type:`flash`,p:Y((i-p.t0)/JF,0,1),tint:t.tint||`#ffffff`});else if(t&&GN(t.type)&&t.type!==`fade`){let r=Math.max(.3,(t.durationMs||1200)/1e3),a=Y((i-p.t0)/r,0,1);if(i<p.t0+r){let r=t.carrySubject?T[t.carrySubject]:null;F={harness:!0,spec:t,p:a,bridge:[n(e.scene),n(p.scene)],subjectFrom:r?{x:r.rigX,y:400}:{x:o*.3,y:420},subjectTo:r?{x:r.rigX,y:400}:{x:o*.7,y:420}}}}else m&&t&&t.type!==`carry`&&(F={type:t.type||`fade`,bands:t.bands||4,direction:t.direction||`left`,p:Y((i-p.t0)/eI,0,1)})}let I=[];(y.effects||[]).forEach(e=>{let t=e.atMs==null?n[e.atPhrase==null?d:e.atPhrase].t:e.atMs/1e3,r=e.hold==null?fF[e.type]||1:e.hold/1e3;if(i<t||i>t+r)return;let a=Y((i-t)/r,0,1),s=e.at?j(e.at):{x:o/2,y:300},c={type:e.type,space:pF(e.type),p:a,t0:t,tint:e.tint,intensity:e.intensity,scale:e.scale,shake:e.shake,VBW:o};if(e.type===`tracerArc`){let t=e.from?j(e.from):s,n=e.to?j(e.to):{x:t.x+120,y:t.y-40};I.push({...c,x:t.x,y:t.y,bx:n.x-t.x,by:n.y-t.y})}else I.push({...c,x:s.x,y:s.y})}),A.forEach(e=>{e.kind===`placeholder`&&(e.emits||[]).forEach(t=>{let n=e.anchors[t.anchor||(t.type===`muzzleFlash`?`muzzle`:`smoke`)]||e.anchors.center;if(t.type===`muzzleFlash`){let r=1.6,a=i%r/r;a<.14&&I.push({type:`muzzleFlash`,space:`world`,x:n.x,y:n.y,p:a/.14,t0:i-a,tint:t.tint,scale:e.depthScale,VBW:o})}else I.push({type:t.type,space:pF(t.type),x:n.x,y:n.y,p:.5,t0:0,tint:t.tint,scale:e.depthScale,VBW:o})})});let ee=0,te=I.filter(e=>!uF.includes(e.type)||++ee<=2),L=0,R=0;te.forEach(e=>{if(!(e.shake===!0||e.shake!==!1&&e.type===`flashImpact`))return;let t=14*(1-Y((i-e.t0)/.3,0,1)),n=_k(`shk`+e.t0.toFixed(3))%100;L+=Math.sin(i*90+n)*t,R+=Math.cos(i*84+n)*t*.7});let ne={VBW:o,sceneT0:p.t0,sceneT1:p.t1,phrases:n,resolveTarget:j,seed:s,cast:D.map(e=>({rigX:e.rigX}))},re=Wj(y.setup.name)?Ij(y.setup.name,y.setup.seed==null?0:y.setup.seed,y.setup.elements||{}):null,ie=y.camera&&!Array.isArray(y.camera)?y.camera:null,ae=!!(ie||re),oe,se=null,ce=null;if(ae){let e=re?{worldW:re.worldW,worldH:re.worldH,viewW:re.viewW,viewH:re.viewH}:{worldW:o,worldH:640,viewW:o,viewH:640},t=ie&&ie.subjects||(re?re.subjects:[]),n=ie||{mode:`generated`,seed:y.setup.seed||1,style:`editorial`},r=mN(vN(n,{duration:p.t1-p.t0,...e,subjects:t}),i-p.t0);if(n.safeZone&&n.safeZone.enabled!==!1){let t=(n.safeZone.x==null?.22:n.safeZone.x)*e.viewW/r.scale,i=(n.safeZone.y==null?.2:n.safeZone.y)*e.viewH/r.scale;r={...r,x:Y(r.x,t,e.worldW-t),y:Y(r.y,i,e.worldH-i)}}if(se=r,oe={cx:r.x,cy:r.y,zoom:r.scale,rotation:r.rotation,pan:!0,subjectId:r.subjectId,worldW:e.worldW,worldH:e.worldH,viewW:e.viewW,viewH:e.viewH},re&&re.focusRing){let e=t.find(e=>e.id===r.subjectId)||t[0];e&&(ce={x:e.x,y:e.y})}(L||R)&&(oe.cx+=L,oe.cy+=R)}else{oe=gP(y,i,ne);let e=f[f.indexOf(p)-1],t=e&&(!Array.isArray(e.scene.camera)&&e.scene.camera||Wj(e.scene.setup.name));if(m&&i<p.t0+eI&&e&&!t){let t=gP(e.scene,e.t1-.001,{...ne,sceneT0:e.t0,sceneT1:e.t1}),n=Y((i-p.t0)/eI,0,1);oe.cx=xk(t.cx,oe.cx,n),oe.cy=xk(t.cy,oe.cy,n),oe.zoom=xk(t.zoom,oe.zoom,n)}(L||R)&&(oe.cx+=L,oe.cy+=R)}let le=y.setup.weather?typeof y.setup.weather==`string`?{type:y.setup.weather}:{...y.setup.weather}:null,ue=null,de=y.setup.timeRamp;if(de){let e=de.overPhrases||2,t=n[Math.min(n.length-1,(y.startPhrase||0)+e)].t,r=Y((i-p.t0)/Math.max(.1,t-p.t0),0,1),a=cM[de.from]||cM.day,s=cM[de.to]||cM.night;ue={k:r,top:bk(a.skyTop,s.skyTop,r),bot:bk(a.skyBot,s.skyBot,r),alpha:.55*r,sun:{x:o*(.2+.6*r),y:130+r*r*380,a:Y(1-r*1.25,0,1)},moon:{x:o*(.78-.5*r),y:430-r*300,a:Y((r-.4)/.45,0,1)}}}let fe=y.mode===`wordReveal`?`wordReveal`:`normal`,pe=null;if(fe===`wordReveal`){let e=y.wordReveal||{},t={...Df,...e},n=bf(y.words||[],(i-p.t0)*1e3,t,180),r=xf(t.swapAnim,n.enterP);if(pe={word:!n.cleared&&n.word?t.allCaps?n.word.toUpperCase():n.word:``,...r,emphasized:n.emphasized,background:t.background,accent:t.accentColor},Math.round(Number(e.trailCount==null?e.ghostWords:e.trailCount)||0)>0){let e=Tf(y.words||[],(i-p.t0)*1e3,t,180);pe.trail={entries:e.entries.map(e=>({...e,text:t.allCaps?e.text.toUpperCase():e.text,transform:e.role===`current`?xf(t.swapAnim,e.enterP):null})),layout:t.trailLayout,muteColor:t.trailMuteColor,exit:t.trailExit}}}let me=fe===`wordReveal`;return{t:i,dur:r,aspect:a,VBW:o,seed:s,phraseIndex:d,mode:fe,wordReveal:pe,background:{to:g,from:m,mix:h},cast:D,extras:P,entities:A,effects:te,bubbles:me?[]:x,cards:me?[]:S,props:k,overlays:M,transition:F,weather:le,timeGrade:ue,sfx:N,style:{bob:l,shadow:u},board:re?{name:y.setup.name,planes:re.planes,worldW:re.worldW,worldH:re.worldH,viewW:re.viewW,viewH:re.viewH,focusRing:re.focusRing,ring:ce,panels:re.panels}:null,camera:{view:oe,pan:se,bgCam:ae?{pan:0,scale:0}:yP(oe,o),coverage:ae?1:bP(y,ne),richness:ae?1:_P(y,ne),traveling:oe.directive===`travel`,shake:{x:L,y:R}}}}function UF(e){return{name:e.setup.name,seed:e.setup.seed==null?7:e.setup.seed,mode:e.setup.mode||`2.5d`,palette:e.setup.palette||`day`}}function WF(e){return{...Nk,...e}}var GF,KF,qF,JF,YF,XF,ZF,QF,$F,eI,tI,nI,rI=o((()=>{Tk(),Uk(),tA(),bj(),QM(),Gj(),wN(),tP(),uP(),EP(),BP(),sF(),gF(),bF(),Dj(),Pf(),GF=590,KF=[`grid`,`wedge`,`column`,`line`],qF=[`march`,`run`,`flee`,`idle`,`cheer`],JF=.18,YF=1,XF=e=>e===`right`?1.16:-.16,ZF=[`idle`,`stand`,`look`,`lookAround`,`turn`,`talkGesture`,`talk`],QF=.06,$F=.25,eI=.5,tI=3.5,nI=class extends Error{constructor(e){super(e),this.name=`SchemaError`}}}));function iI(e,t){let n=Math.round(Y(15*e,12,27));return{fontPx:n,padY:Math.round(n*.5),padX:Math.round(n*.72),maxWidth:Math.min(t*.72,Math.round(250*e)),radius:Math.round(n*1.05),gap:Math.round(9+n*.4)}}function aI(e,t,n,r,i,a){let o=a.radius,s=a.gap,c=e.h*.5+r*.5+s,l=e.h*.5+i*.5+s,u=e.cx+n.x*c-r/2,d=e.midY+n.y*l-i/2;u=Y(u,10,t.w-10-r),d=Y(d,10,t.h-10-i);let f=u+r/2,p=d+i/2,m=e.cx-f,h=e.midY-p,g;return g=Math.abs(h)>=Math.abs(m)?{side:h>0?`down`:`up`,left:Math.round(Y(e.cx,u+o+4,u+r-o-4)-u-9),top:null}:{side:m>0?`right`:`left`,left:null,top:Math.round(Y(e.midY,d+o+4,d+i-o-4)-d-8)},{left:Math.round(u),top:Math.round(d),tail:g}}function oI(e,t,n=34){return Math.max(0,Math.min(e.length,Math.floor(t*n)))}var sI=o((()=>{Tk()}));function cI(e){let t=`gen:`+e;if(pI.has(t))return pI.get(t);let n=_k(e);vk(e);let r=n%360,i=`hsl(${r} 62% 58%)`,a=`hsl(${r} 55% 38%)`,o=`generic`;for(let[t,n]of fI)if(n.test(e)){o=t;break}let s={svg:`<g data-prop>${dI[o]({c:i,d:a})}</g>`,w:80,h:80,icon:o,cached:!1};return pI.set(t,{...s,cached:!0}),s}function lI(e){return e?e.source===`coded`?{svg:`<g data-prop>${(mI[e.ref]||mI.box)()}</g>`,w:90,h:100}:cI(e.prompt||e.ref||`object`):null}function uI(e,t,n,r=1){let i=r;if(e===`hoverIdle`){let e=Math.sin(n*1.6)*6;return{x:t.x,y:t.y+e,scale:i,shadow:`breathe`,floatY:e}}return e===`pinned`?{x:t.x,y:t.y,scale:i,shadow:`none`}:e===`planeAt`?{x:t.x,y:t.y,scale:i,shadow:`soft`}:{x:t.x,y:t.y,scale:i,shadow:`contact`}}var dI,fI,pI,mI,hI=o((()=>{Tk(),dI={coin:e=>`<g><ellipse cx="0" cy="-30" rx="30" ry="30" fill="${e.c}"/><ellipse cx="0" cy="-30" rx="22" ry="22" fill="none" stroke="${e.d}" stroke-width="3"/><text x="0" y="-22" font-size="26" font-weight="800" text-anchor="middle" fill="${e.d}">$</text></g>`,card:e=>`<g><rect x="-38" y="-52" width="76" height="48" rx="7" fill="${e.c}"/><rect x="-38" y="-40" width="76" height="10" fill="${e.d}"/><rect x="-30" y="-18" width="30" height="6" rx="3" fill="#fff" opacity=".85"/></g>`,house:e=>`<g><rect x="-26" y="-42" width="52" height="42" rx="3" fill="${e.c}"/><path d="M-34 -42 L0 -70 L34 -42 Z" fill="${e.d}"/><rect x="-8" y="-24" width="16" height="24" fill="${e.d}"/></g>`,phone:e=>`<g><rect x="-20" y="-64" width="40" height="64" rx="8" fill="${e.c}"/><rect x="-15" y="-58" width="30" height="46" rx="2" fill="#dfe7ee"/><circle cx="0" cy="-7" r="3" fill="#dfe7ee"/></g>`,key:e=>`<g><circle cx="-16" cy="-46" r="14" fill="none" stroke="${e.c}" stroke-width="8"/><rect x="-6" y="-50" width="42" height="8" rx="3" fill="${e.c}"/><rect x="24" y="-42" width="8" height="12" fill="${e.c}"/></g>`,chart:e=>`<g><rect x="-34" y="-8" width="16" height="30" fill="${e.c}"/><rect x="-8" y="-40" width="16" height="62" fill="${e.d}"/><rect x="18" y="-24" width="16" height="46" fill="${e.c}"/></g>`,clock:e=>`<g><circle cx="0" cy="-34" r="30" fill="${e.c}"/><circle cx="0" cy="-34" r="24" fill="#fff" opacity=".9"/><line x1="0" y1="-34" x2="0" y2="-52" stroke="${e.d}" stroke-width="3"/><line x1="0" y1="-34" x2="14" y2="-34" stroke="${e.d}" stroke-width="3"/></g>`,bag:e=>`<g><path d="M-28 -48 Q-28 -60 0 -60 Q28 -60 28 -48 L34 -4 Q34 2 26 2 L-26 2 Q-34 2 -34 -4 Z" fill="${e.c}"/><path d="M-14 -50 Q-14 -66 0 -66 Q14 -66 14 -50" fill="none" stroke="${e.d}" stroke-width="4"/></g>`,generic:e=>`<g><rect x="-30" y="-58" width="60" height="56" rx="12" fill="${e.c}"/><circle cx="0" cy="-30" r="15" fill="${e.d}"/><rect x="-18" y="-14" width="36" height="7" rx="3.5" fill="${e.d}" opacity=".7"/></g>`},fI=[[`coin`,/coin|gold|money|cash/i],[`card`,/card|credit|debit/i],[`house`,/house|home|mortgage|building/i],[`phone`,/phone|mobile|cell/i],[`key`,/key|lock|access/i],[`chart`,/chart|graph|bar|stat/i],[`clock`,/clock|time|watch|hour/i],[`bag`,/bag|shop|purse|wallet/i]],pI=new Map,mI={bookshelf:()=>`<g><rect x="-40" y="-96" width="80" height="96" rx="3" fill="#8a6a45"/><rect x="-34" y="-90" width="68" height="26" fill="#a9855c"/><rect x="-34" y="-60" width="68" height="26" fill="#a9855c"/><rect x="-34" y="-30" width="68" height="26" fill="#a9855c"/>${[-30,-20,-10,2,12,22].map((e,t)=>`<rect x="${e}" y="${-86-t%2*0}" width="7" height="20" fill="${[`#c0563f`,`#3f7fc0`,`#3fae6b`,`#c9a13a`,`#8b5cf6`,`#e08a3a`][t]}"/>`).join(``)}</g>`,table:()=>`<g><rect x="-44" y="-30" width="88" height="10" rx="3" fill="#a9855c"/><rect x="-40" y="-20" width="8" height="20" fill="#8a6a45"/><rect x="32" y="-20" width="8" height="20" fill="#8a6a45"/></g>`,plant:()=>`<g><path d="M-12 0 L-8 -30 L8 -30 L12 0 Z" fill="#c98a3a"/><circle cx="0" cy="-44" r="20" fill="#3f8f63"/><circle cx="-14" cy="-38" r="13" fill="#4fa576"/><circle cx="14" cy="-40" r="12" fill="#357a53"/></g>`,sign:()=>`<g><rect x="-3" y="-40" width="6" height="40" fill="#8a6a45"/><rect x="-30" y="-72" width="60" height="34" rx="4" fill="#eef2f4" stroke="#c7d0d6" stroke-width="2"/></g>`,box:()=>`<g><rect x="-26" y="-48" width="52" height="48" rx="3" fill="#c39a5f"/><path d="M-26 -34 L26 -34" stroke="#9a7440" stroke-width="3"/><path d="M0 -48 L0 0" stroke="#9a7440" stroke-width="2"/></g>`,lamp:()=>`<g><rect x="-2" y="-58" width="4" height="58" fill="#5b636b"/><path d="M-18 -58 L18 -58 L10 -78 L-10 -78 Z" fill="#f2c14e"/></g>`,window:()=>`<g><rect x="-34" y="-64" width="68" height="64" rx="3" fill="#bfe3f2" stroke="#9fb3c0" stroke-width="4"/><path d="M0 -64 L0 0 M-34 -32 L34 -32" stroke="#9fb3c0" stroke-width="3"/></g>`,coin:()=>`<g><ellipse cx="0" cy="-16" rx="16" ry="16" fill="#e6b83a"/><ellipse cx="0" cy="-16" rx="11" ry="11" fill="none" stroke="#b5892a" stroke-width="2"/></g>`}}));function gI(e){let t=e.w||100,n=e.h||100,r=96/Math.max(t,n);return{svg:`<svg x="${(-t*r/2).toFixed(1)}" y="${(-n*r).toFixed(1)}" width="${(t*r).toFixed(1)}" height="${(n*r).toFixed(1)}" viewBox="0 0 ${t} ${n}" preserveAspectRatio="xMidYMax meet" overflow="visible">${e.inner}</svg>`,w:t*r,h:n*r}}var _I,vI,yI,bI=o((()=>{Uk(),bj(),QM(),sI(),EP(),wN(),Gj(),tP(),hI(),BP(),sF(),bF(),gF(),OF(),cN(),Tk(),Pf(),_I=`http://www.w3.org/2000/svg`,vI=()=>document.createElementNS(_I,`g`),yI=class{constructor(e){this.stage=e,this.canvas=document.createElement(`canvas`),this.canvas.className=`v2-bg`,this.svg=document.createElementNS(_I,`svg`),this.svg.setAttribute(`class`,`v2-hero`),this.svg.setAttribute(`preserveAspectRatio`,`xMidYMid meet`),this.boardG=vI(),this.world=vI(),this.extrasG=vI(),this.entitiesG=vI(),this.propsG=vI(),this.wfxG=vI(),this.world.append(this.extrasG,this.entitiesG,this.propsG,this.wfxG),this.stateG=vI(),this.world.appendChild(this.stateG),this.timeG=vI(),this.occG=vI(),this.weatherG=vI(),this.fx=vI(),this.sfxG=vI(),this.transG=vI(),this.wrG=vI(),this.svg.append(this.boardG,this.world,this.timeG,this.occG,this.weatherG,this.fx,this.sfxG,this.transG,this.wrG),this.overlay=document.createElement(`div`),this.overlay.className=`v2-overlay`,e.append(this.canvas,this.svg,this.overlay),this.ctx=this.canvas.getContext(`2d`),this.rigs=new Map,this.bubbleEls=new Map,this.cardEl=null,this._setupCache=new Map,this.assets=null,this._resize=()=>this._sizeCanvas(),window.addEventListener(`resize`,this._resize)}destroy(){window.removeEventListener(`resize`,this._resize),this.stage.innerHTML=``}setAspect(e){this._vbw=Ek(e),this.svg.setAttribute(`viewBox`,`0 0 ${this._vbw} 640`),this._sizeCanvas()}setAssets(e){return this.assets=e||null,this}_sizeCanvas(){let e=this.stage.getBoundingClientRect(),t=Math.min(2,window.devicePixelRatio||1);this.canvas.width=Math.max(1,Math.round(e.width*t)),this.canvas.height=Math.max(1,Math.round(e.height*t))}_setup(e){let t=e.name+`:`+e.seed+`:`+e.mode+`:`+(e.palette||`day`);return this._setupCache.has(t)||this._setupCache.set(t,Qj(e.name,e.seed,e.mode,e.palette)),this._setupCache.get(t)}_rig(e,t,n){let r=Vk(n)?`profile`:`flat`,i=this.rigs.get(e);if(i&&i.family!==r&&(i.rig.remove(),i=null),!i){let t=Dk(r===`profile`?`right`:`front`);this.world.appendChild(t),i={rig:t,paintKey:null,family:r},this.rigs.set(e,i)}let a=JSON.stringify(t);return a!==i.paintKey&&(uj(i.rig,t),i.paintKey=a),i.rig}_groundY(){let e=this.svg.getScreenCTM();if(!e)return this.canvas.height*.9;let t=this.svg.createSVGPoint();t.x=0,t.y=592;let n=this.stage.getBoundingClientRect(),r=this.canvas.height/Math.max(1,n.height);return Y((t.matrixTransform(e).y-n.top)*r,this.canvas.height*.5,this.canvas.height*.98)}render(e){this._aspect!==e.aspect&&(this._aspect=e.aspect,this.setAspect(e.aspect)),this.canvas.width<2&&this._sizeCanvas(),this._t=e.t,this.world.setAttribute(`transform`,vP(e.camera.view,this._vbw));let t=e.camera.view.whip||0;this.world.style.filter=t>.05?`blur(${(t*4).toFixed(1)}px)`:``;let n=this.canvas.width,r=this.canvas.height,i=this._groundY();this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,n,r),e.board?this._board(e):(this.boardG.innerHTML=``,e.background.from&&(this.ctx.globalAlpha=1,$j(this.ctx,this._setup(e.background.from),n,r,i,e.camera.bgCam,e.t)),this.ctx.globalAlpha=e.background.from?e.background.mix:1,$j(this.ctx,this._setup(e.background.to),n,r,i,e.camera.bgCam,e.t),this.ctx.globalAlpha=1),this.extrasG.innerHTML=(e.extras||[]).map(t=>{let n=t.depthScale*.82,r=512+(t.yShift||0),i=Math.sin(e.t*.9+t.phase)*3;return`<g transform="translate(${(t.x+i).toFixed(1)} ${r.toFixed(1)}) scale(${n.toFixed(3)})" opacity="${(t.opacity*.85).toFixed(3)}"><ellipse cx="0" cy="6" rx="42" ry="10" fill="#000" opacity="0.06"/><rect x="-32" y="-150" width="64" height="150" rx="30" fill="${t.shirt}"/><circle cx="0" cy="-178" r="31" fill="#d9ac88"/></g>`}).join(``),this.entitiesG.innerHTML=(e.entities||[]).slice().sort((e,t)=>t.z-e.z).map(e=>{if(e.kind===`placeholder`){let t=this.assets&&e.source?this.assets[e.source]:null,n=t?WP(e,t):XP(e);return`<g transform="translate(${e.x.toFixed(1)} ${e.y.toFixed(1)})" opacity="${e.opacity.toFixed(3)}"${e.blur>.3?` style="filter:blur(${e.blur.toFixed(1)}px)"`:``}>${n}</g>`}return e.kind===`formation`?this._formationSvg(e):``}).join(``),this.propsG.innerHTML=(e.props||[]).map(t=>{let n=t.spec&&t.spec.cache&&this.assets?this.assets[t.spec.cache]:null,r=n?gI(n):lI(t.spec);if(!r)return``;let i=uI(t.presentation,{x:t.x,y:t.y},e.t,t.depthScale||1),a=i.shadow===`none`?``:`<ellipse cx="0" cy="2" rx="34" ry="8" fill="#000" opacity="${i.shadow===`breathe`?(.12+.04*Math.sin(e.t*1.6)).toFixed(3):`0.12`}"/>`;return`<g transform="translate(${t.x.toFixed(1)} ${i.y.toFixed(1)}) scale(${i.scale.toFixed(3)})">${a}${r.svg}</g>`}).join(``);let a=new Set(e.cast.map(e=>e.ref)),o=!(e.style&&e.style.shadow===!1);this.rigs.forEach((e,t)=>{a.has(t)||e.rig.setAttribute(`opacity`,`0`)}),e.cast.forEach(e=>{let t=this._rig(e.ref,e.params,e.facing);t.setAttribute(`opacity`,String(e.opacity==null?1:e.opacity)),t.style.filter=e.blur>.3?`blur(${e.blur.toFixed(1)}px)`:``,Ok(t,e.pose,hj(e.params,e.rigX,{facing:e.facing,squash:e.squash,depthScale:e.depthScale,yShift:e.yShift}));let n=Hk(t,`shadow`);n&&n.setAttribute(`opacity`,o?`0.10`:`0`),this.world.appendChild(t)}),this.stateG.innerHTML=(e.cast||[]).filter(e=>e.states&&e.states.length).map(t=>{let n=592-458*t.depthScale+t.yShift;return`<g transform="translate(${t.rigX.toFixed(1)} ${n.toFixed(1)}) scale(${t.depthScale.toFixed(3)})" opacity="${(t.opacity==null?1:t.opacity).toFixed(2)}">${xF(t.states,e.t)}</g>`}).join(``),this.world.appendChild(this.stateG),this.wfxG.innerHTML=(e.effects||[]).filter(e=>e.space===`world`).map(t=>`<g transform="translate(${t.x.toFixed(1)} ${t.y.toFixed(1)})">${cF(t,t.p,e.t)}</g>`).join(``),this.world.appendChild(this.wfxG),this.sfxG.innerHTML=(e.effects||[]).filter(e=>e.space===`screen`).map(t=>cF(t,t.p,e.t)).join(``),this.fx.innerHTML=(e.overlays||[]).map(t=>`<g transform="translate(${t.x.toFixed(1)} ${t.y.toFixed(1)})">${DP(t,t.p,e.t)}</g>`).join(``),this._timeGrade(e),this._weather(e),this._occluders(e),this._transition(e.transition),this._wordReveal(e);let s=new Set(e.bubbles.map(e=>e.ref));this.bubbleEls.forEach((e,t)=>{s.has(t)||(e.style.display=`none`)}),e.bubbles.forEach(t=>this._bubble(t,e)),this._card(e.cards[0],e)}_board(e){let t=e.board,n=e.camera.pan||{x:t.worldW/2,y:t.worldH/2,scale:1,rotation:0},r=this._vbw/t.viewW,i=640/t.viewH;this.boardG.setAttribute(`transform`,`scale(${r.toFixed(4)} ${i.toFixed(4)})`),this.boardG.innerHTML=t.planes.map(r=>{let i=r.depth===1&&t.focusRing&&t.ring?Lj(t.ring.x,t.ring.y,e.t):``;return`<g transform="${hN(n,r.depth,t.viewW,t.viewH)}">${r.svg}${i}</g>`}).join(``)}_timeGrade(e){let t=e.timeGrade;if(!t){this.timeG.innerHTML=``;return}let n=e.VBW,r=t.sun.a>.01?`<circle cx="${t.sun.x.toFixed(1)}" cy="${t.sun.y.toFixed(1)}" r="58" fill="#ffe08a" opacity="${(t.sun.a*.18).toFixed(2)}"/><circle cx="${t.sun.x.toFixed(1)}" cy="${t.sun.y.toFixed(1)}" r="34" fill="#ffe79a" opacity="${t.sun.a.toFixed(2)}"/>`:``,i=t.moon.a>.01?`<circle cx="${t.moon.x.toFixed(1)}" cy="${t.moon.y.toFixed(1)}" r="24" fill="#eef2f8" opacity="${t.moon.a.toFixed(2)}"/>`:``;this.timeG.innerHTML=`<defs><linearGradient id="v2tg" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${t.top}"/><stop offset="1" stop-color="${t.bot}"/></linearGradient></defs><rect x="0" y="0" width="${n}" height="640" fill="url(#v2tg)" opacity="${t.alpha.toFixed(3)}"/>${r}${i}`}_weather(e){this.weatherG.innerHTML=e.weather?$M(e.weather,e.t,e.VBW):``}_occluders(e){if(!e.camera||!e.camera.traveling){this.occG.innerHTML=``;return}let t=this._vbw,n=(1.2-e.t/.9%1*1.4)*t;this.occG.innerHTML=`<defs><linearGradient id="occEdgeL" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#0e1622" stop-opacity="0.26"/><stop offset="1" stop-color="#0e1622" stop-opacity="0"/></linearGradient><linearGradient id="occEdgeR" x1="1" y1="0" x2="0" y2="0"><stop offset="0" stop-color="#0e1622" stop-opacity="0.26"/><stop offset="1" stop-color="#0e1622" stop-opacity="0"/></linearGradient><filter id="occBlur" x="-40%" y="-40%" width="180%" height="180%"><feGaussianBlur stdDeviation="7"/></filter></defs><rect x="0" y="0" width="${(t*.17).toFixed(0)}" height="640" fill="url(#occEdgeL)"/><rect x="${(t*.83).toFixed(0)}" y="0" width="${(t*.17).toFixed(0)}" height="640" fill="url(#occEdgeR)"/><rect x="${n.toFixed(1)}" y="0" width="30" height="640" rx="10" fill="#0e1622" opacity="0.13" filter="url(#occBlur)"/>`}_wordReveal(e){if(e.mode!==`wordReveal`){this.wrG.innerHTML&&(this.wrG.innerHTML=``);return}let t=e.wordReveal||{},n=this._vbw,r=n/2,i=t.background||`#12151a`,a=e=>String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),o=``;if(t.trail&&t.trail.entries?.length){let e=t.trail.entries.find(e=>e.role===`current`),i=Math.max(40,Math.min(132,n*.9/Math.max(3,(e?.text||``).length*.62))),s=null;t.trail.layout===`inline`&&(s=Ef({entries:t.trail.entries},e=>String(e).length*i*.62,{maxWidth:n*.9,spaceW:i*.28,lineH:i*1.15,trailExit:t.trail.exit}));let c=t.trail.muteColor||`#8e8a80`;o=[...t.trail.entries].sort((e,t)=>t.slot-e.slot).map(e=>{let n=e.role===`current`,o=n?e.transform:null,l=s?s.get(e.wordIndex)||{x:0,y:0}:{x:e.dx*i,y:e.dy*i},u=e.scale*(o?o.scale:1)*(n&&e.emphasized?1.28:1),d=o&&o.ty?o.ty*640:0,f=e.emphasized?t.accent||`#ffd400`:Sf(`#f4f6f8`,c,e.muteP),p=Math.max(0,Math.min(1,e.opacity*(o?o.opacity:1)));return`<g transform="translate(${(r+l.x).toFixed(1)} ${(300+l.y+d).toFixed(1)}) scale(${u.toFixed(3)}) rotate(${(o&&o.rot||0).toFixed(1)})" opacity="${p.toFixed(2)}"><text x="0" y="0" text-anchor="middle" dominant-baseline="central" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${i.toFixed(1)}" fill="${f}">${a(e.text)}</text></g>`}).join(``)}else if(t.word){let e=t.word,i=Math.max(40,Math.min(132,n*.9/Math.max(3,e.length*.62))),s=t.emphasized?1.28:1,c=t.emphasized?t.accent||`#ffd400`:`#f4f6f8`;o=`<g transform="translate(${r.toFixed(1)} ${(300+(t.ty||0)*640).toFixed(1)}) scale(${((t.scale==null?1:t.scale)*s).toFixed(3)}) rotate(${(t.rot||0).toFixed(1)})" opacity="${(t.opacity==null?1:t.opacity).toFixed(2)}"><text x="0" y="0" text-anchor="middle" dominant-baseline="central" font-family="Nunito,system-ui,sans-serif" font-weight="900" font-size="${i.toFixed(1)}" fill="${c}">${a(e)}</text></g>`}this.wrG.innerHTML=`<rect x="0" y="0" width="${n}" height="640" fill="${i}"/>${o}`}_transition(e){if(!e){this.transG.innerHTML=``;return}if(e.harness){let t=AN(e.spec,e.p,{VBW:this._vbw,bridge:e.bridge,subjectFrom:e.subjectFrom,subjectTo:e.subjectTo,subject:e.subjectFrom});this.transG.innerHTML=t.cover;return}let t=this._vbw,n=`#0d1220`,r=e.direction===`right`?1:-1,i=e.p,a=``;if(e.type===`flash`){let n=Math.max(0,1-i*1.1),r=e.tint||`#ffffff`,o=(i*1.5-.25)*t;a=`<rect x="0" y="0" width="${t}" height="640" fill="${r}" opacity="${n.toFixed(3)}"/><path d="M ${o.toFixed(1)} -20 l ${120 .toFixed(1)} 0 l ${(-80).toFixed(1)} ${680 .toFixed(1)} l ${(-120).toFixed(1)} 0 z" fill="${r}" opacity="${(n*.85).toFixed(3)}"/>`}else if(e.type===`fade`)a=`<rect x="0" y="0" width="${t}" height="640" fill="${n}" opacity="${(.55*(1-i)).toFixed(3)}"/>`;else if(e.type===`slide`)a=`<rect x="${(r*i*t).toFixed(1)}" y="0" width="${t}" height="640" fill="${n}" opacity="0.92"/>`;else if(e.type===`irisWipe`){let e=i*Math.hypot(t,640)*.62;a=`<path fill-rule="evenodd" d="M0 0 H ${t} V 640 H 0 Z M ${t/2} 320 m ${(-e).toFixed(1)} 0 a ${e.toFixed(1)} ${e.toFixed(1)} 0 1 0 ${(2*e).toFixed(1)} 0 a ${e.toFixed(1)} ${e.toFixed(1)} 0 1 0 ${(-2*e).toFixed(1)} 0" fill="${n}"/>`}else if(e.type===`whipPan`){let e=Math.sin(i*Math.PI);for(let r=0;r<8;r++){let o=r/8*640,s=(i*1.6-.3)*t+(r%2?20:-20);a+=`<rect x="${s.toFixed(1)}" y="${o.toFixed(1)}" width="${(t*.5).toFixed(1)}" height="${81 .toFixed(1)}" fill="${n}" opacity="${(e*.5).toFixed(2)}"/>`}}else if(e.type===`doorPass`){let e=t/2*i;a=`<rect x="${(-e).toFixed(1)}" y="0" width="${(t/2).toFixed(1)}" height="640" fill="${n}"/><rect x="${(t/2+e).toFixed(1)}" y="0" width="${(t/2).toFixed(1)}" height="640" fill="${n}"/>`}else if(e.type===`objectWipe`){let e=t*.45;a=`<rect x="${(-e+i*(t+2*e)).toFixed(1)}" y="-20" width="${e.toFixed(1)}" height="${680 .toFixed(1)}" rx="18" fill="${n}"/>`}else if(e.type===`matchDissolve`)a=`<rect x="0" y="0" width="${t}" height="640" fill="${n}" opacity="${(Math.sin(i*Math.PI)*.5).toFixed(3)}"/>`;else{let o=Math.max(2,e.bands||4),s=t/o;for(let e=0;e<o;e++){let o=r*Y((i-e*.12)/.6,0,1)*t;a+=`<rect x="${(e*s+o).toFixed(1)}" y="0" width="${(s+1).toFixed(1)}" height="640" fill="${n}"/>`}}this.transG.innerHTML=a}_formationSvg(e){let t=this._t||0;return(e.units||[]).map(e=>`<g transform="translate(${e.x.toFixed(1)} ${e.y.toFixed(1)})">${vF(e,t)}</g>`).join(``)}_bubble(e,t){let n=this.bubbleEls.get(e.ref);n||(n=document.createElement(`div`),n.className=`v2-bubble`,n.innerHTML=`<span class="txt"></span><i class="tail"></i>`,this.overlay.appendChild(n),this.bubbleEls.set(e.ref,n));let r=this.rigs.get(e.ref);if(!r){n.style.display=`none`;return}let i=Hk(r.rig,`head`).getBoundingClientRect(),a=this.stage.getBoundingClientRect();if(!i.width){n.style.display=`none`;return}let o={cx:i.left+i.width/2-a.left,midY:i.top+i.height/2-a.top,h:i.height},s=iI(Y(o.h/135,.6,2),a.width);n.querySelector(`.txt`).textContent=e.text.slice(0,oI(e.text,t.t-e.tStart))||` `,Object.assign(n.style,{display:`inline-block`,fontSize:s.fontPx+`px`,padding:s.padY+`px `+s.padX+`px`,maxWidth:s.maxWidth+`px`,borderRadius:s.radius+`px`,zIndex:String(20+Math.round((1-(e.z==null?.5:e.z))*40))});let c=n.offsetWidth,l=n.offsetHeight,u=aI(o,{w:a.width,h:a.height},{x:0,y:-.9},c,l,s);n.style.left=u.left+`px`,n.style.top=u.top+`px`;let d=n.querySelector(`.tail`);d.className=`tail `+u.tail.side,d.style.left=u.tail.left==null?``:u.tail.left+`px`,d.style.top=u.tail.top==null?``:u.tail.top+`px`}_card(e,t){if(!e){this.cardEl&&(this.cardEl.style.display=`none`);return}this.cardEl||(this.cardEl=document.createElement(`div`),this.overlay.appendChild(this.cardEl));let n=!!e.full;this.cardEl.className=(n?`v2-card-full `:`v2-card `)+(e.tone===`dark`?`v2-card-dark`:`v2-card-light`),this.cardEl.textContent=e.text,this.cardEl.style.display=n?`flex`:`block`}}})),xI,SI,CI,wI,TI,EI=o((()=>{xI={flat:{amb:1,dir:0,len:1},soft:{amb:.85,dir:.4,len:1.4},dramatic:{amb:.5,dir:.9,len:2.6},night:{amb:.35,dir:.6,len:2.2},screenlit:{amb:.6,dir:.5,len:1.2}},SI=[`phone`,`laptop`,`monitor`,`tablet`],CI={condition:[`new`,`worn`,`rusted`,`broken`],fill:[`empty`,`full`],growth:[`seed`,`sprout`,`tree`],temperature:[`cold`,`hot`],damage:[`whole`,`cracked`,`shattered`],life:[`fresh`,`wilted`],size:[`small`,`large`],power:[`dark`,`lit`]},wI=[`stream`,`emitToTarget`,`flowField`,`converge`,`disperse`,`counted`],TI={V1_lighting:{renderers:[`lightShadow`,`glowSvg`,`rimSvg`,`shaftsSvg`,`ambientOcclusion`],looks:Object.keys(xI)},V2_liquids:{renderers:[`fillSvg`,`pourSvg`,`waveSvg`,`dripSvg`,`glassSvg`,`metalSvg`,`wetSvg`]},V3_fire:{renderers:[`flameSvg`,`smokeSvg`,`sparkSvg`,`explosionSvg`,`steamSvg`]},V4_dataviz:{renderers:[`plotOverTime`,`barRace`,`pieGrow`,`sankeySvg`,`scatterSvg`,`networkSvg`,`mapChoropleth`]},V5_type:{renderers:[`wordPop`,`numberMorph`,`kineticHeadline`,`typewriter`,`highlightSweep`,`maskReveal`,`textPath`]},V6_ui:{renderers:[`deviceFrame`,`fakeUI`,`chatThread`,`codeType`,`browserBar`,`notification`],frames:SI},V7_state:{renderers:[`stateChange`],stateSets:Object.keys(CI)},V8_weather:{renderers:[`wetGroundSvg`,`snowAccumulationSvg`,`windEffect`,`fogBankSvg`,`wetCharacterTint`]},V9_continuity:{renderers:[`carryObject`,`motionCarry`,`thematicReprise`]},V10_particles:{renderers:[`particleFlow`,`trailRibbon`],modes:wI}},Object.keys(TI)})),DI,OI,kI,AI,jI,MI,NI,PI,FI,II,LI,RI,zI,BI=o((()=>{({sin:DI,cos:OI,PI:kI,pow:AI,abs:jI,min:MI,max:NI,exp:PI}=Math),FI=[`anticipate`,`overshootSettle`,`snap`,`punch`,`drift`,`cushion`,`elastic`,`linearIntentional`,`flat`],II={primary:{durS:.65,feel:`overshootSettle`,hold:!0},secondary:{durS:.3,feel:`snap`,hold:!1},ambient:{durS:1.1,feel:`drift`,hold:!1},emphasis:{durS:.18,feel:`punch`,hold:!0}},LI=Object.keys(II),RI={polished:{tierFeel:{primary:`overshootSettle`,secondary:`snap`,ambient:`drift`,emphasis:`punch`},staggerMs:75,secondaryMotion:!0,rhythm:1},calm:{tierFeel:{primary:`cushion`,secondary:`drift`,ambient:`drift`,emphasis:`overshootSettle`},staggerMs:110,secondaryMotion:!0,rhythm:.4},energetic:{tierFeel:{primary:`punch`,secondary:`snap`,ambient:`snap`,emphasis:`punch`},staggerMs:50,secondaryMotion:!0,rhythm:1.6},flat:{tierFeel:{primary:`flat`,secondary:`flat`,ambient:`flat`,emphasis:`flat`},staggerMs:0,secondaryMotion:!1,rhythm:0}},zI=Object.keys(RI)})),VI,HI,UI,WI=o((()=>{VI=[`number`,`process`,`comparison`,`thing`,`place`,`person`,`changeOverTime`,`causeEffect`,`concept`,`emphasis`,`list`,`warning`],HI={number:[{id:`counter`,uses:`V4 counter`,note:`the value counts up`},{id:`proportionFill`,uses:`V2 fill / pie`,note:`a proportion filled truthfully`},{id:`oneBigNumber`,uses:`V5 numberMorph`,note:`one big number, held`}],process:[{id:`stepPath`,uses:`method stepPath`,note:`literal ordered sequence`},{id:`causeArrowChain`,uses:`device causeArrowChain`,note:`A→B→C arrows`},{id:`explodedCutaway`,uses:`method explodedView`,note:`exploded / cutaway`}],comparison:[{id:`splitScreen`,uses:`setup split`,note:`both, side by side`},{id:`sideBySideScaled`,uses:`prominence rule`,note:`sized truthfully`},{id:`barCompare`,uses:`V4 barRace`,note:`bars compared`}],thing:[{id:`heroShot`,uses:`placeholder / prop focal`,note:`one clear hero shot`},{id:`labeledObject`,uses:`device connectorLine`,note:`the object, labeled`}],place:[{id:`establishSetup`,uses:`scenes setup`,note:`the place, established`}],person:[{id:`castInRole`,uses:`wardrobe + action`,note:`right wardrobe, relevant action`}],changeOverTime:[{id:`timeline`,uses:`device timelineTicker`,note:`the timeline`},{id:`beforeAfter`,uses:`V7 stateChange`,note:`before / after`},{id:`timeLapse`,uses:`timeRamp`,note:`time-lapse the delta`}],causeEffect:[{id:`arrowAtoB`,uses:`overlay arrow`,note:`A → B`},{id:`domino`,uses:`V10 stream`,note:`domino / chain`},{id:`effectResults`,uses:`V7 stateChange`,note:`the effect visibly resulting`}],concept:[{id:`lightMetaphor`,uses:`ONE metaphor slot`,note:`⚠ only if no literal image exists — instantly readable`},{id:`literalExemplar`,uses:`a concrete example`,note:`show one concrete instance instead`}],emphasis:[{id:`justType`,uses:`V5 + punch feel`,note:`big text + punch + hold — sometimes JUST type`},{id:`bigNumberHold`,uses:`V5 numberMorph`,note:`the number, held`}],list:[{id:`sequentialReveal`,uses:`stagger + numbered`,note:`items reveal in order, numbered`}],warning:[{id:`alertTreatment`,uses:`device alert + red accent`,note:`red accent, consequence shown`},{id:`consequenceShown`,uses:`V7 stateChange`,note:`the consequence visibly`}]},UI=e=>HI[e]||HI.thing,Object.fromEntries(VI.map(e=>[e,UI(e).map(e=>e.id)]))})),GI,KI,qI,JI,YI,XI,ZI,QI,$I,eL,tL,nL,rL=o((()=>{QM(),sF(),tA(),OF(),cN(),gF(),BP(),Gj(),aj(),EI(),BI(),WI(),GI=Object.keys(xI),KI=SI,qI=Object.keys(CI),JI=wI,YI=TI.V4_dataviz.renderers,XI=TI.V5_type.renderers,ZI=[`editorial`,`energetic`,`calm`,`doc`,`documentary`,`dramatic`,`warfilm`],QI=[`panTo`,`punchTo`,`follow`,`hop`,`travel`,`zoomOut`,`establish`,`orbitLite`,`snapZoom`],$I=[`carry`,`fade`,`slide`,`shapeWipe`,`flash`,`irisWipe`,`whipPan`,`doorPass`,`objectWipe`,`matchDissolve`],eL=[`walkIn`,`runIn`,`fadeIn`,`present`,`popIn`,`dropIn`,`riseFrom`,`carryOver`],tL=[`front`,`back`,`left`,`right`],nL=[{path:`setup.name`,type:`enum`,options:YM,default:`openField`,group:`World`,label:`Setup`},{path:`setup.palette`,type:`enum`,options:lM,default:`day`,group:`World`,label:`Palette`},{path:`setup.mode`,type:`enum`,options:[`2.5d`,`2d`],default:`2.5d`,group:`World`,label:`Depth mode`},{path:`setup.seed`,type:`number`,min:0,max:9999,step:1,default:7,group:`World`,label:`Seed`},{path:`entity.face`,type:`enum`,options:tF,default:`assetBox`,group:`Placeholder`,label:`Face`},{path:`entity.label`,type:`text`,default:``,group:`Placeholder`,label:`Label`},{path:`entity.size`,type:`enum`,options:[`S`,`M`,`L`],default:`M`,group:`Placeholder`,label:`Size`},{path:`entity.plane`,type:`number`,min:0,max:1,step:.01,default:.5,group:`Placeholder`,label:`Plane (z)`},{path:`entity.x`,type:`number`,min:0,max:1,step:.01,default:.5,group:`Placeholder`,label:`X`},{path:`entity.placement`,type:`enum`,options:$P,default:`ground`,group:`Placeholder`,label:`Placement`},{path:`entity.tint`,type:`color`,default:`#4a5a6b`,group:`Placeholder`,label:`Tint`},{path:`entity.source`,type:`enum`,options:[`placeholder`,`asset`],default:`placeholder`,group:`Placeholder`,label:`Source`},{path:`cast.action`,type:`enum`,options:$k,default:`idle`,group:`Performance`,label:`Action`},{path:`cast.state`,type:`enum`,options:SF,default:[],multi:!0,group:`Performance`,label:`State overlays`},{path:`cast.facing`,type:`enum`,options:tL,default:`front`,group:`Performance`,label:`Facing`},{path:`cast.enter.type`,type:`enum`,options:eL,default:`walkIn`,group:`Performance`,label:`Entrance`},{path:`effect.type`,type:`enum`,options:lF,default:`burst`,group:`Effects`,label:`Effect`},{path:`effect.tint`,type:`color`,default:`#ffd27a`,group:`Effects`,label:`Effect tint`},{path:`effect.intensity`,type:`number`,min:0,max:1,step:.05,default:.6,group:`Effects`,label:`Intensity`},{path:`setup.weather`,type:`enum`,options:[`none`,...aN],default:`none`,group:`Weather`,label:`Weather`},{path:`setup.weather.intensity`,type:`enum`,options:[`light`,`storm`],default:`light`,group:`Weather`,label:`Intensity`},{path:`setup.timeRamp.from`,type:`enum`,options:lM,default:`goldenHour`,group:`Weather`,label:`Time ramp — from`},{path:`setup.timeRamp.to`,type:`enum`,options:lM,default:`night`,group:`Weather`,label:`Time ramp — to`},{path:`setup.timeRamp.overPhrases`,type:`number`,min:1,max:12,step:1,default:2,group:`Weather`,label:`Time ramp — over phrases`},{path:`overlay.type`,type:`enum`,options:RP,default:`counter`,group:`Overlays`,label:`Overlay`},{path:`overlay.anchor`,type:`text`,default:`skyBand`,group:`Overlays`,label:`Anchor`},{path:`overlay.value`,type:`number`,min:0,max:1e3,step:1,default:60,group:`Overlays`,label:`Value`},{path:`overlay.label`,type:`text`,default:``,group:`Overlays`,label:`Label`},{path:`overlay.tint`,type:`color`,default:`#2BB3A3`,group:`Overlays`,label:`Overlay tint`},{path:`card.type`,type:`enum`,options:zP,default:`titleCard`,group:`Overlays`,label:`Structural card`},{path:`camera.idle`,type:`enum`,options:[`focusFlow`,`drift`,`locked`],default:`focusFlow`,group:`Camera`,label:`Idle motion`},{path:`camera.stylePreset`,type:`enum`,options:ZI,default:`editorial`,group:`Camera`,label:`Style preset`},{path:`camera.directive`,type:`enum`,options:QI,default:`establish`,group:`Camera`,label:`Directive`},{path:`transitionOut.type`,type:`enum`,options:$I.concat([`irisObject`,`strokeSweep`,`slabWipe`,`curtainFall`,`lightWash`,`bandWipe`,`carryTravel`]),default:`carry`,group:`Transitions`,label:`Transition out`},{path:`transitionOut.durationMs`,type:`number`,min:200,max:4e3,step:50,default:1200,group:`Transitions`,label:`Duration (ms)`},{path:`transitionOut.ease`,type:`enum`,options:[`linear`,`smooth`,`smoother`],default:`smoother`,group:`Transitions`,label:`Ease`},{path:`transitionOut.direction`,type:`enum`,options:[`L2R`,`R2L`,`T2B`,`B2T`,`radialIn`,`radialOut`],default:`L2R`,group:`Transitions`,label:`Direction`},{path:`transitionOut.colorMode`,type:`enum`,options:[`bridge`,`incoming`,`token`,`custom`],default:`bridge`,group:`Transitions`,label:`Colour mode`},{path:`transitionOut.carrySubject`,type:`text`,default:``,group:`Transitions`,label:`Carry subject (castId)`},{path:`sfx.name`,type:`text`,default:``,group:`Audio`,label:`SFX cue`},{path:`board.name`,type:`enum`,options:Uj,default:`conceptTriptych`,group:`Boards`,label:`Board`},{path:`setup.element`,type:`bool`,default:!0,group:`Boards`,label:`Element (per manifest)`},{path:`camera.mode`,type:`enum`,options:[`generated`,`manual`,`hybrid`],default:`generated`,group:`PanControl`,label:`Camera mode`},{path:`camera.style`,type:`enum`,options:[`editorial`,`calm`,`energetic`,`dramatic`,`custom`],default:`editorial`,group:`PanControl`,label:`Shot style`},{path:`camera.seed`,type:`number`,min:0,max:9999,step:1,default:1,group:`PanControl`,label:`Shot seed`},{path:`camera.safeZone.enabled`,type:`bool`,default:!0,group:`PanControl`,label:`Safe-zone clamp`},{path:`camera.point.x`,type:`number`,min:-4e3,max:4e3,step:1,default:0,group:`PanControl`,label:`Point · X`},{path:`camera.point.y`,type:`number`,min:-4e3,max:4e3,step:1,default:0,group:`PanControl`,label:`Point · Y`},{path:`camera.point.zoom`,type:`number`,min:.5,max:3,step:.01,default:1,group:`PanControl`,label:`Point · zoom`},{path:`camera.point.rotation`,type:`number`,min:-6,max:6,step:.1,default:0,group:`PanControl`,label:`Point · rotation`},{path:`camera.point.time`,type:`number`,min:0,max:600,step:.1,default:0,group:`PanControl`,label:`Point · time`},{path:`camera.point.ease`,type:`enum`,options:[`linear`,`smooth`,`smoother`],default:`smoother`,group:`PanControl`,label:`Point · ease`},{path:`appearance.hair`,type:`enum`,options:jA,default:`crop`,group:`Wardrobe`,label:`Hair`},{path:`appearance.top`,type:`enum`,options:ij.top,default:`tee`,group:`Wardrobe`,label:`Top`},{path:`appearance.sleeves`,type:`enum`,options:ij.sleeves,default:`short`,group:`Wardrobe`,label:`Sleeves`},{path:`appearance.outerwear`,type:`enum`,options:ij.outerwear,default:`none`,group:`Wardrobe`,label:`Outerwear`},{path:`appearance.bottom`,type:`enum`,options:ij.bottom,default:`jeans`,group:`Wardrobe`,label:`Bottom`},{path:`appearance.footwear`,type:`enum`,options:ij.footwear,default:`sneakers`,group:`Wardrobe`,label:`Footwear`},{path:`appearance.faceShape`,type:`enum`,options:UA,default:`oval`,group:`Wardrobe`,label:`Face shape`},{path:`appearance.facialHair`,type:`enum`,options:KA,default:`none`,group:`Wardrobe`,label:`Facial hair`},{path:`appearance.glasses`,type:`enum`,options:JA,default:`none`,group:`Wardrobe`,label:`Glasses`},{path:`appearance.topColor`,type:`color`,default:`#2b6cb0`,group:`Wardrobe`,label:`Top colour`},{path:`appearance.outerColor`,type:`color`,default:`#455a70`,group:`Wardrobe`,label:`Outerwear colour`},{path:`appearance.bottomColor`,type:`color`,default:`#37455a`,group:`Wardrobe`,label:`Bottom colour`},{path:`appearance.pack`,type:`enum`,options:rj,default:`casual`,group:`Wardrobe`,label:`Wardrobe pack`},{path:`cast.ageHint`,type:`enum`,options:[`childYoung`,`child`,`teen`,`adult`,`elder`],default:`adult`,group:`Wardrobe`,label:`Age`},{path:`appearance.headwear`,type:`enum`,options:XA,default:`none`,group:`Wardrobe`,label:`Headwear`},{path:`appearance.headwearColor`,type:`color`,default:`#37455a`,group:`Wardrobe`,label:`Headwear colour`},{path:`appearance.eyeShape`,type:`enum`,options:QA,default:`round`,group:`Wardrobe`,label:`Eye shape`},{path:`appearance.eyeSpacing`,type:`number`,min:-1,max:1,step:.1,default:0,group:`Wardrobe`,label:`Eye spacing`},{path:`appearance.irisColor`,type:`color`,default:`#243038`,group:`Wardrobe`,label:`Iris colour`},{path:`appearance.lashes`,type:`bool`,default:!1,group:`Wardrobe`,label:`Lashes`},{path:`appearance.browShape`,type:`enum`,options:ej,default:`flat`,group:`Wardrobe`,label:`Brow shape`},{path:`appearance.browThickness`,type:`number`,min:2,max:7,step:.5,default:4,group:`Wardrobe`,label:`Brow thickness`},{path:`appearance.browColor`,type:`color`,default:`#253038`,group:`Wardrobe`,label:`Brow colour`},{path:`appearance.freckles`,type:`bool`,default:!1,group:`Wardrobe`,label:`Freckles`},{path:`appearance.blush`,type:`bool`,default:!1,group:`Wardrobe`,label:`Blush`},{path:`appearance.earrings`,type:`bool`,default:!1,group:`Wardrobe`,label:`Earrings`},{path:`appearance.wrinkles`,type:`bool`,default:!1,group:`Wardrobe`,label:`Wrinkles (age)`},{path:`lighting.look`,type:`enum`,options:GI,default:`soft`,group:`Lighting`,label:`Lighting look`},{path:`lighting.light.type`,type:`enum`,options:[`sun`,`point`,`spot`,`ambient`],default:`sun`,group:`Lighting`,label:`Key light`},{path:`lighting.light.x`,type:`number`,min:0,max:1,step:.01,default:.3,group:`Lighting`,label:`Light X`},{path:`lighting.light.y`,type:`number`,min:0,max:1,step:.01,default:.1,group:`Lighting`,label:`Light Y (height)`},{path:`lighting.light.color`,type:`color`,default:`#fff2cc`,group:`Lighting`,label:`Light colour`},{path:`element.glow.color`,type:`color`,default:`#ffd27a`,group:`Lighting`,label:`Glow colour`},{path:`element.glow.radius`,type:`number`,min:0,max:200,step:5,default:60,group:`Lighting`,label:`Glow radius`},{path:`element.rim`,type:`bool`,default:!1,group:`Lighting`,label:`Rim light`},{path:`liquid.type`,type:`enum`,options:[`fill`,`pour`,`flow`,`drip`,`wave`],default:`fill`,group:`Materials`,label:`Liquid`},{path:`liquid.pct`,type:`number`,min:0,max:1,step:.01,default:.5,group:`Materials`,label:`Fill level`},{path:`liquid.color`,type:`color`,default:`#4aa3c4`,group:`Materials`,label:`Liquid colour`},{path:`material.shader`,type:`enum`,options:[`none`,`glass`,`metal`,`wet`],default:`none`,group:`Materials`,label:`Material`},{path:`fire.type`,type:`enum`,options:[`flame`,`smoke`,`spark`,`explosion`,`steam`],default:`flame`,group:`Fire`,label:`Fire/energy`},{path:`fire.size`,type:`number`,min:10,max:200,step:5,default:60,group:`Fire`,label:`Size`},{path:`smoke.variant`,type:`enum`,options:[`smolder`,`puff`,`billow`,`wisp`],default:`billow`,group:`Fire`,label:`Smoke variant`},{path:`dataviz.type`,type:`enum`,options:YI,default:`plotOverTime`,group:`Data-viz`,label:`Chart`},{path:`dataviz.data`,type:`text`,default:`[]`,group:`Data-viz`,label:`Data (JSON)`},{path:`type.effect`,type:`enum`,options:XI,default:`wordPop`,group:`Typography`,label:`Kinetic type`},{path:`type.text`,type:`text`,default:``,group:`Typography`,label:`Text`},{path:`type.stagger`,type:`number`,min:0,max:.5,step:.01,default:.15,group:`Typography`,label:`Stagger`},{path:`ui.device`,type:`enum`,options:KI,default:`phone`,group:`Screen/UI`,label:`Device frame`},{path:`ui.content`,type:`enum`,options:[`fakeUI`,`chatThread`,`codeType`,`browserBar`,`notification`,`graphOnScreen`],default:`fakeUI`,group:`Screen/UI`,label:`Screen content`},{path:`state.set`,type:`enum`,options:qI,default:`condition`,group:`Object-state`,label:`State set`},{path:`state.shakeIntensity`,type:`number`,min:0,max:20,step:1,default:6,group:`Object-state`,label:`Shake`},{path:`state.popScale`,type:`number`,min:1,max:2,step:.05,default:1.25,group:`Object-state`,label:`Pop scale`},{path:`weather.consequence`,type:`enum`,options:[`wetGround`,`snowAccumulation`,`windEffect`,`wetCharacter`,`fogBank`],default:`wetGround`,group:`Weather`,label:`Consequence`},{path:`weather.windStrength`,type:`number`,min:0,max:3,step:.1,default:1,group:`Weather`,label:`Wind strength`},{path:`continuity.mode`,type:`enum`,options:[`carryObject`,`motionCarry`,`thematicReprise`],default:`carryObject`,group:`Continuity`,label:`Carry mode`},{path:`particles.mode`,type:`enum`,options:JI,default:`stream`,group:`Particles`,label:`Flow mode`},{path:`particles.count`,type:`number`,min:1,max:300,step:1,default:20,group:`Particles`,label:`Count`},{path:`particles.particleType`,type:`enum`,options:[`dot`,`coin`,`arrow`],default:`dot`,group:`Particles`,label:`Particle`},{path:`particles.rate`,type:`number`,min:.1,max:4,step:.1,default:1,group:`Particles`,label:`Rate`},{path:`finish.profile`,type:`enum`,options:zI,default:`polished`,group:`Finish`,label:`Finish profile`},{path:`element.tier`,type:`enum`,options:LI,default:`secondary`,group:`Finish`,label:`Motion tier`},{path:`element.feel`,type:`enum`,options:FI,default:`flat`,group:`Finish`,label:`Feel (override)`},{path:`element.feelParams.overshootPct`,type:`number`,min:0,max:.4,step:.01,default:.08,group:`Finish`,label:`Overshoot %`},{path:`element.feelParams.windupPct`,type:`number`,min:0,max:.3,step:.01,default:.08,group:`Finish`,label:`Wind-up %`},{path:`element.feelParams.settleMs`,type:`number`,min:0,max:500,step:10,default:150,group:`Finish`,label:`Settle (ms)`},{path:`element.feelParams.intensity`,type:`number`,min:0,max:2,step:.1,default:1,group:`Finish`,label:`Feel intensity`},{path:`finish.staggerMs`,type:`number`,min:0,max:200,step:5,default:75,group:`Finish`,label:`Stagger (ms)`},{path:`finish.secondaryMotion`,type:`bool`,default:!0,group:`Finish`,label:`Secondary motion`},{path:`beat.simultaneous`,type:`bool`,default:!1,group:`Finish`,label:`Enter simultaneously`},{path:`beat.type`,type:`enum`,options:VI,default:`thing`,group:`Taste`,label:`Beat type`},{path:`beat.emphasis`,type:`bool`,default:!1,group:`Taste`,label:`Emphasis beat`},{path:`beat.focalSide`,type:`enum`,options:[`left`,`center`,`right`],default:`left`,group:`Taste`,label:`Focal position`},{path:`beat.deliberateCenter`,type:`bool`,default:!1,group:`Taste`,label:`Deliberate center`},{path:`beat.intensity`,type:`number`,min:0,max:1,step:.05,default:.4,group:`Taste`,label:`Beat intensity`}],Object.fromEntries(nL.map(e=>[e.path,e]))})),iL=o((()=>{rI(),bI(),QM(),Gj(),tA(),BP(),tP(),gF(),cN(),OF(),sF(),bj(),rL()})),aL=o((()=>{iL()})),oL=o((()=>{iL(),new Set(YM)})),sL=o((()=>{new Set(`the a an and or but of to in on at for with by from as is are was were be been it its this that these those they them their you your we our i he she his her not no yes so if then than into over about after before while when where why how what which who whom can could will would should may might must do does did have has had get got make makes made just very more most some any all each every one two three now here there also only even because through during them then meanwhile feel feels feeling think thinks really actually basically thing things stuff time times way ways`.split(` `))})),cL=o((()=>{sL(),new Set(`the a an and or of to in on at for with by from as is are was were it its this that your you our their about`.split(` `))}));function lL(e){return String(e||``).trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function uL(e,t=`flat`){return`${t}-${lL(e)}`}var dL=o((()=>{})),fL=o((()=>{cL(),new Set(`the a an and or of to in on at for with by from as is are was were it its this that so now then`.split(` `))})),pL=o((()=>{iL(),oL(),cL(),sL(),Pf(),fL()})),mL=o((()=>{iL(),aL()})),hL=o((()=>{iL(),aL(),oL(),pL(),mL()}));function gL(e={}){let t=new Map(Object.entries(e));return{read:()=>Object.fromEntries(t),write:e=>{t.clear();for(let[n,r]of Object.entries(e))t.set(n,r)}}}function _L(){return{read(){try{return JSON.parse(localStorage.getItem(bL)||`{}`)||{}}catch{return{}}},write(e){try{localStorage.setItem(bL,JSON.stringify(e))}catch{}}}}function vL(){return typeof localStorage<`u`?_L():gL()}function yL(e=vL()){let t=()=>e.read();return{has(e){return Object.prototype.hasOwnProperty.call(t(),e)},get(e){return t()[e]||null},put(n,r){let i=t();return i[n]={inner:r.inner,w:r.w,h:r.h},e.write(i),n},keys(){return Object.keys(t())},resolverFor(e){let n=t(),r={};return e.forEach(e=>{n[e]&&(r[e]=n[e])}),r}}}var bL,xL=o((()=>{bL=`aivw.v2.assets`}));function SL(e,t,n={}){let r=n.style||`flat`,i=!1,a=(e.scenes||[]).map(e=>{if(!e.entities?.length)return e;let n=!1,a=e.entities.map(e=>{if(e.type!==`assetBox`&&e.type!==`placeholder`)return e;let i=lL(e.label);if(!i)return e;let a=uL(i,r),o=t.has(a)?`${TL}${a}`:`placeholder`;return e.source===o?e:(n=!0,{...e,source:o})});return n?(i=!0,{...e,entities:a}):e});return i?{...e,scenes:a}:e}function CL(e){let t=new Set;return(e.scenes||[]).forEach(e=>(e.entities||[]).forEach(e=>{let n=DL(e.source);n&&t.add(n)})),(e.props||[]).forEach(e=>{let n=DL(e.cache);n&&t.add(n)}),[...t]}function wL(e,t){let n={};return CL(e).forEach(e=>{let r=t.get(e);r&&(n[`${TL}${e}`]=r)}),n}var TL,EL,DL,OL=o((()=>{dL(),TL=`vault:`,EL=e=>typeof e==`string`&&e.startsWith(TL),DL=e=>EL(e)?e.slice(6):null})),kL=o((()=>{dL(),xL(),OL()})),AL,jL=o((()=>{xL(),AL=yL(vL())}));function ML(e,t,n){return new Promise((t,n)=>{let r=new Blob([e],{type:`image/svg+xml;charset=utf-8`}),i=URL.createObjectURL(r),a=new Image;a.onload=()=>{URL.revokeObjectURL(i),t(a)},a.onerror=()=>{URL.revokeObjectURL(i),n(Error(`v2 svg raster failed`))},a.src=i})}function NL(e,t,n,r){let i=(t||[]).map(e=>e.text).filter(Boolean).join(` `).trim();if(!i)return;let a=Math.max(14,Math.round(r*.03));e.font=`700 ${a}px Nunito, system-ui, sans-serif`;let o=n*.86,s=i.split(/\s+/),c=[],l=``;for(let t of s){let n=l?`${l} ${t}`:t;e.measureText(n).width>o&&l?(c.push(l),l=t):l=n}l&&c.push(l);let u=a*1.3,d=a*.7,f=a*.5,p=Math.min(o+d*2,Math.max(...c.map(t=>e.measureText(t).width))+d*2),m=c.length*u+f*2,h=(n-p)/2,g=r-m-r*.06,_=Math.min(18,m/2);e.fillStyle=`rgba(20,24,30,0.82)`,e.beginPath(),e.moveTo(h+_,g),e.arcTo(h+p,g,h+p,g+m,_),e.arcTo(h+p,g+m,h,g+m,_),e.arcTo(h,g+m,h,g,_),e.arcTo(h,g,h+p,g,_),e.closePath(),e.fill(),e.fillStyle=`#f4f6f8`,e.textAlign=`center`,e.textBaseline=`middle`,c.forEach((t,r)=>e.fillText(t,n/2,g+f+u*(r+.5)))}function PL(e,t,n){let r=SL(e,AL),i=wL(r,AL),a=document.createElement(`div`);a.style.cssText=`position:fixed;left:-99999px;top:0;width:${t}px;height:${n}px;`,document.body.appendChild(a);let o=new yI(a);o.setAspect(r.meta?.aspect||`16:9`),o.setAssets(i),o.svg.setAttribute(`width`,String(t)),o.svg.setAttribute(`height`,String(n));let s=document.createElement(`canvas`);s.width=t,s.height=n;let c=s.getContext(`2d`),l=new XMLSerializer;return{width:t,height:n,async frameAt(e){let i=HF(r,Math.max(0,e));o.render(i),c.clearRect(0,0,t,n),c.fillStyle=`#0b0e12`,c.fillRect(0,0,t,n);try{c.drawImage(o.canvas,0,0,t,n)}catch{}try{let e=await ML(l.serializeToString(o.svg),t,n);c.drawImage(e,0,0,t,n)}catch{}return NL(c,i.bubbles,t,n),s},close(){try{o.destroy()}catch{}try{a.remove()}catch{}}}}var FL=o((()=>{hL(),kL(),jL()}));function IL(e,t,n,r,i){let a=e.createLinearGradient(0,0,0,n);a.addColorStop(0,r),a.addColorStop(1,i),e.fillStyle=a,e.fillRect(0,0,t,n)}function LL(e){let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)}function RL(e){let t=/^#?([0-9a-f]{6})$/i.exec(String(e||``).trim());if(!t)return null;let n=parseInt(t[1],16);return{r:n>>16&255,g:n>>8&255,b:n&255}}function zL(e,t,n){let r=RL(e),i=RL(t);if(!r||!i)return e;let a=e=>Math.round(r[e]+(i[e]-r[e])*n);return`rgb(${a(`r`)},${a(`g`)},${a(`b`)})`}function BL(e,t){let n=RL(e);return n?`rgba(${n.r},${n.g},${n.b},${t})`:`rgba(0,0,0,${t})`}function VL(e,t,n,r,i){let a,o,s,c,l;if(YL(i)){let e=i[0]||QL[0],t=i[1]||QL[1];a=e,o=zL(e,t,.4),s=BL(t,.28),c=BL(t,.35),l=BL(t,0)}else a=`#0a1a3f`,o=`#123a8a`,s=`rgba(120,170,255,0.28)`,c=`rgba(80,140,255,0.35)`,l=`rgba(80,140,255,0)`;IL(e,t,n,a,o);let u=Math.max(28,Math.min(t,n)*.09),d=r*u*.35%u;e.lineWidth=Math.max(1,Math.min(t,n)*.0022),e.strokeStyle=s,e.beginPath();for(let r=-u+d%u;r<=t+u;r+=u)e.moveTo(r,0),e.lineTo(r,n);for(let r=-u+d;r<=n+u;r+=u)e.moveTo(0,r),e.lineTo(t,r);e.stroke();let f=e.createRadialGradient(t/2,n*.45,0,t/2,n*.45,Math.max(t,n)*.6);f.addColorStop(0,c),f.addColorStop(1,l),e.fillStyle=f,e.fillRect(0,0,t,n)}function HL(e,t,n,r){IL(e,t,n,`#050716`,`#0b1030`);let i=[{c:`rgba(90,220,200,0.55)`,fx:.07,fy:.05,px:.3,py:.35,r:.55},{c:`rgba(140,90,240,0.5)`,fx:.05,fy:.08,px:.7,py:.5,r:.6},{c:`rgba(60,140,255,0.5)`,fx:.09,fy:.06,px:.5,py:.7,r:.5},{c:`rgba(240,120,190,0.4)`,fx:.06,fy:.09,px:.4,py:.2,r:.45}];e.globalCompositeOperation=`lighter`;for(let a=0;a<i.length;a++){let o=i[a],s=t*(o.px+.18*Math.sin(r*o.fx*Math.PI*2+a)),c=n*(o.py+.16*Math.cos(r*o.fy*Math.PI*2+a*1.7)),l=Math.max(t,n)*o.r,u=e.createRadialGradient(s,c,0,s,c,l);u.addColorStop(0,o.c),u.addColorStop(1,`rgba(0,0,0,0)`),e.fillStyle=u,e.fillRect(0,0,t,n)}e.globalCompositeOperation=`source-over`}function UL(e,t,n,r){IL(e,t,n,`#1a1130`,`#2a0f3a`);let i=[{c:`rgba(255,120,80,0.55)`,bx:.25,by:.3},{c:`rgba(255,80,160,0.5)`,bx:.75,by:.28},{c:`rgba(120,90,255,0.5)`,bx:.7,by:.75},{c:`rgba(80,200,255,0.45)`,bx:.28,by:.72}];e.globalCompositeOperation=`lighter`;for(let a=0;a<i.length;a++){let o=i[a],s=t*(o.bx+.1*Math.sin(r*.15*Math.PI+a*1.3)),c=n*(o.by+.1*Math.cos(r*.13*Math.PI+a*.9)),l=Math.max(t,n)*(.5+.06*Math.sin(r*.2+a)),u=e.createRadialGradient(s,c,0,s,c,l);u.addColorStop(0,o.c),u.addColorStop(1,`rgba(0,0,0,0)`),e.fillStyle=u,e.fillRect(0,0,t,n)}e.globalCompositeOperation=`source-over`}function WL(e,t,n,r,i){let a;if(YL(i)){let r=i[0]||$L[0],o=i[1]||$L[1];IL(e,t,n,r,zL(r,o,.18)),a=e=>BL(o,e)}else IL(e,t,n,`#0b1226`,`#152244`),a=e=>`rgba(150,190,255,${e})`;let o=n*1.25;e.globalCompositeOperation=`lighter`;for(let i=0;i<46;i++){let s=.4+LL(i)*.9,c=(.01+LL(i+99)*.04)*Math.min(t,n),l=(LL(i+7)+.05*Math.sin(r*.3+i))*t,u=n+c-(r*s*n*.06+LL(i+31)*o)%o,d=.15+LL(i+53)*.4,f=e.createRadialGradient(l,u,0,l,u,c);f.addColorStop(0,a(d)),f.addColorStop(1,a(0)),e.fillStyle=f,e.beginPath(),e.arc(l,u,c,0,Math.PI*2),e.fill()}e.globalCompositeOperation=`source-over`}function GL(e,t,n,r){IL(e,t,n,`#04122a`,`#0a2e4a`);for(let i of[{c:`rgba(30,140,200,0.5)`,amp:.05,base:.62,k:1.3,spd:.5},{c:`rgba(40,190,180,0.5)`,amp:.06,base:.72,k:1,spd:-.7},{c:`rgba(80,110,230,0.55)`,amp:.07,base:.82,k:.8,spd:.9}]){e.beginPath(),e.moveTo(0,n);let a=Math.max(6,t/120);for(let o=0;o<=t;o+=a){let a=o/t*Math.PI*2*i.k+r*i.spd,s=n*i.base+Math.sin(a)*n*i.amp;e.lineTo(o,s)}e.lineTo(t,n),e.closePath(),e.fillStyle=i.c,e.fill()}}function KL(e,t,n,r,i){let a=YL(i),o=a?i[0]||eR[0]:`#e8e4da`,s=a?i[1]||eR[1]:`#57503f`,c=Math.floor(Math.max(0,Number(r)||0)/XL)%ZL*977,l=Math.min(t,n)/360;IL(e,t,n,o,zL(o,s,.08));let u=e.createRadialGradient(t/2,n/2,Math.min(t,n)*.35,t/2,n/2,Math.max(t,n)*.75);u.addColorStop(0,BL(s,0)),u.addColorStop(1,BL(s,.1)),e.fillStyle=u,e.fillRect(0,0,t,n);for(let r=0;r<6;r++){let i=LL(c+11+r)*t,a=LL(c+23+r)*n,o=Math.max(t,n)*(.1+.16*LL(c+37+r)),l=e.createRadialGradient(i,a,0,i,a,o);l.addColorStop(0,BL(s,.055)),l.addColorStop(1,BL(s,0)),e.fillStyle=l,e.fillRect(0,0,t,n)}let d=Math.max(24,Math.min(t,n)*.075),f=(LL(c+3)-.5)*3*l,p=(LL(c+4)-.5)*3*l;e.lineWidth=Math.max(1,l*1.1),e.strokeStyle=BL(s,.16),e.beginPath();for(let r=-d+f;r<=t+d;r+=d)e.moveTo(r,0),e.lineTo(r,n);for(let r=-d+p;r<=n+d;r+=d)e.moveTo(0,r),e.lineTo(t,r);e.stroke(),e.fillStyle=BL(s,.5);for(let r=0;r<42;r++){let i=LL(c+101+r)*t,a=LL(c+211+r)*n,o=(.8+1.8*LL(c+307+r))*l;e.globalAlpha=.22+.38*LL(c+401+r),e.fillRect(i,a,o,o)}e.strokeStyle=BL(s,.3),e.lineWidth=Math.max(.6,l*.7);for(let r=0;r<14;r++){let i=LL(c+503+r)*t,a=LL(c+601+r)*n,o=LL(c+701+r)*Math.PI*2,s=(4+6*LL(c+809+r))*l;e.globalAlpha=.15+.2*LL(c+907+r),e.beginPath(),e.moveTo(i,a),e.lineTo(i+Math.cos(o)*s,a+Math.sin(o)*s),e.stroke()}for(let r=0;r<160;r++){let i=LL(c+1103+r)*t,a=LL(c+1301+r)*n,o=r%2==0;e.fillStyle=o?BL(s,1):`#ffffff`,e.globalAlpha=o?.04+.05*LL(c+1409+r):.05+.07*LL(c+1511+r),e.fillRect(i,a,l,l)}e.globalAlpha=1}function qL(e){if(typeof e!=`string`||!e.startsWith(`anim|`))return null;let[,t,...n]=e.split(`|`);return tR[t]?{key:t,colors:n}:null}function JL(e,t,n,r,i){let a=qL(t);return a?(tR[a.key].draw(e,n,r,Number(i)||0,a.colors),!0):!1}var YL,XL,ZL,QL,$L,eR,tR,nR=o((()=>{YL=e=>Array.isArray(e)&&e.length>0,XL=.17,ZL=8,QL=[`#0a1a3f`,`#3b7dff`],$L=[`#0b1226`,`#96beff`],eR=[`#e8e4da`,`#57503f`],tR={grid:{label:`Blue Grid`,draw:VL,css:`linear-gradient(180deg, #0a1a3f, #123a8a)`,tunable:[{key:`base`,label:`Background`,default:QL[0]},{key:`accent`,label:`Grid & glow`,default:QL[1]}]},aurora:{label:`Aurora`,draw:HL,css:`radial-gradient(circle at 35% 40%, rgba(90,220,200,0.7), rgba(140,90,240,0.5) 45%, #0b1030 80%)`},mesh:{label:`Mesh`,draw:UL,css:`radial-gradient(circle at 30% 30%, rgba(255,120,80,0.7), rgba(120,90,255,0.5) 55%, #2a0f3a 85%)`},bokeh:{label:`Bokeh`,draw:WL,css:`radial-gradient(circle at 60% 70%, rgba(150,190,255,0.5), #152244 70%)`,tunable:[{key:`base`,label:`Background`,default:$L[0]},{key:`accent`,label:`Dots`,default:$L[1]}]},waves:{label:`Waves`,draw:GL,css:`linear-gradient(180deg, #0a2e4a 40%, rgba(40,190,180,0.6) 70%, #04122a)`},paper:{label:`Paper`,draw:KL,css:`linear-gradient(180deg, #e8e4da, #ded9cd)`,tunable:[{key:`base`,label:`Paper`,default:eR[0]},{key:`accent`,label:`Grid & flecks`,default:eR[1]}]}}}));function rR(e,t,n,r,i){let a=typeof t==`string`?t:``;if(!JL(e,a,n,r,(Number(i)||0)/1e3)){if(a.startsWith(`radial|`)||a.startsWith(`linear|`)){let t=a.split(`|`),i;if(t[0]===`radial`){let a=t.slice(1);i=e.createRadialGradient(n/2,r*.42,Math.min(n,r)*.05,n/2,r*.5,Math.max(n,r)*.72),iR(i,a)}else{let a=Number(t[1])||90,o=t.slice(2),s=(a-90)*Math.PI/180,c=Math.max(n,r)/2,l=Math.cos(s)*c,u=Math.sin(s)*c;i=e.createLinearGradient(n/2-l,r/2-u,n/2+l,r/2+u),iR(i,o)}e.fillStyle=i}else e.fillStyle=a||`#ffffff`;e.fillRect(0,0,n,r)}}function iR(e,t){let n=t.length;t.forEach((t,r)=>e.addColorStop(n===1?0:r/(n-1),t))}function aR(e){let t=Number(e?.videoWidth||e?.width||e?.naturalWidth||e?.displayWidth)||0,n=Number(e?.videoHeight||e?.height||e?.naturalHeight||e?.displayHeight)||0;return{w:Math.max(1,t),h:Math.max(1,n)}}function oR(e,t){let n=Math.max(0,(t-(e.appearMs||0))/1e3),r=Number(e.speed)>0?Number(e.speed):1,i=Math.max(0,Number(e.trimStartSec)||0),a=i+n*r,o=Number(e.durationSec)||0;if(o>0){let t=Math.max(.05,o-i);a=e.loop===!1?Math.min(a,o-.05):i+(a-i)%t}return a}function sR(e,t){if(Array.isArray(e.wordTimes)&&Number.isFinite(Number(e.wordTimes[t])))return Number(e.wordTimes[t]);let n=e.anim?.speedMs||180;return(e.appearMs||0)+t*n}function cR(e,t){return String(e.text||``).split(/\s+/).filter(Boolean).map((n,r)=>{let i=sR(e,r),a=t-i;return{text:n,start:i,local:a,p:vR(a/320,0,1),spoken:a>=0}})}function lR(e,t){let n=cR(e,t),r=0;for(let t=0;t<n.length;t++){let i=n[t];if(!i.spoken)break;let a=t+1<n.length?Math.max(40,n[t+1].start-i.start):(e.anim?.speedMs||180)*2,o=vR(i.local/a,0,1);r+=Math.round(o*(i.text.length+1))}return r}function uR(e,t,n){if(!e.motion||e.motion.type===`none`||t<(e.appearMs||0))return null;let r=e.leaveMs==null?n||0:e.leaveMs,i=Math.max(.1,(r-(e.appearMs||0))/1e3),a=(t-(e.appearMs||0))/1e3;return Ld(e.motion,a,i)}function dR(e,t,n){return e+(t-e)*n}function fR(e,t){let n=Math.max(0,Math.min(1,e));return t===`linear`?n:t===`ease-in`?n*n:t===`ease-out`?1-(1-n)*(1-n):n<.5?2*n*n:1-(-2*n+2)**2/2}function pR(e,t){let n={x:e.pos?.x??.5,y:e.pos?.y??.5,size:e.size},r=Array.isArray(e.moves)?e.moves.filter(e=>e&&typeof e==`object`).slice().sort((e,t)=>(e.atMs||0)-(t.atMs||0)):[],i=n;for(let e=0;e<r.length;e++){let n=r[e],a=Number(n.atMs)||0;if(t<a)break;let o=Number(n.durMs),s=Number.isFinite(o)&&o>=0?o:500,c=e+1<r.length?Number(r[e+1].atMs)||0:1/0,l=Math.max(0,Math.min(s,c-a)),u={x:n.pos?.x==null?i.x:n.pos.x,y:n.pos?.y==null?i.y:n.pos.y,size:n.size==null?i.size:n.size};if(l<=0||t>=a+l){i=u;continue}let d=fR((t-a)/l,n.ease);return{pos:{x:dR(i.x,u.x,d),y:dR(i.y,u.y,d)},size:i.size!=null&&u.size!=null?dR(i.size,u.size,d):u.size??i.size}}return{pos:{x:i.x,y:i.y},size:i.size}}function mR(e,t,n){let r=t.shadow==null?.18:Math.max(0,Math.min(1,Number(t.shadow)));if(r<=.001){e.shadowColor=`transparent`,e.shadowBlur=0,e.shadowOffsetY=0;return}e.shadowColor=`rgba(0,0,0,${r})`,e.shadowBlur=n*(.03+r*.14),e.shadowOffsetY=n*(.008+r*.05)}function hR(e,t){return(e?.elements||[]).filter(e=>t>=(e.appearMs||0)&&(e.leaveMs==null||t<e.leaveMs))}function gR(e,t,n=`pop`){let r=t-(e.appearMs||0),i=vR(r/320,0,1),a=1-(1-i)*(1-i);switch(e.kind===`text`?e.anim?.type||`pop`:e.entrance||n||`pop`){case`fade`:return{alpha:a,scale:1,dy:0,p:i};case`rise`:return{alpha:a,scale:1,dy:(1-a)*.06,p:i};case`scale`:return{alpha:1,scale:.4+.6*a,dy:0,p:i};case`typewriter`:case`pop-word`:case`word-pop`:case`sentence-build`:case`highlight`:return{alpha:1,scale:1,dy:0,p:i};case`line`:{let e=i<.7?i/.7*1.12:1.12-.12*((i-.7)/.3);return{alpha:Math.min(1,i*2.5),scale:e,dy:0,p:i}}default:{let e=i<.7?i/.7*1.12:1.12-.12*((i-.7)/.3);return{alpha:Math.min(1,i*2.5),scale:e,dy:0,p:i}}}}function _R(e,t,n,r,i,a){e.save(),rR(e,t.background,i,a,n);let o=t.handoff?.arrive===`fade`?`fade`:`pop`;for(let s of hR(t,n)){let c=gR(s,n,o),l=pR(s,n),u=l.pos,d=l.size==null?s.size:l.size,f=u.x*i,p=(u.y+(c.dy||0))*a;e.save(),e.globalAlpha=c.alpha,e.translate(f,p);let m=uR(s,n,t.durationMs);if(m&&(e.translate(m.tx/100*i,m.ty/100*a),m.rot&&e.rotate(m.rot*Math.PI/180),m.scale!==1&&e.scale(m.scale,m.scale),m.blur>.01&&(e.filter=`blur(${(m.blur*(a/1080)).toFixed(2)}px)`)),s.tilt&&e.rotate(s.tilt*Math.PI/180),c.scale!==1&&e.scale(c.scale,c.scale),s.kind===`image`||s.kind===`video`){let t=s.src?r(s.src,s):null;!t&&s.kind===`video`&&s.poster&&(t=r(s.poster,s));let n=(d||.28)*i,o=s.box?Math.max(1,s.box.h*a):null,c=s.box?Math.max(1,s.box.w*i):null;if(t&&c){let{w:n,h:r}=aR(t),i=Math.max(c/n,o/r),a=c/i,l=o/i,u=(n-a)/2,d=(r-l)/2;mR(e,s,c),s.cutout||(e.fillStyle=`#fff`,e.fillRect(-c/2-c*.02,-o/2-c*.02,c+c*.04,o+c*.04),e.shadowColor=`transparent`),e.drawImage(t,u,d,a,l,-c/2,-o/2,c,o),s.cutout&&(e.shadowColor=`transparent`)}else if(t){let{w:r,h:i}=aR(t),a=i/r*n;mR(e,s,n),s.cutout||(e.fillStyle=`#fff`,e.fillRect(-n/2-n*.02,-a/2-n*.02,n+n*.04,a+n*.04),e.shadowColor=`transparent`),e.drawImage(t,-n/2,-a/2,n,a),s.cutout&&(e.shadowColor=`transparent`)}else{let t=c||n,r=o||n*.66;e.strokeStyle=`rgba(0,0,0,0.25)`,e.setLineDash([6,5]),e.lineWidth=2,e.strokeRect(-t/2,-r/2,t,r),e.setLineDash([]),e.fillStyle=`rgba(0,0,0,0.4)`,e.font=`${Math.round(a*.028)}px Hanken Grotesk, Arial, sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(String(s.query||(s.kind===`video`?`video`:`image`)).slice(0,28),0,0)}}else{let t=Math.max(10,(d||.07)*a);e.font=`${s.weight||700} ${t}px ${s.font||`Hanken Grotesk`}, Arial, sans-serif`,e.fillStyle=s.color||`#111111`,e.textAlign=`center`,e.textBaseline=`middle`;let r=s.anim?.type||`pop`,i=String(s.text||``);if(r===`typewriter`){if(Array.isArray(s.wordTimes)&&s.wordTimes.length){let t=lR(s,n);e.fillText(i.slice(0,t),0,0)}else{let t=s.anim?.speedMs||45,r=Math.max(0,Math.floor((n-(s.appearMs||0))/t));e.fillText(i.slice(0,r),0,0)}}else if(r===`pop-word`||r===`word-pop`||r===`sentence-build`||r===`highlight`){let i=cR(s,n),a=i.map(t=>e.measureText(`${t.text} `).width),o=-a.reduce((e,t)=>e+t,0)/2,l=s.anim?.entrance||`pop`;for(let n=0;n<i.length;n++){let s=i[n];if(r===`highlight`)e.save(),e.translate(o+a[n]/2,0),e.globalAlpha=c.alpha*(s.spoken?1:.3),e.fillText(s.text,0,0),e.restore();else if(s.spoken){let i=s.p;e.save();let u=1,d=0,f=0,p=Math.min(1,i*2.5);if(r===`sentence-build`){let e=1-(1-i)*(1-i);l===`fade`?p=e:l===`slide`?(d=(1-e)*-t*.8,p=e):l===`rise`?(f=(1-e)*t*.6,p=e):l===`scale`?(u=.4+.6*e,p=1):u=i<.7?i/.7*1.12:1.12-.12*((i-.7)/.3)}else u=i<.7?i/.7*1.12:1.12-.12*((i-.7)/.3);e.translate(o+a[n]/2+d,f),e.scale(u,u),e.globalAlpha=c.alpha*p,e.fillText(s.text,0,0),e.restore()}o+=a[n]}}else e.fillText(i,0,0)}e.restore()}e.restore()}var vR,yR=o((()=>{Vd(),nR(),[...Object.entries(tR).map(([e,t])=>({key:`anim-${e}`,label:t.label,value:`anim|${e}`,animated:!0}))],vR=(e,t,n)=>Math.max(t,Math.min(n,e))}));function bR(e){return e===`9:16`?[1080,1920]:e===`1:1`?[1080,1080]:[1920,1080]}async function xR(e,t=1920,n=1080){let r=typeof OffscreenCanvas<`u`?new OffscreenCanvas(t,n):Object.assign(document.createElement(`canvas`),{width:t,height:n}),i=r.getContext(`2d`),a=new Map,o=new Set;for(let t of e?.elements||[])t.kind===`image`&&t.src&&o.add(t.src),t.kind===`video`&&t.poster&&o.add(t.poster);await Promise.all([...o].map(e=>new Promise(t=>{let n=new Image;n.crossOrigin=`anonymous`,n.onload=()=>{a.set(e,n),t()},n.onerror=()=>t(),n.src=e})));let s=(e?.elements||[]).filter(e=>e.kind===`video`&&e.src),c=new Map;await Promise.all(s.map(e=>new Promise(t=>{if(typeof document>`u`)return t();let n=document.createElement(`video`);n.crossOrigin=`anonymous`,n.muted=!0,n.playsInline=!0,n.preload=`auto`;let r=()=>t();n.addEventListener(`loadeddata`,()=>{c.set(e.id,n),r()},{once:!0}),n.addEventListener(`error`,r,{once:!0}),setTimeout(r,8e3),n.src=e.src})));let l=(e,t)=>new Promise(n=>{if(Math.abs((e.currentTime||0)-t)<CR)return n();let r=setTimeout(n,SR);e.addEventListener(`seeked`,()=>{clearTimeout(r),n()},{once:!0});try{e.currentTime=t}catch{clearTimeout(r),n()}});return{width:t,height:n,frameAt:async o=>{let u=Math.max(0,o)*1e3;for(let e of s){let t=c.get(e.id);if(!t||u<(e.appearMs||0)||e.leaveMs!=null&&u>=e.leaveMs)continue;let n=Number(e.durationSec)||t.duration||0;await l(t,oR({...e,durationSec:n},u))}return _R(i,e,u,(e,t)=>a.get(e)||(t&&t.src===e?c.get(t.id):null)||null,t,n),r},close:()=>{a.clear();for(let e of c.values())try{e.pause(),e.removeAttribute(`src`),e.load()}catch{}c.clear()}}}var SR,CR,wR=o((()=>{yR(),SR=1500,CR=.006}));async function TR(e){let t=e?.original;if(!t?.assetId||!t?.versionId)return null;try{let e=hp(t);return e?await mp(e):null}catch{return null}}function ER(e){return e===`16:9`?[1920,1080]:e===`1:1`?[1080,1080]:[1080,1920]}function DR(e){return e?.aspect===`9:16`?[1080,1920]:e?.aspect===`1:1`?[1080,1080]:[1920,1080]}async function OR(e){let t=e.kind||`image`;if(t===`vector-scene`&&e.scene){let[t,n]=DR(e.scene),r=mk(e.scene,t,n,{debug:e.debug}),i=e.trimStart||0,a=e.speed||1;return{width:r.width,height:r.height,frameAt:e=>r.frameAt(i+Math.max(0,e)*a),close:()=>r.close?.()}}if(t===`collage`&&e.collage){let[t,n]=bR(e.collage.aspect),r=await xR(e.collage,t,n);return{width:r.width,height:r.height,frameAt:t=>r.frameAt(Math.max(0,t)*(e.speed||1)+(e.trimStart||0)),close:()=>r.close?.()}}if(t===`v2-scene`&&e.v2video){let[t,n]=ER(e.v2video.meta?.aspect),r=PL(e.v2video,t,n),i=e.trimStart||0,a=e.speed||1;return{width:r.width,height:r.height,frameAt:e=>r.frameAt(i+Math.max(0,e)*a),close:()=>r.close?.()}}let n=t===`video`?await dp(e.url):null;if(n)return kR({...e,url:n},null);let r=await TR(e)||await lp(e);if(fp(r))throw Error(`Can't find "${r.name}" on this device. Reconnect your local folder or re-import it, then try the export again.`);if(t===`video`&&(r.type||``).startsWith(`image/`)&&(t=`image`),t===`image`)try{let e=await createImageBitmap(r);return{frameAt:async()=>e,close:()=>e.close?.()}}catch{let t=URL.createObjectURL(r),n=new Image;await new Promise((r,i)=>{n.onload=r,n.onerror=()=>i(Error(`image load failed: ${e.title||e.url}`)),n.src=t});let i=await createImageBitmap(n);return URL.revokeObjectURL(t),{frameAt:async()=>i,close:()=>i.close?.()}}if(!e.reverse)try{return await GC(e,await r.arrayBuffer())}catch(t){console.warn(`[export] WebCodecs decode failed, seek fallback:`,e.title||e.url,t?.message||t)}return kR(e,r)}async function kR(e,t){let n=document.createElement(`video`);n.crossOrigin=`anonymous`,n.muted=!0,n.preload=`auto`,n.playsInline=!0;let r=t?URL.createObjectURL(t):e.url;n.src=r,await new Promise((t,r)=>{let i=()=>{s(),t()},a=()=>{s(),r(Error(`video load failed: ${e.title||e.url}`))},o=setTimeout(()=>{s(),r(Error(`video load timeout: ${e.title||e.url}`))},3e4);function s(){clearTimeout(o),n.removeEventListener(`loadeddata`,i),n.removeEventListener(`error`,a)}n.addEventListener(`loadeddata`,i),n.addEventListener(`error`,a)});let i=e.speed||1,a=e.trimStart||0,o=n.duration||0;return{async frameAt(t){let r=e.reverse?(e.trimEnd??o)-t*i:a+t*i;return r=Math.max(0,Math.min(Math.max(0,o-.001),r)),Math.abs(n.currentTime-r)>.001&&await new Promise(e=>{let t=()=>{n.removeEventListener(`seeked`,t),e()};n.addEventListener(`seeked`,t),n.currentTime=r,setTimeout(e,2e3)}),n},close(){try{n.removeAttribute(`src`),n.load(),URL.revokeObjectURL(r)}catch{}}}}var AR=o((()=>{KC(),vp(),gk(),FL(),wR()}));async function jR(e){let t=[];for(let n of e||[]){let e=n?.kind||`image`;if(!n?.url||e===`vector-scene`||e===`v2-scene`||e===`collage`||!LR(n))continue;let r=null;try{if(n.original?.assetId&&n.original?.versionId){let e=hp(n.original);e&&(r=await mp(e).catch(()=>null))}r||=await lp(n)}catch{continue}fp(r)&&t.push(r.name||n.title||n.url)}return[...new Set(t)]}function MR(e,t){let n=String(e||``).split(/[:/]/).map(Number),[r,i]=n.length===2&&n[0]>0&&n[1]>0?n:[16,9],a=[720,1080].includes(Number(t))?Number(t):1080,o,s;return r>=i?(s=a,o=Math.round(r/i*a)):(o=a,s=Math.round(i/r*a)),o-=o%2,s-=s%2,[Math.max(2,o),Math.max(2,s)]}function NR(e={}){let t=e||{},n=[24,30,60].includes(t.fps)?t.fps:RR.fps,[r,i]=MR(t.aspect||`16:9`,t.resolution),a=t.quality===`standard`?.1:.15;return{width:r,height:i,fps:n,bitrate:Math.min(28e6,Math.max(2e6,Math.round(r*i*n*a)))}}function PR(e){let t=new Map((e||[]).map((e,t)=>[e,t]));return(e,n)=>{let r=t.has(e.trackId)?t.get(e.trackId):0,i=t.has(n.trackId)?t.get(n.trackId):0;return r===i?(e.start||0)-(n.start||0):r-i}}async function FR(e,t){let n;for(let e=0;;e++)try{n=await up(t);break}catch(t){if(e>=2)throw Error(`audio fetch failed after ${e+1} tries: ${t.message}`);await new Promise(t=>setTimeout(t,400*(e+1)))}if(fp(n))throw Error(`Can't find audio "${n.name}" on this device. Reconnect your local folder or re-import it, then try the export again.`);return e.decodeAudioData(n)}async function IR(e,{onProgress:t,settings:n,nativeAudio:r=null}={}){let{clips:i=[],audio:a=[],targetDuration:o=0,trackOrder:s=[],overlays:c=[],stickers:l=[],blurs:u=[],zooms:d=[],polishFx:f=[],fullscreenFrames:p=[],figureSweeps:m=[],graphs:h=[],fxEvents:g=[],liveOverlays:_=[],previewH:v=0,backgroundColor:y=`#000000`,stillmadeWatermark:b=!1,stillmadeWatermarkPos:x=`br`,stillmadeWatermarkOpacity:S=null,stillmadeWatermarkLook:C=null,stillmadeEndScreen:w=!1,stillmadeEndScreenSec:T=void 0,stillmadeEndScreenAnim:E=void 0}=e||{},D=await jR(i);if(D.length){let e=D.length===1?D[0]:`${D.slice(0,-1).join(`, `)} and ${D.at(-1)}`;throw Error(`Can't find ${D.length===1?`this file`:`these files`} on this device: ${e}. Reconnect your local folder or re-import, then try the export again. If you just re-imported ${D.length===1?`it`:`them`}, choose Update affected steps on the Steps after Import media first, so they use the new copies.`)}let O=i.filter(e=>e&&(e.url||e.kind===`vector-scene`&&e.scene||e.kind===`v2-scene`&&e.v2video||e.kind===`collage`&&e.collage)).map(e=>({id:e.id,kind:e.kind||`image`,url:e.url,scene:e.kind===`vector-scene`?e.scene:void 0,v2video:e.kind===`v2-scene`?e.v2video:void 0,collage:e.kind===`collage`?e.collage:void 0,source:e.source,localKey:e.localKey,original:e.original,title:e.title,trackId:e.trackId,start:e.start||0,duration:e.duration||0,speed:e.speed||1,reverse:!!e.reverse,trimStart:(e.trimStart||0)+(e.sourceOffset||0),trimEnd:e.trimEnd,motion:e.motion,color:e.color,lut:e.lut,transition:e.transition,speedRamp:e.speedRamp,freeze:e.freeze,transform:{...e.transform||{},opacity:e.transform?.opacity??e.opacity??1},shareSource:!!e.shareSource})).sort(PR(s)),k=O.reduce((e,t)=>Math.max(e,t.start+t.duration),0),A=a.reduce((e,t)=>Math.max(e,(t.start||0)+(t.duration||0)),0),j=Math.max(o||0,k,A,1),M=w?j+mm(T):j,N=[],P=new Map;for(let e of O)P.has(e.trackId)||P.set(e.trackId,[]),P.get(e.trackId).push(e);for(let e of P.values()){e.sort((e,t)=>e.start-t.start);for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1],i=n.transition?.type;if(!i||i===`Cut`)continue;let a=Math.min(n.transition.duration||.5,n.duration*.9,r.duration*.9);a<=.01||N.push({outId:n.id,inId:r.id,type:i,startT:Math.max(0,n.start+n.duration-a/2),dur:a,color:n.transition.color||null})}}let F=null,I=a.filter(e=>e&&e.url);if(I.length&&r===null){let e=new(window.AudioContext||window.webkitAudioContext),n=[],r=new Map;for(let i of I){t&&t({phase:`audio-decode`});try{let t=`${i.source||``}\u0000${i.localKey||``}\u0000${i.url}`;r.has(t)||r.set(t,FR(e,i));let a=await r.get(t);n.push({audioBuffer:a,start:i.start||0,durationSec:i.duration||a.duration,volume:(i.volume??80)/100,fadeIn:i.fadeIn||0,fadeOut:i.fadeOut||0,sourceOffset:i.sourceOffset||0,loop:!!i.loop,rate:i.rate>0?i.rate:1})}catch(t){if(!i.embedded){try{e.close?.()}catch{}throw Error(`Audio "${i.title||i.url}" failed to load (${t.message}). Export stopped so this sound isn't silently missing — if retrying doesn't fix it, re-import or replace that item (its source may be gone).`)}console.warn(`[export] audio decode failed, skipping:`,i.url,t.message)}}try{e.close?.()}catch{}n.length&&(F=await jd(n,{duration:M}))}let ee={...n,aspect:n?.aspect||e?.aspect||e?.aspectRatio};return{...RR,...NR(ee),duration:M,layers:O,transitions:N,overlays:c,stickers:l,blurs:u,zooms:d,polishFx:f,fullscreenFrames:p,figureSweeps:m,graphs:h,fxEvents:g,liveOverlays:_,previewH:v,backgroundColor:y,stillmadeWatermark:b,stillmadeWatermarkPos:x,stillmadeWatermarkOpacity:S,stillmadeWatermarkLook:C,stillmadeEndScreen:w,stillmadeEndScreenSec:T,stillmadeEndScreenAnim:E,audioBuffer:F,nativeAudio:r}}var LR,RR,zR=o((()=>{Nd(),vp(),Dm(),LR=e=>!!(e?.original?.assetId&&e?.original?.versionId)||/^(?:sm-media|blob|file):/i.test(String(e?.url||``)),RR={width:1920,height:1080,fps:60,bitrate:18e6}}));function BR(e){return e instanceof Blob&&VR.add(e),e}var VR,HR=o((()=>{VR=new WeakSet})),UR=c({renderNative:()=>GR,wavHeader:()=>WR});function WR(e){let t=e.numberOfChannels,n=e.length*t*2;if(n>4294967259)throw Error(`Audio exceeds WAV size limit`);let r=new Uint8Array(44),i=new DataView(r.buffer),a=(e,t)=>[...t].forEach((t,n)=>i.setUint8(e+n,t.charCodeAt(0)));return a(0,`RIFF`),i.setUint32(4,n+36,!0),a(8,`WAVE`),a(12,`fmt `),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,t,!0),i.setUint32(24,e.sampleRate,!0),i.setUint32(28,e.sampleRate*t*2,!0),i.setUint16(32,t*2,!0),i.setUint16(34,16,!0),a(36,`data`),i.setUint32(40,n,!0),r}async function GR(e,{onProgress:t,signal:n,exportAuthorization:r}={}){let i=_p(),a=new Map,o,s=()=>{if(n?.aborted)throw Error(`Export aborted`)},c=()=>{o&&i.cancelExport(o.id).catch(()=>{})};n?.addEventListener(`abort`,c,{once:!0});try{s();let n=Math.max(1,Math.round(e.duration*e.fps));if(o=await i.beginExport({width:e.width,height:e.height,fps:e.fps,frames:n},r?.ticket),s(),await document.fonts?.ready,s(),e.stickers?.some(e=>e.shape===`gif`)){let{preloadGifStickers:t}=await Ti(async()=>{let{preloadGifStickers:e}=await Promise.resolve().then(()=>(Up(),Cp));return{preloadGifStickers:e}},void 0);await t(e.stickers)}for(let t of e.layers)s(),a.has(t.id)||a.set(t.id,await OR(t));let c=new OffscreenCanvas(e.width,e.height).getContext(`2d`,{willReadFrequently:!0});for(let r=0;r<n;r++)s(),await Wg(c,e,r/e.fps,a,e.width,e.height),s(),await i.writeExportFrame(o.id,r,new Uint8Array(c.getImageData(0,0,e.width,e.height).data.buffer)),s(),(r%12==0||r===n-1)&&t?.({phase:`video`,done:r+1,total:n});if(e.nativeAudio?.length&&(s(),t?.({phase:`audio`}),await i.mixExportAudio(o.id,e.nativeAudio),s()),s(),e.audioBuffer){let n=e.audioBuffer;t?.({phase:`audio`}),await i.writeExportAudio(o.id,WR(n));let r=Array.from({length:n.numberOfChannels},(e,t)=>n.getChannelData(t));for(let e=0;e<n.length;e+=16384){s();let t=Math.min(16384,n.length-e),a=new Uint8Array(t*r.length*2),c=new DataView(a.buffer);for(let n=0;n<t;n++)for(let t=0;t<r.length;t++){let i=Math.max(-1,Math.min(1,r[t][e+n]));c.setInt16((n*r.length+t)*2,Math.round(i<0?i*32768:i*32767),!0)}await i.writeExportAudio(o.id,a)}}s();let l=await i.finishExport(o.id);return o=null,s(),t?.({phase:`done`}),l}finally{n?.removeEventListener(`abort`,c);for(let e of a.values())e.close?.();o&&await i.cancelExport(o.id).catch(()=>{})}}var KR=o((()=>{Jg(),AR(),vp(),Ei()}));async function qR(){return _p()&&(await _p().capabilities()).nativeTimelineExport?{strategy:`native`}:zi()}async function JR(e,t={}){cz(t.signal),t.exportAuthorization?.watermark===!0&&(e={...e,stillmadeWatermark:!0,stillmadeWatermarkLook:t.exportAuthorization.mark||null});let n=_p(),r=n&&(await n.capabilities()).nativeTimelineExport;cz(t.signal);let i=r&&n.prepareNativeAudio?await n.prepareNativeAudio(e.audio||[]):null;cz(t.signal);let a=await IR(e,{...t,nativeAudio:i});if(a.stillmadeWatermark||a.stillmadeEndScreen)try{await Promise.all(bm().map(e=>document.fonts.load(e)))}catch{}cz(t.signal);let o=r?await(await Ti(async()=>{let{renderNative:e}=await Promise.resolve().then(()=>(KR(),UR));return{renderNative:e}},void 0)).renderNative(a,t):await $R(a,t);return t.exportAuthorization?BR(o):o}async function YR(e,{width:t,height:n,duration:r,fps:i=30,shortSide:a=1080,signal:o,onProgress:s,render:c=$R,plan:l=IR}={}){if(cz(o),!(e instanceof Blob)||!e.size)throw Error(`A video file is needed for a working copy.`);if(!(t>0&&n>0&&r>0))throw Error(`The video’s size and length are needed before it can be made smaller.`);if(Math.min(t,n)<720)throw Error(`no-gain`);let u=URL.createObjectURL(e);try{let e=await l({clips:[{id:`working`,kind:`video`,url:u,start:0,duration:r,trimStart:0,speed:1,trackId:`video`}],audio:[{id:`working-audio`,url:u,start:0,duration:r,trimStart:0,volume:1,trackId:`audio`}],targetDuration:r,trackOrder:[`video`],stillmadeWatermark:!1,stillmadeEndScreen:!1},{settings:{aspect:`${t}:${n}`,resolution:Math.min(a,1080)>=1080?1080:720,fps:[24,30,60].includes(i)?i:30,quality:`standard`},onProgress:s,signal:o});cz(o);let d=await c(e,{onProgress:s,signal:o});return d instanceof Blob?d:new Blob([d],{type:`video/mp4`})}finally{URL.revokeObjectURL(u)}}async function XR(e,{keep:t,width:n,height:r,duration:i,fps:a=30,shortSide:o=1080,signal:s,onProgress:c,render:l=$R,plan:u=IR}={}){cz(s);let d=e instanceof Blob&&e.size>0,f=typeof e==`string`&&e?e:d?URL.createObjectURL(e):null;if(!f)throw Error(`A video file is needed to cut.`);if(!(n>0&&r>0&&i>0))throw Error(`The video’s size and length are needed before it can be cut.`);let p=(Array.isArray(t)?t:[]).map(e=>({start:Math.max(0,Number(e?.start)),end:Math.min(i,Number(e?.end))})).filter(e=>Number.isFinite(e.start)&&Number.isFinite(e.end)&&e.end-e.start>.001);if(!p.length)throw Error(`Keep at least part of the recording.`);try{let e=0,t=[],i=[];for(let[n,r]of p.entries()){let a=r.end-r.start;t.push({id:`cut-${n}`,kind:`video`,url:f,start:e,duration:a,trimStart:r.start,speed:1,trackId:`video`}),i.push({id:`cut-audio-${n}`,url:f,start:e,duration:a,trimStart:r.start,volume:1,trackId:`audio`}),e+=a}let d=await u({clips:t,audio:i,targetDuration:e,trackOrder:[`video`],stillmadeWatermark:!1,stillmadeEndScreen:!1},{settings:{aspect:`${n}:${r}`,resolution:Math.min(n,r,o)>=1080?1080:720,fps:[24,30,60].includes(a)?a:30,quality:`standard`},onProgress:c,signal:s});cz(s);let m=await l(d,{onProgress:c,signal:s});return{file:m instanceof Blob?m:new Blob([m],{type:`video/mp4`}),duration:e}}finally{d&&URL.revokeObjectURL(f)}}async function ZR(e,t={}){cz(t.signal);let n=_p(),r=n?.beginAudioExport&&n.prepareNativeAudio?await n.prepareNativeAudio(e.audio||[]):null;cz(t.signal);let i=await IR(e,{...t,nativeAudio:r});if(cz(t.signal),r?.length){let e,a=()=>{e&&n.cancelExport(e.id).catch(()=>{})};try{e=await n.beginAudioExport(i.duration,t.exportAuthorization?.ticket),t.signal?.addEventListener(`abort`,a,{once:!0}),cz(t.signal),t.onProgress?.(.1),await n.mixExportAudio(e.id,r),cz(t.signal),t.onProgress?.(.8);let o=await n.finishExport(e.id);return e=null,cz(t.signal),t.onProgress?.(1),o}finally{t.signal?.removeEventListener(`abort`,a),e&&await n.cancelExport(e.id).catch(()=>{})}}if(!i.audioBuffer){let e=Error(`NO_AUDIO`);throw e.code=`NO_AUDIO`,e}return Md(i.audioBuffer,t)}async function QR(e,t){if(!e.shareSource||e.kind!==`video`||e.reverse||!e.url)return OR(e);t.has(e.url)||t.set(e.url,OR({...e,id:`shared:${e.url}`,start:0,trimStart:0,trimEnd:void 0,speed:1}));let n=await t.get(e.url),r=e.trimStart||0,i=e.speed||1;return{...n,frameAt:e=>n.frameAt(r+Math.max(0,e)*i),close(){}}}async function $R(e,t={}){let n=await zi();try{return await ez(e,t,n)}catch(r){if(t.signal?.aborted||n.hardwareAcceleration!==`prefer-hardware`||!/VideoEncoder|codec/i.test(String(r?.message||``)))throw r;return ez(e,t,{...n,hardwareAcceleration:`prefer-software`})}}async function ez(e,{onProgress:t,signal:n}={},r){if(r.strategy!==`webcodecs`)throw Error(`WebCodecs unavailable (wasm fallback is a later phase)`);let{width:i,height:a,fps:o,duration:s}=e;if(e.overlays?.length)try{await document.fonts?.ready}catch{}if(e.stickers?.some?.(e=>e?.shape===`gif`))try{let{preloadGifStickers:t}=await Ti(async()=>{let{preloadGifStickers:e}=await Promise.resolve().then(()=>(Up(),Cp));return{preloadGifStickers:e}},void 0);await t(e.stickers)}catch{}let c=new Map,l=new Map,u=null;try{for(let t of e.layers){if(n?.aborted)throw Error(`aborted`);c.has(t.id)||c.set(t.id,await QR(t,l))}let d=e.audioBuffer?await kd(e.audioBuffer):null,f=Math.max(1,Math.round(s*o)),p=d?Math.ceil(d.buffer.length/(d.codec===`opus`?960:1024))+64:0,m=Fs({width:i,height:a,fps:o,audio:d?{channels:d.buffer.numberOfChannels,sampleRate:d.buffer.sampleRate,codec:d.codec}:null,expected:{video:f+16,audio:p}});u=Ls({codec:r.videoCodec,width:i,height:a,fps:o,bitrate:e.bitrate||1e7,hardwareAcceleration:r.hardwareAcceleration||`prefer-hardware`,onChunk:(e,t)=>m.addVideoChunk(e,t)});let h=new OffscreenCanvas(i,a),g=h.getContext(`2d`),_=f;for(let r=0;r<_;r++){if(n?.aborted)throw Error(`aborted`);let s=r/o;await Wg(g,e,s,c,i,a),await u.encodeFrame(h,Math.round(s*1e6),r%48==0),t&&(r%12==0||r===_-1)&&t({phase:`video`,done:r+1,total:_})}return await u.finish(),u=null,d&&(t&&t({phase:`audio`}),await Ad(d.buffer,{config:d.config,onChunk:(e,t)=>m.addAudioChunk(e,t)})),t&&t({phase:`done`}),m.finalize()}finally{for(let e of c.values())try{e.close?.()}catch{}for(let e of l.values())try{(await e).close?.()}catch{}if(u)try{u.close()}catch{}}return e.audioBuffer&&(t&&t({phase:`audio`}),await Ad(e.audioBuffer,{onChunk:(e,t)=>muxer.addAudioChunk(e,t)})),t&&t({phase:`done`}),muxer.finalize()}async function tz(){let e=await zi();if(e.strategy!==`webcodecs`)return{ok:!1,reason:`no webcodecs`,caps:e};let t=44100,n=Fs({width:640,height:360,fps:24,audio:{channels:2,sampleRate:t}}),r=Ls({codec:e.videoCodec,width:640,height:360,fps:24,bitrate:2e6,onChunk:(e,t)=>n.addVideoChunk(e,t)}),i=new OffscreenCanvas(640,360),a=i.getContext(`2d`);for(let e=0;e<48;e++)a.fillStyle=`#101830`,a.fillRect(0,0,640,360),a.fillStyle=`#e0b84c`,a.fillRect(e/48*560,140,80,80),await r.encodeFrame(i,Math.round(e/24*1e6),e%48==0);await r.finish();let o=new OfflineAudioContext(2,t*2,t),s=o.createOscillator();s.frequency.value=440;let c=o.createGain();c.gain.value=.2,s.connect(c).connect(o.destination),s.start(0),s.stop(2),await Ad(await o.startRendering(),{onChunk:(e,t)=>n.addAudioChunk(e,t)});let l=n.finalize(),u=new Uint8Array(await l.slice(0,12).arrayBuffer()),d=String.fromCharCode(u[4],u[5],u[6],u[7])===`ftyp`,f=URL.createObjectURL(l),p=await new Promise(e=>{let t=document.createElement(`video`);t.preload=`metadata`,t.muted=!0,t.onloadedmetadata=()=>e({w:t.videoWidth,h:t.videoHeight,dur:Math.round(t.duration*100)/100}),t.onerror=()=>e({error:`decode error`}),t.src=f,setTimeout(()=>e({error:`timeout`}),5e3)});return URL.revokeObjectURL(f),{ok:!0,size:l.size,type:l.type,ftyp:d,codec:e.videoCodec,probe:p}}function nz(e,t){let n=document.createElement(`canvas`);n.width=800,n.height=450;let r=n.getContext(`2d`);r.fillStyle=t,r.fillRect(0,0,800,450),r.strokeStyle=`rgba(255,255,255,0.35)`;for(let e=0;e<=800;e+=80)r.beginPath(),r.moveTo(e,0),r.lineTo(e,450),r.stroke();for(let e=0;e<=450;e+=90)r.beginPath(),r.moveTo(0,e),r.lineTo(800,e),r.stroke();return r.fillStyle=`#fff`,r.font=`bold 160px sans-serif`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(e,400,225),n.toDataURL(`image/png`)}async function rz(){let e={width:640,height:360,fps:24,duration:4,bitrate:3e6,layers:[{id:`a`,kind:`image`,url:nz(`A`,`#1a3a5a`),start:0,duration:2,motion:{type:`zoom`,zoomDirection:`in`,zoomAmount:1.4,zoomAnchor:`center`,intensity:100,range:[0,100],easing:`ease-in-out`},color:{saturation:40},transform:{opacity:1}},{id:`b`,kind:`image`,url:nz(`B`,`#5a1a3a`),start:2,duration:2,motion:{type:`pan`,panDirection:`left-right`,panAmount:20,intensity:100,range:[0,100],easing:`linear`},lut:`Teal and Orange`,transform:{opacity:1}}]},t=44100,n=new OfflineAudioContext(2,t*4,t),r=n.createOscillator();r.frequency.value=330;let i=n.createGain();i.gain.value=.15,r.connect(i).connect(n.destination),r.start(0),r.stop(4),e.audioBuffer=await n.startRendering();let a=performance.now(),o=await $R(e),s=Math.round(performance.now()-a),c=new Map;for(let t of e.layers)c.set(t.id,await OR(t));let l=document.getElementById(`__rt`);l||(l=document.createElement(`canvas`),l.id=`__rt`,l.style.cssText=`position:fixed;top:8px;left:8px;z-index:99999;border:2px solid #0f0;background:#000`,document.body.appendChild(l)),l.width=640,l.height=360,await Wg(l.getContext(`2d`),e,1,c,640,360);let u=new Uint8Array(await o.slice(0,12).arrayBuffer()),d=String.fromCharCode(u[4],u[5],u[6],u[7])===`ftyp`,f=URL.createObjectURL(o),p=await new Promise(e=>{let t=document.createElement(`video`);t.preload=`metadata`,t.muted=!0,t.onloadedmetadata=()=>e({w:t.videoWidth,h:t.videoHeight,dur:Math.round(t.duration*100)/100}),t.onerror=()=>e({error:`decode`}),t.src=f,setTimeout(()=>e({error:`timeout`}),6e3)});return URL.revokeObjectURL(f),{ok:!0,size:o.size,ftyp:d,probe:p,ms:s}}async function iz(){let e=await $R({width:480,height:270,fps:24,duration:3,bitrate:2e6,layers:[{id:`s`,kind:`image`,url:nz(`V`,`#243a2a`),start:0,duration:3,motion:{type:`pan`,panDirection:`left-right`,panAmount:30,intensity:100,range:[0,100],easing:`linear`},transform:{opacity:1}}]}),t=URL.createObjectURL(e),n=performance.now(),r=await $R({width:480,height:270,fps:24,duration:2,bitrate:2e6,layers:[{id:`v`,kind:`video`,url:t,start:0,duration:2,trimStart:.5,speed:1,motion:{type:`zoom`,zoomDirection:`in`,zoomAmount:1.3,zoomAnchor:`center`,intensity:100,range:[0,100],easing:`ease-in-out`},transform:{opacity:1}}]}),i=Math.round(performance.now()-n);URL.revokeObjectURL(t);let a=new Uint8Array(await r.slice(0,12).arrayBuffer()),o=String.fromCharCode(a[4],a[5],a[6],a[7])===`ftyp`,s=URL.createObjectURL(r),c=await new Promise(e=>{let t=document.createElement(`video`);t.preload=`metadata`,t.muted=!0,t.onloadedmetadata=()=>e({w:t.videoWidth,h:t.videoHeight,dur:Math.round(t.duration*100)/100}),t.onerror=()=>e({error:`decode`}),t.src=s,setTimeout(()=>e({error:`timeout`}),8e3)});return URL.revokeObjectURL(s),{ok:!0,srcSize:e.size,size:r.size,ftyp:o,probe:c,ms:i}}async function az(){let e=await IR({targetDuration:4,trackOrder:[`video`,`overlay`],audio:[],clips:[{id:`c1`,kind:`image`,trackId:`video`,url:nz(`1`,`#203a4a`),start:0,duration:2,motion:{type:`ken-burns`,intensity:100,range:[0,100],easing:`ease-in-out`},transform:{opacity:1}},{id:`c2`,kind:`image`,trackId:`video`,url:nz(`2`,`#4a2030`),start:2,duration:2,motion:{type:`zoom`,zoomDirection:`out`,zoomAmount:1.5,intensity:100,range:[0,100]},lut:`Filmic`,transform:{opacity:1}}]}),t=performance.now(),n=await $R(e),r=Math.round(performance.now()-t),i=new Uint8Array(await n.slice(0,12).arrayBuffer()),a=String.fromCharCode(i[4],i[5],i[6],i[7])===`ftyp`,o=URL.createObjectURL(n),s=await new Promise(e=>{let t=document.createElement(`video`);t.preload=`metadata`,t.muted=!0,t.onloadedmetadata=()=>e({w:t.videoWidth,h:t.videoHeight,dur:Math.round(t.duration*100)/100}),t.onerror=()=>e({error:`decode`}),t.src=o,setTimeout(()=>e({error:`timeout`}),8e3)});return URL.revokeObjectURL(o),{ok:!0,layers:e.layers.length,dims:[e.width,e.height],size:n.size,ftyp:a,probe:s,ms:r}}async function oz(){let e=await IR({targetDuration:4,trackOrder:[`video`],audio:[],clips:[{id:`a`,kind:`image`,trackId:`video`,url:nz(`A`,`#1a3a5a`),start:0,duration:2,transition:{type:`Wipe left`,duration:1},transform:{opacity:1}},{id:`b`,kind:`image`,trackId:`video`,url:nz(`B`,`#5a1a3a`),start:2,duration:2,transform:{opacity:1}}]}),t=await $R(e),n=new Map;for(let t of e.layers)n.set(t.id,await OR(t));let r=document.getElementById(`__rt`);r||(r=document.createElement(`canvas`),r.id=`__rt`,r.style.cssText=`position:fixed;top:8px;left:8px;z-index:99999;border:2px solid #0ff;background:#000`,document.body.appendChild(r)),r.width=640,r.height=360,await Wg(r.getContext(`2d`),e,2,n,640,360);let i=new Uint8Array(await t.slice(0,12).arrayBuffer()),a=String.fromCharCode(i[4],i[5],i[6],i[7])===`ftyp`;return{ok:!0,transitions:e.transitions.length,transition:e.transitions[0],size:t.size,ftyp:a}}async function sz(){let e=await IR({targetDuration:3,trackOrder:[`video`],audio:[],previewH:360,clips:[{id:`bg`,kind:`image`,trackId:`video`,url:nz(`BG`,`#22303a`),start:0,duration:3,transform:{opacity:1}}],overlays:[{text:`Title Card`,subtitle:``,font:`Georgia`,size:60,color:`#ffffff`,background:`#16140F`,backgroundOpacity:90,backgroundPadding:10,backgroundRadius:5,position:`center`,start:0,end:3},{text:`A caption at the bottom`,font:`Hanken Grotesk`,size:28,color:`#ffffff`,background:`#000000`,backgroundOpacity:45,backgroundPadding:10,backgroundRadius:6,position:`bottom center`,start:0,end:3}],stickers:[{shape:`circle`,color:`#e0b84c`,x:22,y:30,scale:1,opacity:.9,rotation:0,start:0,end:3},{shape:`frame`,color:`#ffffff`,x:78,y:32,scale:1,opacity:.9,rotation:0,start:0,end:3}]}),t=await $R(e),n=new Map;for(let t of e.layers)n.set(t.id,await OR(t));let r=document.getElementById(`__rt`);r||(r=document.createElement(`canvas`),r.id=`__rt`,r.style.cssText=`position:fixed;top:8px;left:8px;z-index:99999;border:2px solid #ff0;background:#000`,document.body.appendChild(r)),r.width=640,r.height=360,await Wg(r.getContext(`2d`),e,1,n,640,360);let i=new Uint8Array(await t.slice(0,12).arrayBuffer()),a=String.fromCharCode(i[4],i[5],i[6],i[7])===`ftyp`;return{ok:!0,overlays:e.overlays.length,stickers:e.stickers.length,size:t.size,ftyp:a}}var cz,lz=o((()=>{Hi(),Is(),zs(),Nd(),Jg(),AR(),zR(),vp(),HR(),Dm(),Ei(),cz=e=>{if(e?.aborted)throw Object.assign(Error(`Export aborted`),{name:`AbortError`})}})),uz=c({__overlayTest:()=>sz,__planTest:()=>az,__renderTest:()=>rz,__smokeTestExport:()=>tz,__transitionTest:()=>oz,__videoTest:()=>iz,exportEditorAudioMp3:()=>ZR,exportEditorTimeline:()=>JR,getExportCapabilities:()=>qR,renderRecordingCut:()=>XR,renderTimeline:()=>$R,renderWorkingCopy:()=>YR}),dz,fz,pz=o((()=>{Ni(),ki(),Un(),lz(),dz=e=>()=>{throw Error(e+` is unavailable in the local preview.`)},fz={version:1};for(let e of Oi)fz[e]=[`toast`,`presenterHost`,`upgradeReasons`].includes(e)?{}:dz(e);Object.assign(fz,{loadMediaBlob:async e=>{let t=typeof e==`string`?e:e?.url,n=t?await fetch(t).catch(()=>null):null;return n?.ok?n.blob():{missing:!0,ref:e}},loadMediaArrayBuffer:async e=>{let t=typeof e==`string`?e:e?.url,n=t?await fetch(t).catch(()=>null):null;return n?.ok?n.arrayBuffer():{missing:!0,ref:e}},resolveDesktopMediaUrl:async e=>typeof e==`string`&&e.startsWith(`sm-media://asset/`)?e:null,isMissing:e=>!!(e&&e.missing),proxiedMediaUrl:e=>e,cachedObjectUrlIfPresent:()=>null,desktopBridge:()=>null,isDeviceMediaUrl:Dn,resolveDeviceMediaUrl:vn,deviceMediaUrlFor:e=>/^[0-9a-f-]{36}$/i.test(e?.assetId||``)&&/^[0-9a-f]{64}$/.test(e?.versionId||``)?Tn(e):null,loadDeviceMediaBlob:async e=>{let t=En(e);if(!t)return null;try{return await gn(t)}catch{return null}}}),Ai(fz)})),mz=c({cutRecording:()=>_z,cutWithMediaRecorder:()=>gz,rendererAvailable:()=>hz});async function hz({capabilities:e}={}){try{if(typeof VideoEncoder>`u`||typeof OffscreenCanvas>`u`)return!1;let t=await(e||(await Ti(async()=>{let{getExportCapabilities:e}=await Promise.resolve().then(()=>(pz(),uz));return{getExportCapabilities:e}},void 0)).getExportCapabilities)();return t?.strategy===`webcodecs`||t?.strategy===`native`}catch{return!1}}async function gz(e,{keep:t,width:n,height:r,shortSide:i=1080,fps:a=30,signal:o,onProgress:s,documentRef:c=globalThis.document}={}){if(typeof MediaRecorder!=`function`||!c)throw Error(`This browser cannot cut recordings.`);let l=(t||[]).filter(e=>e.end>e.start);if(!l.length)throw Error(`Keep at least part of the recording.`);let u=l.reduce((e,t)=>e+t.end-t.start,0),d=vz(n||1920,r||1080,i),f=URL.createObjectURL(e),p=c.createElement(`video`),m=c.createElement(`canvas`);m.width=d.width,m.height=d.height;for(let e of[p,m])e.setAttribute(`aria-hidden`,`true`),e.style.position=`fixed`,e.style.left=`-20000px`,e.style.top=`0`,e.style.width=`1px`,e.style.height=`1px`;p.preload=`auto`,p.playsInline=!0,p.muted=!1,p.volume=1,p.src=f,c.body.append(p,m);let h=m.getContext(`2d`,{alpha:!1}),g=null,_=null,v=null,y=null,b=()=>{clearInterval(y);try{_?.getTracks().forEach(e=>e.stop())}catch{}try{g?.close()}catch{}p.pause(),p.removeAttribute(`src`);try{p.load()}catch{}p.remove(),m.remove(),URL.revokeObjectURL(f)},x=()=>{if(o?.aborted)throw Object.assign(Error(`The cut was cancelled.`),{name:`AbortError`})};try{await new Promise((e,t)=>{let n=setTimeout(()=>t(Error(`The recording did not load in time.`)),3e4);p.onloadedmetadata=()=>{clearTimeout(n),e()},p.onerror=()=>{clearTimeout(n),t(Error(`This recording could not be read.`))}}),x(),_=m.captureStream(a);let e=globalThis.AudioContext||globalThis.webkitAudioContext;if(typeof e==`function`&&typeof MediaStream==`function`)try{g=new e;let t=g.createMediaStreamDestination();g.createMediaElementSource(p).connect(t),_=new MediaStream([..._.getVideoTracks(),...t.stream.getAudioTracks()])}catch{g?.close?.(),g=null}let t=Ir(`screen`,{isTypeSupported:e=>MediaRecorder.isTypeSupported?.(e),canPlayType:e=>c.createElement(`video`).canPlayType(e)});v=new MediaRecorder(_,{...t?{mimeType:t}:{},videoBitsPerSecond:Lr({width:d.width,height:d.height,frameRate:a}),audioBitsPerSecond:Hr.voice});let n=[];v.addEventListener(`dataavailable`,e=>{e.data?.size&&n.push(e.data)});let r=new Promise(e=>v.addEventListener(`stop`,e,{once:!0})),i=new Promise((e,t)=>v.addEventListener(`error`,()=>t(Error(`Recording the cut failed.`)),{once:!0})),f=()=>{try{h.drawImage(p,0,0,d.width,d.height)}catch{}},b=e=>new Promise((t,n)=>{let r=setTimeout(()=>n(Error(`The recording could not be positioned.`)),15e3);p.onseeked=()=>{clearTimeout(r),t()},p.currentTime=e});await b(l[0].start),f(),v.start(1e3),v.pause();let S=0;y=setInterval(f,Math.round(1e3/a));for(let e of l)x(),Math.abs(p.currentTime-e.start)>.05&&await b(e.start),f(),await g?.resume?.(),v.resume(),await p.play(),await new Promise((t,n)=>{let r=()=>{if(o?.aborted){n(Object.assign(Error(`The cut was cancelled.`),{name:`AbortError`}));return}let i=p.currentTime;if(s?.(Math.min(1,(S+Math.max(0,i-e.start))/u)),i>=e.end-1/a||p.ended){t();return}setTimeout(r,40)};Promise.race([i]).catch(n),r()}),p.pause(),v.pause(),S+=e.end-e.start;v.stop(),await Promise.race([r,i]);let C=v.mimeType||t||`video/webm`,w=await kr(new Blob(n,{type:C}),u*1e3);if(!w.size)throw Error(`Nothing was recorded from the cut.`);return s?.(1),{file:w,duration:u,width:d.width,height:d.height}}finally{b()}}async function _z(e,{keep:t,width:n,height:r,duration:i,shortSide:a=1080,fps:o=30,signal:s,onProgress:c,renderer:l,playback:u=gz,available:d=hz}={}){return await d()?{...await(l||(await Ti(async()=>{let{renderRecordingCut:e}=await Promise.resolve().then(()=>(pz(),uz));return{renderRecordingCut:e}},void 0)).renderRecordingCut)(e,{keep:t,width:n,height:r,duration:i,fps:o,shortSide:a,signal:s,onProgress:c}),method:`renderer`}:{...await u(e,{keep:t,width:n,height:r,shortSide:a,fps:o,signal:s,onProgress:c}),method:`playback`}}var vz,yz=o((()=>{Ei(),vz=(e,t,n)=>{let r=Math.min(1,n/Math.max(1,Math.min(e,t)));return{width:Math.max(2,Math.round(e*r/2)*2),height:Math.max(2,Math.round(t*r/2)*2)}}})),bz=c({canvasMediaFile:()=>xz,uploadCanvasMediaFile:()=>Sz});function xz(){return{kind:null}}async function Sz(){throw Error(`Read media from a folder in StillMade; the local preview reads text only.`)}var Cz=o((()=>{}));Et(),Ge(),Xt(),Un(),Fr(),Kr(),Ei();var wz={screen:`screen.capture`,camera:`camera.capture`,microphone:`microphone.capture`},Tz=500,Ez=async(e,t)=>(await Ti(async()=>{let{cutRecording:e}=await Promise.resolve().then(()=>(yz(),mz));return{cutRecording:e}},void 0)).cutRecording(e,t),Dz=async()=>{if(typeof MediaRecorder!=`function`)return`none`;try{return await(await Ti(async()=>{let{rendererAvailable:e}=await Promise.resolve().then(()=>(yz(),mz));return{rendererAvailable:e}},void 0)).rendererAvailable()?`renderer`:`playback`}catch{return`playback`}};async function Oz(e){if(typeof document>`u`)return{};let t=URL.createObjectURL(e),n=document.createElement(`video`);n.preload=`metadata`,n.muted=!0;try{return await new Promise((e,r)=>{let i=setTimeout(()=>r(Error(`The video did not load in time.`)),3e4);n.onloadedmetadata=()=>{clearTimeout(i),e({duration:Number.isFinite(n.duration)?n.duration:0,width:n.videoWidth,height:n.videoHeight})},n.onerror=()=>{clearTimeout(i),r(Error(`This video cannot be read here.`))},n.src=t})}finally{n.removeAttribute(`src`);try{n.load()}catch{}URL.revokeObjectURL(t)}}var kz=/^\/api\/media\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-][A-Za-z0-9._-]*$/;async function Az(e,{signal:t}={}){let n=typeof location<`u`?location.origin:``,r=e.startsWith(`sm-media://asset/`),i=kz.test(e),a=n&&e.startsWith(`blob:${n}/`);if(!r&&!i&&!a)throw Error(`Cut a recording kept on this device or saved in StillMade.`);let o=await fetch(e,{signal:t,credentials:`omit`,redirect:i?`follow`:`error`,referrerPolicy:`no-referrer`}).catch(()=>null);if(!o?.ok)throw Error(`This video cannot be read here.`);let s=(o.headers.get(`content-type`)||``).split(`;`)[0].trim().toLowerCase();if(!Gn.video.includes(s))throw Error(`Choose a supported video file.`);if(Number(o.headers.get(`content-length`))>2147483648)throw Error(`Videos over 2 GB cannot be cut here.`);if(!o.body?.getReader)return o.blob();let c=o.body.getReader(),l=[],u=0;try{for(;;){let{done:e,value:t}=await c.read();if(e)break;if(u+=t.byteLength,u>2147483648)throw Error(`Videos over 2 GB cannot be cut here.`);l.push(t)}}finally{await c.cancel().catch(()=>{}),c.releaseLock()}return new Blob(l,{type:s})}function jz(e,t){if(!Array.isArray(e)||!e.length||e.length>Tz)throw Error(`Keep 1 to ${Tz} ranges of the recording.`);let n=-1,r=[];for(let i of e){let e=Number(i?.start),a=Number(i?.end);if(!Number.isFinite(e)||!Number.isFinite(a)||e<0||e<n||a<=e)throw Error(`Keep ranges are ordered, non-overlapping {start, end} seconds.`);r.push({start:e,end:t>0?Math.min(a,t):a}),n=a}return r.filter(e=>e.end-e.start>.001)}var Mz={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!1},Nz=1048576,Pz=e=>{try{for(let t of e?.getTracks?.()||[])t.stop()}catch{}},Fz=(e,t)=>{try{return e?.[t===`video`?`getVideoTracks`:`getAudioTracks`]?.()||[]}catch{return[]}},Iz=e=>{try{return e?.getSettings?.()||{}}catch{return{}}},Lz=e=>[`NotAllowedError`,`AbortError`].includes(e?.name);function Rz(e,{bridge:t=globalThis.stillmadeDesktop?.blockDesktop,onStatus:n=()=>{},onLive:r=()=>{},onActivity:i=()=>{},storageScope:a=`preview`,limits:o,now:s=Date.now,renderCut:c=Ez,probeVideo:l=Oz,probeCut:u=Dz}={}){let d=null,f=null,p=!1,m=null,h=null,g=!1,_=null,v=null,y=new Set,b=e=>e&&[`audio`,`video`,`image`].includes(e.kind)&&[`assetId`,`versionId`,`url`].every(t=>typeof e[t]==`string`&&e[t])?JSON.stringify([e.kind,e.assetId,e.versionId,e.url]):``,x=e?.manifest?.permissions?.desktop||[],S=new Map((e?.manifest?.desktopTools||[]).map(e=>[e.id,new Set(e.actions||[])])),C={"tool.launch":`launch`,"tool.project.import":`project.import`,"tool.project.open":`project.open`,"tool.project.render":`project.render`,"tool.adapter.import":`adapter.import`,"tool.adapter.inspect":`adapter.inspect`,"tool.adapter.execute":`adapter.execute`,"tool.adapter.describe":`adapter.describe`,"tool.adapter.call":`adapter.call`},w=t?`desktop`:`browser`,T=!!t&&[`recordingOpen`,`recordingAppend`,`recordingClose`].every(e=>typeof t[e]==`function`),E={...w===`browser`?Wr.browser:T?Wr.desktop:Wr.legacyDesktop,...o},D=()=>({seconds:E.seconds,bytes:Number.isFinite(E.bytes)?E.bytes:null}),O=async(e,n,r)=>{if(!T)return t.save(d,e,new Uint8Array(await n.arrayBuffer()),r);let{id:i,maxAppendBytes:a}=await t.recordingOpen(d,{kind:e,mime:r}),o=Math.min(a||8*Nz,8*Nz);try{for(let e=0;e<n.size;e+=o)await t.recordingAppend(d,i,new Uint8Array(await n.slice(e,e+o).arrayBuffer()))}catch(e){throw await t.recordingClose(d,i,{discard:!0}).catch(()=>{}),e}return t.recordingClose(d,i,{})},k=e=>new Promise((t,r)=>{_={reject:r},n({awaitingStart:!0,...e,start:()=>{_=null,n({active:!1}),t()},cancel:()=>{_=null,n({active:!1}),r(Error(e.kind===`folder`?`No folder was chosen.`:`Folder access was not allowed.`))}})}),A=null,j=()=>A||=(async()=>yi({key:await bi(e,a),digest:await gt(e),name:e.manifest.name,permissions:x,askToStart:k,importMedia:async(e,t)=>{let{uploadCanvasMediaFile:n,canvasMediaFile:r}=await Ti(async()=>{let{uploadCanvasMediaFile:e,canvasMediaFile:t}=await Promise.resolve().then(()=>(Cz(),bz));return{uploadCanvasMediaFile:e,canvasMediaFile:t}},void 0),i=null;try{i=r({name:e.name,type:e.type,size:1}).kind}catch{}if(![`image`,`video`,`audio`].includes(i))throw Error(`Read ${e.name} as text; only images, video and audio are read as media.`);let a=await n(e,{localFirst:!0,handle:t});return{kind:a.kind,assetId:a.assetId,versionId:a.versionId,url:a.url,source:`local`,...a.mimeType?{mimeType:a.mimeType}:{},...a.bytes?{bytes:a.bytes}:{},name:e.name}},mediaBlob:async e=>{if(!Dn(e?.url))throw Error(`Not on this device`);return gn(e)}}))(),M=()=>{if(!t)throw Error(`This capability requires the StillMade desktop app.`)},N=e=>{if(p)throw Error(`Block desktop access was closed. Reopen the Block.`);if(!x.includes(e))throw Error(`Declare permissions.desktop: ${e}`)},P=async()=>(f||=(async()=>{M();let n=e.manifest,r=await t.open({id:n.id,version:n.version,digest:await gt(e),permissions:x,tools:n.desktopTools||[],name:n.name,storageScope:`${Jt()||`anonymous`}:${a}`,remember:{key:await bi(e,a)}});if(p)throw await t.close(r),Error(`Block was closed`);return d=r,r})(),f),F=async(e,n={})=>{M(),N(e);let r=await P();if(p)throw Error(`Block was closed`);return t.invoke(r,e,n)},I=(e,t,r)=>{if(!(m!==e||e.ended)){e.ended={stoppedBy:t,message:r},e.endedAt=s(),clearTimeout(e.timer),clearInterval(e.cursorTimer);try{e.recorder.state!==`inactive`&&e.recorder.stop()}catch{}n({active:!0,ended:!0,kind:e.kind,stoppedBy:t,message:r})}},ee=e=>{clearTimeout(e.timer),clearInterval(e.cursorTimer),Pz(e.stream),Pz(e.microphone);try{e.audioContext?.close?.()}catch{}},te=(e,n)=>{e.appending=e.appending.then(async()=>{e.discarded||await t.recordingAppend(d,e.sink.id,new Uint8Array(await n.arrayBuffer()))}).catch(t=>{!e.ended&&!e.discarded&&I(e,`disk`,t?.message||`The recording could not be written to disk.`)})},L=async e=>{let r=m;if(!r)throw Error(`No recording is active`);return r.finishing||=(async()=>{if(r.recorder.state!==`inactive`&&r.recorder.stop(),await r.stopped,ee(r),m=null,n({active:!1}),r.sink&&await r.appending,!e)return r.sink&&(r.discarded=!0,await t.recordingClose(d,r.sink.id,{discard:!0}).catch(()=>{})),{cancelled:!0};if(r.error)throw r.sink&&(r.discarded=!0,await t.recordingClose(d,r.sink.id,{discard:!0}).catch(()=>{})),Error(r.error);if(!r.chunks.length)throw Error(`Nothing was recorded.`);let i=r.recorder.mimeType||r.mimeType||``,a=Math.max(1,(r.endedAt||s())-r.started),o=r.kind===`microphone`?`audio`:`video`,c=i.split(`;`)[0].trim(),l={duration:a/1e3,mimeType:c,...o===`video`&&r.width?{width:r.width,height:r.height}:{}},u;if(r.sink){let e=await kr(new Blob([r.chunks[0]],i?{type:i}:void 0),a);u=await t.recordingClose(d,r.sink.id,{head:new Uint8Array(await e.arrayBuffer())})}else{let e=await kr(new Blob(r.chunks,i?{type:i}:void 0),a);if(t)u=await t.save(d,r.kind,new Uint8Array(await e.arrayBuffer()),c);else{let t=Gr(r.kind,c,r.started);u=yn(await pn(new File([e],t,i?{type:c}:void 0),{kind:o,metadata:l,maxBytes:E.bytes}),{name:t})}}let f=b(u);return f&&y.add(f),{asset:u,...l,bytes:r.bytes,...r.ended?{stoppedBy:r.ended.stoppedBy,message:r.ended.message}:{},cursor:r.cursor,displays:r.displays||[],coordinates:`Global screen coordinates in device-independent pixels; timestamps in milliseconds relative to recording start.`}})(),r.finishing},R=()=>{let e=m;return e?{active:!0,platform:w,kind:e.kind,elapsed:(e.endedAt||s())-e.started,bytes:e.bytes,ended:!!e.ended,...e.ended||{},limits:D()}:{active:!1,platform:w,...v?{cutting:{progress:v.progress}}:{},limits:D()}},ne=async()=>{N(Object.values(wz).find(e=>x.includes(e))||`screen.capture`);let e=typeof MediaRecorder==`function`&&!!navigator?.mediaDevices?.getDisplayMedia,n=null,r=0;if(!t)try{let e=await bn();n=Number.isFinite(e?.quota)?e.quota:null,r=Number(e?.bytes)||0}catch{}let i=Lr({width:1920,height:1080,frameRate:30})+Hr.voice,a=w===`browser`?zr({platform:`browser`,bitsPerSecond:i,quota:n,used:r}):{seconds:E.seconds,bytes:Number.isFinite(E.bytes)?E.bytes:null};return w===`browser`&&Number.isFinite(E.bytes)&&(a.bytes=Math.min(a.bytes,E.bytes)),{platform:w,streams:T,recorder:!!e&&(t?!0:fn()),cut:e?await u():`none`,budget:{seconds:Math.min(a.seconds,E.seconds),bytes:a.bytes==null?null:Math.floor(a.bytes/Nz)*Nz,bitsPerSecond:i},limits:D()}},re=async(e,t)=>{let n=navigator.mediaDevices;if(e===`screen`){let e=Rr({resolution:t.resolution,frameRate:t.frameRate}),r=t=>n.getDisplayMedia({video:e,audio:t}),i=t.systemAudio===!0;try{return await r(i)}catch(e){if(!i||Lz(e))throw e;return r(!1)}}return e===`camera`?n.getUserMedia({video:Rr({resolution:t.resolution,frameRate:t.frameRate}),audio:!1}):n.getUserMedia({video:!1,audio:Mz})},ie=(e,t)=>{if(!t)return{recorded:e};let n=Fz(t,`audio`),r=Fz(e,`audio`);if(!n.length)return{recorded:e};let i=globalThis.AudioContext||globalThis.webkitAudioContext;if(r.length&&typeof i==`function`&&typeof MediaStream==`function`){let n=new i,r=n.createMediaStreamDestination();for(let i of[e,t])n.createMediaStreamSource(i).connect(r);return{recorded:new MediaStream([...Fz(e,`video`),...Fz(r.stream,`audio`)]),audioContext:n}}return typeof MediaStream==`function`?{recorded:new MediaStream([...Fz(e,`video`),...r.length?r:n])}:{recorded:e}},ae=async(e,n=[])=>{if(N([`screen.capture`,`camera.capture`].find(e=>x.includes(e))||`screen.capture`),m)throw Error(`Stop the recording before cutting it.`);let r=e.source;if(!b(r)||r.kind!==`video`)throw Error(`Choose the video to cut.`);if(!y.has(b(r))&&!(Array.isArray(n)?n:[]).some(e=>b(e)===b(r)))throw Error(`Cut a video this Block received or recorded in this session.`);let i=String(r.url),a,o={width:Number(r.width)||0,height:Number(r.height)||0,duration:Number(r.duration)||0};if(Dn(i)){let e=En(i),t=await mn(e);if(!t)throw Error(`This recording is not on this device.`);a=await gn(e),o={width:Number(t.width)||o.width,height:Number(t.height)||o.height,duration:Number(t.duration)||o.duration}}else a=await Az(i);if(p)throw Error(`Block was closed`);o.width>0&&o.height>0&&o.duration>0||(o={...o,...await l(a)});let u=jz(e.keep,o.duration);if(!u.length)throw Error(`Keep at least part of the recording.`);v={progress:0,started:s()};try{let e=await c(a,{keep:u,width:o.width,height:o.height,duration:o.duration,onProgress:e=>{let t=typeof e==`number`?e:e?.total?e.done/e.total:null;Number.isFinite(t)&&v&&(v.progress=Math.max(0,Math.min(1,t)))}});if(p)throw Error(`Block was closed`);let n=e?.file;if(!(n instanceof Blob)||!n.size)throw Error(`The cut could not be rendered here.`);let i=await l(n).catch(()=>({})),s=String(n.type||`video/mp4`).split(`;`)[0].trim(),d={duration:i.duration||e.duration||u.reduce((e,t)=>e+t.end-t.start,0),width:i.width||o.width,height:i.height||o.height,mimeType:s},f=`${String(r.name||`recording`).replace(/\.[a-z0-9]+$/i,``).slice(0,200)||`recording`}-cut.${/webm/.test(s)?`webm`:`mp4`}`,m;m=t?await O(`screen`,n,s):yn(await pn(new File([n],f,{type:s}),{kind:`video`,metadata:d,maxBytes:E.bytes}),{name:f});let h=b(m);return h&&y.add(h),{asset:m,...d,bytes:n.size,keep:u}}finally{v=null}},oe=async e=>{if(h)throw Error(`The live feed is already on.`);if(m)throw Error(`Stop the recording before starting the live feed.`);let i=Yr(e),{camera:a,microphone:o}=i;if(a&&N(`camera.capture`),o&&N(`microphone.capture`),!navigator?.mediaDevices?.getUserMedia)throw Error(`This browser cannot open a camera or microphone. Use a current desktop browser or StillMade Desktop.`);if(await new Promise((e,t)=>{_={reject:t},n({awaitingStart:!0,kind:`live`,camera:a,microphone:o,start:()=>{_=null,e()}})}),p)throw Error(`Block was closed`);t&&(a&&await F(`camera.capture`),o&&await F(`microphone.capture`));let s=await navigator.mediaDevices.getUserMedia({video:a?{width:{ideal:i.width},frameRate:{ideal:i.fps}}:!1,audio:o?Mz:!1});if(p)throw Pz(s),Error(`Block was closed`);let c=Qr(s,{...i,onFrame:(e,t)=>{h===c?r({type:`frame`,bitmap:e,...t},[e]):e.close?.()},onAudio:(e,t)=>{h===c&&r({type:`audio`,samples:e,...t},[e.buffer])},onEnded:e=>{h===c&&(h=null,n({active:!1}),r({type:`ended`,reason:e},[]))}});h=c;let l=await c.ready;if(h!==c)throw Error(`The live feed ended before it started.`);return n({active:!0,kind:`live`,camera:a,microphone:o,stop:()=>c.stop(`person`)}),{live:!0,...l}},se=()=>h?{live:!0,...h.info}:{live:!1},ce=[],le=new Map,ue=()=>i({entries:[...ce],folders:[...le.values()]}),de=e=>{ce[0]?.text===e?ce[0]={...ce[0],at:s(),count:(ce[0].count||1)+1}:ce.unshift({at:s(),text:e}),ce.length=Math.min(ce.length,50),ue()},fe=(e,t,n)=>{if(e===`folder.shared`||e===`folder.pick`)for(let e of n?.folders||(n?.folder?[n.folder]:[]))le.set(e.id,e);if(e===`folder.forget`){let e=le.get(t.folder);return le.delete(t.folder),e&&`Stopped using ${e.name}`}let r=le.get(t?.folder)?.name||`the shared folder`,i=typeof t?.path==`string`&&t.path?t.path:``;return e===`folder.pick`?`Shared ${n.folder.name} for ${n.folder.write?`reading and changing`:`reading`}`:e===`folder.read`?`Read ${i} in ${r}`:e===`folder.write`?`${n?.replaced?`Replaced`:`Wrote`} ${i} in ${r}`:e===`folder.list`?`Looked in ${i?`${i} in `:``}${r}`:e===`clipboard.read`?`Read the text you copied`:e===`clipboard.write`?`Replaced the text you copied`:e===`media.pick`?`Opened ${n?.assets?.length||0} files you chose`:e.startsWith(`tool.`)&&e!==`tool.status`?`Ran ${t?.tool||`a desktop program`} (${e.slice(5)})`:null},pe=async(e,t={},n={})=>{let r=await me(e,t,n);try{let n=fe(e,t,r);n?de(n):e===`folder.shared`&&ue()}catch{}return r},me=async(e,r={},{received:i}={})=>{if(e===`record.stop`)return L(!0);if(e===`record.cancel`)return L(!1);if(e===`record.status`)return R();if(e===`device.info`)return ne();if(e===`session.close`)return await he(),{closed:!0};if(e===`live.status`)return se();if(e===`live.stop`)return h?.stop(`stopped`),{live:!1};if(g)throw Error(`A desktop request is already in progress`);g=!0;try{if(e===`record.cut`)return await ae(r,i);if(e===`live.start`)return await oe(r);if(e!==`record.start`){if(e.startsWith(`tool.`)){M(),N(`native.tools`);let n=S.get(r.tool),i=C[e];if(!n||e!==`tool.status`&&!n.has(i))throw Error(`Declare the exact desktop tool action`);let a=await t.invoke(await P(),e,r);if(p)throw Error(`Block desktop access closed before the native operation completed.`);let o=b(a?.asset);return o&&y.add(o),a}if(e.startsWith(`storage.`)){if(![`storage.info`,`storage.list`,`storage.read`,`storage.write`,`storage.remove`].includes(e))throw Error(`Unknown storage operation`);if(!t)throw Error(`Device storage requires the StillMade desktop app.`);if(p)throw Error(`Block desktop access was closed. Reopen the Block.`);return t.invoke(await P(),e,r)}if(e.startsWith(`folder.`)){if(!ei.includes(e))throw Error(`Unknown folder operation`);if(N(`folder.read`),(e===`folder.write`||e===`folder.pick`&&r.write===!0)&&N(`folder.write`),e===`folder.write`&&r.asset!==void 0&&!(y.has(b(r.asset))||(Array.isArray(i)?i:[]).some(e=>b(e)===b(r.asset))))throw Error(`Write a file this Block saved or received in this session.`);if(!t&&!pi())throw Error(`Folders need Chrome, Edge or StillMade Desktop.`);let n=t?await t.invoke(await P(),e,r):await(await j()).invoke(e,r);if(p)throw Error(`Block desktop access closed before the folder operation completed.`);let a=b(n?.asset);return a&&y.add(a),n}if(!We.includes(e))throw Error(`Unknown desktop operation`);if(Object.values(wz).includes(e))throw Error(`Use record.start with kind screen, camera, or microphone.`);let n=await F(e,r);if(e===`media.pick`)for(let e of n?.assets||[]){let t=b(e);t&&y.add(t)}return n}if(m)throw Error(`A recording is already active`);if(h)throw Error(`Stop the live feed before recording.`);let a=r.kind||`screen`,o=wz[a];if(!o)throw Error(`Choose screen, camera, or microphone`);N(o);let c=a===`screen`&&r.microphone===!0;if(c&&N(`microphone.capture`),r.cursor&&(N(`cursor.track`),M(),await F(`cursor.track`)),!t){if(!navigator?.mediaDevices?.[a===`screen`?`getDisplayMedia`:`getUserMedia`]||typeof MediaRecorder!=`function`)throw Error(`This browser cannot record. Use a current desktop browser or StillMade Desktop.`);if(!fn())throw Error(`This browser cannot keep recordings on the device. Use StillMade Desktop.`)}if(await new Promise((e,t)=>{_={reject:t},n({awaitingStart:!0,kind:a,microphone:c,start:()=>{_=null,e()}})}),p)throw Error(`Block was closed`);t&&(await F(o,a===`screen`?{systemAudio:r.systemAudio===!0}:{}),c&&await F(`microphone.capture`));let l=await re(a,r);if(p)throw Pz(l),Error(`Block was closed`);let u=null;if(c){try{u=await navigator.mediaDevices.getUserMedia({video:!1,audio:Mz})}catch(e){throw Pz(l),Error(`The microphone is unavailable: ${e?.message||e}`)}if(p)throw Pz(l),Pz(u),Error(`Block was closed`)}let f=Iz(Fz(l,`video`)[0]),g=Number(f.width)||0,v=Number(f.height)||0,x=Ir(a,{isTypeSupported:e=>MediaRecorder.isTypeSupported?.(e),canPlayType:e=>typeof document<`u`?document.createElement(`video`).canPlayType(e):`maybe`}),w={...x?{mimeType:x}:{},...a===`microphone`?{}:{videoBitsPerSecond:Lr({width:g,height:v,frameRate:f.frameRate})},audioBitsPerSecond:r.systemAudio===!0?Hr.system:Hr.voice},O,k,A;try{({recorded:O,audioContext:k}=ie(l,u)),A=new MediaRecorder(O,w)}catch(e){Pz(l),Pz(u);try{k?.close?.()}catch{}throw e}let R={kind:a,stream:l,microphone:u,audioContext:k,recorder:A,mimeType:x,width:g,height:v,chunks:[],bytes:0,cursor:[],started:s(),error:null,ended:null,endedAt:null,sink:null,appending:Promise.resolve(),discarded:!1};if(m=R,T){try{R.sink=await t.recordingOpen(d,{kind:a,mime:(A.mimeType||x||``).split(`;`)[0].trim()})}catch(e){throw ee(R),m=null,e}if(p)throw ee(R),m=null,await t.recordingClose(d,R.sink.id,{discard:!0}).catch(()=>{}),Error(`Block was closed`)}R.stopped=new Promise(e=>A.addEventListener(`stop`,e,{once:!0})),A.addEventListener(`dataavailable`,e=>{let n=e.data?.size||0;if(n&&m===R){if(R.bytes+n>E.bytes){I(R,`size`,`This recording reached the ${Math.round(E.bytes/Nz)} MB that fit here and was saved up to that point.${t?``:` StillMade Desktop records longer.`}`);return}R.bytes+=n,R.sink&&R.chunks.length?te(R,e.data):R.chunks.push(e.data)}}),A.addEventListener(`error`,()=>{R.error=`Recording failed`,L(!1).catch(()=>{})});for(let e of[...Fz(l,`video`),...Fz(l,`audio`)])e.addEventListener(`ended`,()=>{m===R&&!R.ended&&I(R,`sharing`,`Sharing ended. The recording was saved up to that point.`)});try{A.start(1e3)}catch(e){throw ee(R),m=null,e}if(r.cursor){let e=!1;R.cursorTimer=setInterval(async()=>{if(!(e||m!==R||R.ended||R.cursor.length>=18e3)){e=!0;try{let e=await F(`cursor.track`);m===R&&(R.displays=e.displays,R.cursor.push({x:e.x,y:e.y,time:e.time-R.started}))}catch(e){R.error=e.message,L(!1).catch(()=>{})}finally{e=!1}}},100)}return R.ended||(R.timer=setTimeout(()=>I(R,`time`,`This recording reached the ${Math.round(E.seconds/60)} minute limit and was saved up to that point.`),E.seconds*1e3),n({active:!0,kind:a})),{recording:!0,kind:a,cursor:!!r.cursor,microphone:!!u,mimeType:x||null,width:g,height:v,limits:D()}}catch(e){throw!m&&!h&&n({active:!1,error:e.message}),e}finally{g=!1}},he=async()=>{p||(p=!0,ge?.(),_?.reject(Error(`Recording cancelled`)),_=null,h?.stop(`closed`),m&&(Pz(m.stream),Pz(m.microphone)),m&&await L(!1).catch(()=>{}),d&&await t.close(d).catch(()=>{}),n({active:!1,closed:!0}))},ge=t?.onRevoked?.(e=>{d===e&&he().catch(()=>{})});return{call:pe,close:he,authorizesMedia:e=>y.has(b(e)),liveAck:()=>h?.ack(),platform:w}}function zz(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function Bz(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&MB.test(String.fromCharCode(e)):t!==!1&&zz(e,TB)}function Vz(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&NB.test(String.fromCharCode(e)):t===!1?!1:zz(e,TB)||zz(e,wB)}function Hz(e,t){return new PB(e,{beforeExpr:!0,binop:t})}function Uz(e,t){return t===void 0&&(t={}),t.keyword=e,LB[e]=new PB(e,t)}function Wz(e){return e===10||e===13||e===8232||e===8233}function Gz(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(Wz(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}function Kz(e){return qB[e]||(qB[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function qz(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function Jz(e,t){for(var n=1,r=0;;){var i=Gz(e,r,t);if(i<0)return new YB(n,t-r);++n,r=i}}function Yz(e){var t={};for(var n in ZB)t[n]=e&&GB(e,n)?e[n]:ZB[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!QB&&typeof console==`object`&&console.warn&&(QB=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
1171
1171
  Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved??=t.ecmaVersion<5,(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),KB(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(KB(t.onComment)&&(t.onComment=Xz(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function Xz(e,t){return function(n,r,i,a,o,s){var c={type:n?`Block`:`Line`,value:r,start:i,end:a};e.locations&&(c.loc=new XB(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}function Zz(e,t){return eV|(e?tV:0)|(t?nV:0)}function Qz(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type===`MethodDefinition`&&(t.kind===`get`||t.kind===`set`)&&(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):r?!0:(e[n]=i,!1)}function $z(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}function eB(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&eB(e.expression)}function tB(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&tB(e.expression)||e.type===`ParenthesizedExpression`&&tB(e.expression)}function nB(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}function rB(e){var t=tH[e]={binary:Kz(KV[e]+` `+JV),binaryOfStrings:Kz(qV[e]),nonBinary:{General_Category:Kz(JV),Script:Kz(eH[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}function iB(e){for(var t in e)return!0;return!1}function aB(e){return e===105||e===109||e===115}function oB(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}function sB(e){return Bz(e,!0)||e===36||e===95}function cB(e){return Vz(e,!0)||e===36||e===95||e===8204||e===8205}function lB(e){return e>=65&&e<=90||e>=97&&e<=122}function uB(e){return e>=0&&e<=1114111}function dB(e){return e===100||e===68||e===115||e===83||e===119||e===87}function fB(e){return lB(e)||e===95}function pB(e){return fB(e)||_B(e)}function mB(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function hB(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}function gB(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}function _B(e){return e>=48&&e<=57}function vB(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function yB(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}function bB(e){return e>=48&&e<=55}function xB(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function SB(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}function CB(e,t){return _V.parse(e,t)}var wB,TB,EB,DB,OB,kB,AB,jB,MB,NB,PB,FB,IB,LB,$,RB,zB,BB,VB,HB,UB,WB,GB,KB,qB,JB,YB,XB,ZB,QB,$B,eV,tV,nV,rV,iV,aV,oV,sV,cV,lV,uV,dV,fV,pV,mV,hV,gV,_V,vV,yV,bV,xV,SV,CV,wV,TV,EV,DV,OV,kV,AV,jV,MV,NV,PV,FV,IV,LV,RV,zV,BV,VV,HV,UV,WV,GV,KV,qV,JV,YV,XV,ZV,QV,$V,eH,tH,nH,rH,iH,aH,oH,sH,cH,lH,uH,dH,fH,pH,mH,hH=o((()=>{for(wB=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],TB=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],EB=`‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-᫝᫠-᫫ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,DB=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-࢏ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚ౜ౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ೜-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ƛ꟱-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,OB={3:`abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile`,5:`class enum extends super const export import`,6:`enum`,strict:`implements interface let package private protected public static yield`,strictBind:`eval arguments`},kB=`break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this`,AB={5:kB,"5module":kB+` export import`,6:kB+` const class extends export import super`},jB=/^in(stanceof)?$/,MB=RegExp(`[`+DB+`]`),NB=RegExp(`[`+DB+EB+`]`),PB=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null},FB={beforeExpr:!0},IB={startsExpr:!0},LB={},$={num:new PB(`num`,IB),regexp:new PB(`regexp`,IB),string:new PB(`string`,IB),name:new PB(`name`,IB),privateId:new PB(`privateId`,IB),eof:new PB(`eof`),bracketL:new PB(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new PB(`]`),braceL:new PB(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new PB(`}`),parenL:new PB(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new PB(`)`),comma:new PB(`,`,FB),semi:new PB(`;`,FB),colon:new PB(`:`,FB),dot:new PB(`.`),question:new PB(`?`,FB),questionDot:new PB(`?.`),arrow:new PB(`=>`,FB),template:new PB(`template`),invalidTemplate:new PB(`invalidTemplate`),ellipsis:new PB(`...`,FB),backQuote:new PB("`",IB),dollarBraceL:new PB("${",{beforeExpr:!0,startsExpr:!0}),eq:new PB(`=`,{beforeExpr:!0,isAssign:!0}),assign:new PB(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new PB(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new PB(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Hz(`||`,1),logicalAND:Hz(`&&`,2),bitwiseOR:Hz(`|`,3),bitwiseXOR:Hz(`^`,4),bitwiseAND:Hz(`&`,5),equality:Hz(`==/!=/===/!==`,6),relational:Hz(`</>/<=/>=`,7),bitShift:Hz(`<</>>/>>>`,8),plusMin:new PB(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Hz(`%`,10),star:Hz(`*`,10),slash:Hz(`/`,10),starstar:new PB(`**`,{beforeExpr:!0}),coalesce:Hz(`??`,1),_break:Uz(`break`),_case:Uz(`case`,FB),_catch:Uz(`catch`),_continue:Uz(`continue`),_debugger:Uz(`debugger`),_default:Uz(`default`,FB),_do:Uz(`do`,{isLoop:!0,beforeExpr:!0}),_else:Uz(`else`,FB),_finally:Uz(`finally`),_for:Uz(`for`,{isLoop:!0}),_function:Uz(`function`,IB),_if:Uz(`if`),_return:Uz(`return`,FB),_switch:Uz(`switch`),_throw:Uz(`throw`,FB),_try:Uz(`try`),_var:Uz(`var`),_const:Uz(`const`),_while:Uz(`while`,{isLoop:!0}),_with:Uz(`with`),_new:Uz(`new`,{beforeExpr:!0,startsExpr:!0}),_this:Uz(`this`,IB),_super:Uz(`super`,IB),_class:Uz(`class`,IB),_extends:Uz(`extends`,FB),_export:Uz(`export`),_import:Uz(`import`,IB),_null:Uz(`null`,IB),_true:Uz(`true`,IB),_false:Uz(`false`,IB),_in:Uz(`in`,{beforeExpr:!0,binop:7}),_instanceof:Uz(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:Uz(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:Uz(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:Uz(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},RB=/\r\n?|\n|\u2028|\u2029/,zB=new RegExp(RB.source,`g`),BB=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,VB=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,HB=Object.prototype,UB=HB.hasOwnProperty,WB=HB.toString,GB=Object.hasOwn||(function(e,t){return UB.call(e,t)}),KB=Array.isArray||(function(e){return WB.call(e)===`[object Array]`}),qB=Object.create(null),JB=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,YB=function(e,t){this.line=e,this.column=t},YB.prototype.offset=function(e){return new YB(this.line,this.column+e)},XB=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)},ZB={ecmaVersion:null,sourceType:`script`,strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},QB=!1,$B=1,eV=2,tV=4,nV=8,rV=16,iV=32,aV=64,oV=128,sV=256,cV=512,lV=1024,uV=$B|eV|sV,dV=0,fV=1,pV=2,mV=3,hV=4,gV=5,_V=function(e,t,n){this.options=e=Yz(e),this.sourceFile=e.sourceFile,this.keywords=Kz(AB[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=OB[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=Kz(r);var i=(r?r+` `:``)+OB.strict;this.reservedWordsStrict=Kz(i),this.reservedWordsStrictBind=Kz(i+` `+OB.strictBind),this.input=String(t),this.containsEsc=!1,this.pos=n||0,this.curLine=1,e.startLocation?(this.lineStart=this.pos-e.startLocation.column,this.curLine=e.startLocation.line):n?(this.lineStart=this.input.lastIndexOf(`
1172
1172
  `,n-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(RB).length)):this.lineStart=0,this.type=$.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType===`module`,this.strict=this.inModule||e.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?eV:$B),this.regexpState=null,this.privateNameStack=[]},vV={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}},_V.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},vV.inFunction.get=function(){return(this.currentVarScope().flags&eV)>0},vV.inGenerator.get=function(){return(this.currentVarScope().flags&nV)>0},vV.inAsync.get=function(){return(this.currentVarScope().flags&tV)>0},vV.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(sV|cV))return!1;if(t&eV)return(t&tV)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},vV.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&$B)},vV.allowSuper.get=function(){return(this.currentThisScope().flags&aV)>0||this.options.allowSuperOutsideMethod},vV.allowDirectSuper.get=function(){return(this.currentThisScope().flags&oV)>0},vV.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},vV.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(sV|cV)||t&eV&&!(t&rV))return!0}return!1},vV.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&lV||!this.inModule&&e&$B)},vV.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&sV)>0},_V.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,r=0;r<e.length;r++)n=e[r](n);return n},_V.parse=function(e,t){return new this(t,e).parse()},_V.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},_V.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(_V.prototype,vV),yV=_V.prototype,bV=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/,yV.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){VB.lastIndex=e,e+=VB.exec(this.input)[0].length;var t=bV.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){VB.lastIndex=e+t[0].length;var n=VB.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||RB.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`)}e+=t[0].length,VB.lastIndex=e,e+=VB.exec(this.input)[0].length,this.input[e]===`;`&&e++}},yV.eat=function(e){return this.type===e&&(this.next(),!0)},yV.isContextual=function(e){return this.type===$.name&&this.value===e&&!this.containsEsc},yV.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},yV.catchStackOverflow=function(e){try{return e()}catch(e){if(e instanceof Error&&(/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message)||/\btoo much recursion\b/i.test(e.message)))this.raise(this.start,`Not enough stack space to parse input`);else throw e}},yV.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},yV.canInsertSemicolon=function(){return this.type===$.eof||this.type===$.braceR||RB.test(this.input.slice(this.lastTokEnd,this.start))},yV.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},yV.semicolon=function(){!this.eat($.semi)&&!this.insertSemicolon()&&this.unexpected()},yV.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},yV.expect=function(e){this.eat(e)||this.unexpected()},yV.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)},xV=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1},yV.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,`Comma is not permitted after the rest element`);var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?`Assigning to rvalue`:`Parenthesized pattern`)}},yV.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,`Shorthand property assignments are valid only in destructuring patterns`),r>=0&&this.raiseRecoverable(r,`Redefinition of __proto__ property`)},yV.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,`Yield expression cannot be a default value`),this.awaitPos&&this.raise(this.awaitPos,`Await expression cannot be a default value`)},yV.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`},SV=_V.prototype,SV.parseTopLevel=function(e){var t=Object.create(null);for(e.body||=[];this.type!==$.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)},CV={kind:`loop`},wV={kind:`switch`},SV.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;VB.lastIndex=this.pos;var t=VB.exec(this.input),n=this.pos+t[0].length,r=this.fullCharCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123)return!0;if(Bz(r)){var i=n;do n+=r<=65535?1:2;while(Vz(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!jB.test(a))return!0}return!1},SV.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;VB.lastIndex=this.pos;var e=VB.exec(this.input),t=this.pos+e[0].length,n;return!RB.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(Vz(n=this.fullCharCodeAt(t+8))||n===92))},SV.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;VB.lastIndex=this.pos;var n=VB.exec(this.input),r=this.pos+n[0].length;if(RB.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!==`using`||i===this.input.length||Vz(a=this.fullCharCodeAt(i))||a===92)return!1;VB.lastIndex=i;var o=VB.exec(this.input);if(r=i+o[0].length,o&&RB.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!Bz(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(Vz(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(jB.test(l))return!1;if(t&&!e&&l===`of`){VB.lastIndex=r;var u=VB.exec(this.input);if(r+=u[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},SV.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},SV.isUsing=function(e){return this.isUsingKeyword(!1,e)},SV.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=$._var,a=`let`),r){case $._break:case $._continue:return this.parseBreakContinueStatement(i,r.keyword);case $._debugger:return this.parseDebuggerStatement(i);case $._do:return this.parseDoStatement(i);case $._for:return this.parseForStatement(i);case $._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case $._class:return e&&this.unexpected(),this.parseClass(i,!0);case $._if:return this.parseIfStatement(i);case $._return:return this.parseReturnStatement(i);case $._switch:return this.parseSwitchStatement(i);case $._throw:return this.parseThrowStatement(i);case $._try:return this.parseTryStatement(i);case $._const:case $._var:return a||=this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case $._while:return this.parseWhileStatement(i);case $._with:return this.parseWithStatement(i);case $.braceL:return this.parseBlock(!0,i);case $.semi:return this.parseEmptyStatement(i);case $._export:case $._import:if(this.options.ecmaVersion>10&&r===$._import){VB.lastIndex=this.pos;var o=VB.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),r===$._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===$.name&&d.type===`Identifier`&&this.eat($.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},SV.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat($.semi)||this.insertSemicolon()?e.label=null:this.type===$.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},SV.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},SV.parseDoStatement=function(e){return this.next(),this.labels.push(CV),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect($._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat($.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},SV.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(CV),this.enterScope(0),this.expect($.parenL),this.type===$.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===$._var||this.type===$._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new xV,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===$._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===$._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},SV.parseForAfterInit=function(e,t,n){return(this.type===$._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===$._in?((t.kind===`using`||t.kind===`await using`)&&!t.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},SV.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,EV|(n?0:DV),!1,t)},SV.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat($._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},SV.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat($.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},SV.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect($.braceL),this.labels.push(wV),this.enterScope(lV);for(var t,n=!1;this.type!==$.braceR;)if(this.type===$._case||this.type===$._default){var r=this.type===$._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect($.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},SV.parseThrowStatement=function(e){return this.next(),RB.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)},TV=[],SV.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?iV:0),this.checkLValPattern(e,t?hV:pV),this.expect($.parenR),e},SV.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===$._catch){var t=this.startNode();this.next(),this.eat($.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat($._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},SV.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},SV.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(CV),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},SV.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},SV.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},SV.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===$._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},SV.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},SV.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect($.braceL),e&&this.enterScope(0);this.type!==$.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},SV.parseFor=function(e,t){return e.init=t,this.expect($.semi),e.test=this.type===$.semi?null:this.parseExpression(),this.expect($.semi),e.update=this.type===$.parenR?null:this.parseExpression(),this.expect($.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},SV.parseForIn=function(e,t){var n=this.type===$._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect($.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},SV.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat($.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===$._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==$._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&(!t||this.type!==$._in&&!this.isContextual(`of`))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat($.comma))break}return e},SV.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?fV:pV,!1)},EV=1,DV=2,OV=4,SV.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===$.star&&t&DV&&this.unexpected(),e.generator=this.eat($.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&EV&&(e.id=t&OV&&this.type!==$.name?null:this.parseIdent(),e.id&&!(t&DV)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?fV:pV:mV));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Zz(e.async,e.generator)),t&EV||(e.id=this.type===$.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&EV?`FunctionDeclaration`:`FunctionExpression`)},SV.parseFunctionParams=function(e){this.expect($.parenL),e.params=this.parseBindingList($.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},SV.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect($.braceL);this.type!==$.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&Qz(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},SV.parseClassElement=function(e){if(this.eat($.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat($.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===$.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===$.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat($.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===$.parenL||o!==`method`||i||a){var l=!n.static&&$z(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},SV.isClassElementNameStart=function(){return this.type===$.name||this.type===$.privateId||this.type===$.num||this.type===$.string||this.type===$.bracketL||this.type.keyword},SV.parseClassElementName=function(e){this.type===$.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},SV.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&$z(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},SV.parseClassField=function(e){return $z(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&$z(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat($.eq)?(this.enterScope(cV|aV),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},SV.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(sV|aV);this.type!==$.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},SV.parseClassId=function(e,t){this.type===$.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,pV,!1)):(t===!0&&this.unexpected(),e.id=null)},SV.parseClassSuper=function(e){e.superClass=this.eat($._extends)?this.parseExprSubscripts(null,!1):null},SV.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},SV.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];GB(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}},SV.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==$.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},SV.parseExport=function(e,t){if(this.next(),this.eat($.star))return this.parseExportAllDeclaration(e,t);if(this.eat($._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==$.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},SV.parseExportDeclaration=function(e){return this.parseStatement(null)},SV.parseExportDefaultDeclaration=function(){var e;if(this.type===$._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,EV|OV,!1,e)}if(this.type===$._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}var r=this.parseMaybeAssign();return this.semicolon(),r},SV.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),GB(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},SV.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},SV.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},SV.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},SV.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},SV.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect($.braceL);!this.eat($.braceR);){if(n)n=!1;else if(this.expect($.comma),this.afterTrailingComma($.braceR))break;t.push(this.parseExportSpecifier(e))}return t},SV.parseImport=function(e){return this.next(),this.type===$.string?(e.specifiers=TV,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===$.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},SV.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,pV),this.finishNode(e,`ImportSpecifier`)},SV.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,pV),this.finishNode(e,`ImportDefaultSpecifier`)},SV.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,pV),this.finishNode(e,`ImportNamespaceSpecifier`)},SV.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===$.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat($.comma)))return e;if(this.type===$.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect($.braceL);!this.eat($.braceR);){if(t)t=!1;else if(this.expect($.comma),this.afterTrailingComma($.braceR))break;e.push(this.parseImportSpecifier())}return e},SV.parseWithClause=function(){var e=[];if(!this.eat($._with))return e;this.expect($.braceL);for(var t={},n=!0;!this.eat($.braceR);){if(n)n=!1;else if(this.expect($.comma),this.afterTrailingComma($.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;GB(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},SV.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===$.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect($.colon),this.type!==$.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},SV.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===$.string){var e=this.parseLiteral(this.value);return JB.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},SV.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},SV.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`"`||this.input[e.start]===`'`)},kV=_V.prototype,kV.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case`Identifier`:this.inAsync&&e.name===`await`&&this.raise(e.start,`Cannot use 'await' as identifier inside an async function`);break;case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:break;case`ObjectExpression`:e.type=`ObjectPattern`,n&&this.checkPatternErrors(n,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.toAssignable(a,t),a.type===`RestElement`&&(a.argument.type===`ArrayPattern`||a.argument.type===`ObjectPattern`)&&this.raise(a.argument.start,`Unexpected token`)}break;case`Property`:e.kind!==`init`&&this.raise(e.key.start,`Object pattern can't contain getter or setter`),this.toAssignable(e.value,t);break;case`ArrayExpression`:e.type=`ArrayPattern`,n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case`SpreadElement`:e.type=`RestElement`,this.toAssignable(e.argument,t),e.argument.type===`AssignmentPattern`&&this.raise(e.argument.start,`Rest elements cannot have a default value`);break;case`AssignmentExpression`:e.operator!==`=`&&this.raise(e.left.end,`Only '=' operator can be used for specifying default value.`),e.type=`AssignmentPattern`,delete e.operator,this.toAssignable(e.left,t);break;case`ParenthesizedExpression`:this.toAssignable(e.expression,t,n);break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:if(!t)break;default:this.raise(e.start,`Assigning to rvalue`)}else n&&this.checkPatternErrors(n,!0);return e},kV.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type===`RestElement`&&a.argument.type!==`Identifier`&&this.unexpected(a.argument.start)}return e},kV.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},kV.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==$.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},kV.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case $.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList($.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case $.braceL:return this.parseObj(!0)}return this.parseIdent()},kV.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect($.comma),t&&this.type===$.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===$.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===$.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},kV.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},kV.parseBindingListItem=function(e){return e},kV.parseMaybeDefault=function(e,t,n){if(n||=this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat($.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},kV.checkLValSimple=function(e,t,n){t===void 0&&(t=dV);var r=t!==dV;switch(e.type){case`Identifier`:this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?`Binding `:`Assigning to `)+e.name+` in strict mode`),r&&(t===pV&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(GB(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==gV&&this.declareName(e.name,t,e.start));break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:r&&this.raiseRecoverable(e.start,`Binding member expression`);break;case`ParenthesizedExpression`:return r&&this.raiseRecoverable(e.start,`Binding parenthesized expression`),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?`Binding`:`Assigning to`)+` rvalue`)}},kV.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=dV),e.type){case`ObjectPattern`:for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case`ArrayPattern`:for(var o=0,s=e.elements;o<s.length;o+=1){var c=s[o];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},kV.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=dV),e.type){case`Property`:this.checkLValInnerPattern(e.value,t,n);break;case`AssignmentPattern`:this.checkLValPattern(e.left,t,n);break;case`RestElement`:this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}},AV=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},jV={b_stat:new AV(`{`,!1),b_expr:new AV(`{`,!0),b_tmpl:new AV("${",!1),p_stat:new AV(`(`,!1),p_expr:new AV(`(`,!0),q_tmpl:new AV("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new AV(`function`,!1),f_expr:new AV(`function`,!0),f_expr_gen:new AV(`function`,!0,!1,null,!0),f_gen:new AV(`function`,!1,!1,null,!0)},MV=_V.prototype,MV.initialContext=function(){return[jV.b_stat]},MV.curContext=function(){return this.context[this.context.length-1]},MV.braceIsBlock=function(e){var t=this.curContext();return t===jV.f_expr||t===jV.f_stat?!0:e===$.colon&&(t===jV.b_stat||t===jV.b_expr)?!t.isExpr:e===$._return||e===$.name&&this.exprAllowed?RB.test(this.input.slice(this.lastTokEnd,this.start)):e===$._else||e===$.semi||e===$.eof||e===$.parenR||e===$.arrow?!0:e===$.braceL?t===jV.b_stat:e===$._var||e===$._const||e===$.name?!1:!this.exprAllowed},MV.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token===`function`)return t.generator}return!1},MV.updateContext=function(e){var t,n=this.type;n.keyword&&e===$.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},MV.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},$.parenR.updateContext=$.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===jV.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},$.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?jV.b_stat:jV.b_expr),this.exprAllowed=!0},$.dollarBraceL.updateContext=function(){this.context.push(jV.b_tmpl),this.exprAllowed=!0},$.parenL.updateContext=function(e){var t=e===$._if||e===$._for||e===$._with||e===$._while;this.context.push(t?jV.p_stat:jV.p_expr),this.exprAllowed=!0},$.incDec.updateContext=function(){},$._function.updateContext=$._class.updateContext=function(e){e.beforeExpr&&e!==$._else&&(e!==$.semi||this.curContext()===jV.p_stat)&&!(e===$._return&&RB.test(this.input.slice(this.lastTokEnd,this.start)))&&(e!==$.colon&&e!==$.braceL||this.curContext()!==jV.b_stat)?this.context.push(jV.f_expr):this.context.push(jV.f_stat),this.exprAllowed=!1},$.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},$.backQuote.updateContext=function(){this.curContext()===jV.q_tmpl?this.context.pop():this.context.push(jV.q_tmpl),this.exprAllowed=!1},$.star.updateContext=function(e){if(e===$._function){var t=this.context.length-1;this.context[t]===jV.f_expr?this.context[t]=jV.f_expr_gen:this.context[t]=jV.f_gen}this.exprAllowed=!0},$.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==$.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t},NV=_V.prototype,NV.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type===`SpreadElement`)&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,i;switch(r.type){case`Identifier`:i=r.name;break;case`Literal`:i=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){i===`__proto__`&&a===`init`&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,`Redefinition of __proto__ property`)),t.proto=!0);return}i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}},NV.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===$.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat($.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},NV.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new xV,r=!0);var s=this.start,c=this.startLoc;(this.type===$.parenL||this.type===$.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===$.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===$.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},NV.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if((i.type!==`ArrowFunctionExpression`||i.start!==n)&&this.eat($.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect($.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},NV.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},NV.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==$._in)&&a>r){var o=this.type===$.logicalOR||this.type===$.logicalAND,s=this.type===$.coalesce;s&&(a=$.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===$.coalesce||s&&(this.type===$.logicalOR||this.type===$.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},NV.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},NV.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===$.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&eB(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&tB(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===$.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==$._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&(o.type!==`ArrowFunctionExpression`||o.start!==i)&&this.eat($.starstar)){if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1)}else return o},NV.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprAtom(e,t);if(i.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return i;var a=this.parseSubscripts(i,n,r,!1,t);return e&&a.type===`MemberExpression`&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a},NV.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s===e||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s}},NV.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat($.arrow)},NV.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},NV.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat($.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat($.bracketL);if(l||c&&this.type!==$.parenL&&this.type!==$.backQuote||this.eat($.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect($.bracketR)):u.property=this.type===$.privateId&&e.type!==`Super`?this.parsePrivateIdent():this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat($.parenL)){var d=new xV,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList($.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===$.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},NV.parseExprAtom=function(e,t,n){this.type===$.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case $._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===$.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==$.dot&&this.type!==$.bracketL&&this.type!==$.parenL&&this.unexpected(),this.finishNode(r,`Super`);case $._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case $.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat($._function))return this.overrideContext(jV.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat($.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===$.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat($.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case $.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case $.num:case $.string:return this.parseLiteral(this.value);case $._null:case $._true:case $._false:return r=this.startNode(),r.value=this.type===$._null?null:this.type===$._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case $.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case $.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList($.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case $.braceL:return this.overrideContext(jV.b_expr),this.parseObj(!1,e);case $._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case $._class:return this.parseClass(this.startNode(),!1);case $._new:return this.parseNew();case $.backQuote:return this.parseTemplate();case $._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},NV.parseExprAtomDefault=function(){this.unexpected()},NV.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===$.parenL&&!e)return this.parseDynamicImport(t);if(this.type===$.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}this.unexpected()},NV.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat($.parenR)?e.options=null:(this.expect($.comma),this.afterTrailingComma($.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat($.parenR)||(this.expect($.comma),this.afterTrailingComma($.parenR)||this.unexpected())));else if(!this.eat($.parenR)){var t=this.start;this.eat($.comma)&&this.eat($.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},NV.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},NV.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},NV.parseParenExpression=function(){this.expect($.parenL);var e=this.parseExpression();return this.expect($.parenR),e},NV.shouldParseArrow=function(e){return!this.canInsertSemicolon()},NV.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new xV,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==$.parenR;){if(l?l=!1:this.expect($.comma),a&&this.afterTrailingComma($.parenR,!0)){u=!0;break}if(this.type===$.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===$.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}c.push(this.parseMaybeAssign(!1,d,this.parseParenItem))}var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect($.parenR),e&&this.shouldParseArrow(c)&&this.eat($.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=p,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,h,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(n,r);return _.expression=i,this.finishNode(_,`ParenthesizedExpression`)}return i},NV.parseParenItem=function(e){return e},NV.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)},PV=[],NV.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===$.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),e.arguments=this.eat($.parenL)?this.parseExprList($.parenR,this.options.ecmaVersion>=8,!1):PV,this.finishNode(e,`NewExpression`)},NV.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===$.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\r\n?/g,`
1173
1173
  `),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
@@ -1175,9 +1175,9 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
1175
1175
  `;break;default:e+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},fH.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case"`":return this.finishToken($.invalidTemplate,this.input.slice(this.start,this.pos));case`\r`:this.input[this.pos+1]===`
1176
1176
  `&&++this.pos;case`
1177
1177
  `:case`\u2028`:case`\u2029`:++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,`Unterminated template`)},fH.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
1178
- `;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return qz(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return Wz(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},fH.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},fH.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(Vz(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?Bz:Vz)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=qz(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},fH.readWord=function(){var e=this.readWord1(),t=$.name;return this.keywords.test(e)&&(t=LB[e]),this.finishToken(t,e)},mH=`8.18.0`,_V.acorn={Parser:_V,version:mH,defaultOptions:ZB,Position:YB,SourceLocation:XB,getLineInfo:Jz,Node:RV,TokenType:PB,tokTypes:$,keywordTypes:LB,TokContext:AV,tokContexts:jV,isIdentifierChar:Vz,isIdentifierStart:Bz,Token:dH,isNewLine:Wz,lineBreak:RB,lineBreakG:zB,nonASCIIwhitespace:BB}}));async function gH(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=await globalThis.crypto.subtle.digest(`SHA-256`,t);return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function _H(e,t,n){let r=e.files[t];B(r,`MODULE_FILE`,`${t} is not part of this module`);let i=n instanceof Uint8Array?n:new Uint8Array(n);return B(i.byteLength===r.bytes&&await gH(i)===r.sha256,`MODULE_FILE`,`${t} does not match its recorded digest`),i}var vH=o((()=>{Et(),Object.freeze({files:64,fileBytes:67108864,totalBytes:134217728,path:160,wallClockMs:12e4,maxWallClockMs:18e5,progressGraceMs:6e4,messageBytes:16777216,logEntries:500}),Object.freeze([`text/javascript`,`application/wasm`,`application/json`,`text/plain`,`image/png`,`image/jpeg`,`image/webp`,`font/woff2`,`application/octet-stream`]),Object.freeze([`input`,`signal`,`progress`,`log`,`asset`,`files.read`,`files.write`,`media.transform`,`actions.run`,`hosted.run`,`connections.call`,`net.fetch`,`net.connect`,`storage.info`,`storage.list`,`storage.get`,`storage.set`,`storage.remove`,`storage.putFile`,`storage.getFile`,`project.read`,`assets.create`,`assets.appendVersion`])}));function yH(e){return e?e.type===`Identifier`?[e.name]:e.type===`RestElement`?yH(e.argument):e.type===`AssignmentPattern`?yH(e.left):e.type===`ArrayPattern`?e.elements.flatMap(yH):e.type===`ObjectPattern`?e.properties.flatMap(e=>yH(e.type===`RestElement`?e.argument:e.value)):[]:[]}function bH(e){return e?.type===`MemberExpression`?bH(e.object):yH(e)}function xH(e){let t=[],n=new Map,r=new Map,i=new Set,a=new Map,o=[e];for(;o.length;){let e=o.pop();B(t.length<25e3,`VIEW`,`View JavaScript exceeds review complexity`),t.push(e);let s=e.type===`VariableDeclarator`?[e.id]:[`FunctionExpression`,`ArrowFunctionExpression`,`FunctionDeclaration`].includes(e.type)?[e.id,...e.params]:[`ClassDeclaration`,`ClassExpression`].includes(e.type)?[e.id]:e.type===`CatchClause`?[e.param]:[];for(let e of s)for(let t of yH(e))r.set(t,(r.get(t)||0)+1);if(e.type===`AssignmentExpression`)for(let t of bH(e.left))i.add(t);if(e.type===`UpdateExpression`||e.type===`UnaryExpression`&&e.operator===`delete`)for(let t of bH(e.argument))i.add(t);if(e.type===`CallExpression`&&e.callee?.type===`MemberExpression`&&!e.callee.computed&&e.callee.object?.type===`Identifier`&&e.callee.object.name===`StillMade`&&e.callee.property.name===`onInput`&&e.arguments.length===1){let t=e.arguments[0];[`ArrowFunctionExpression`,`FunctionExpression`].includes(t.type)&&t.params.length===1&&t.params[0].type===`Identifier`&&a.set(t,t.params[0].name)}for(let t of Object.values(e))for(let r of Array.isArray(t)?t:[t])r&&typeof r==`object`&&(n.set(r,e),o.push(r))}let s=new Set;for(let e of t){if(e.computed||PH(e)!==`prompt`)continue;if(e.type===`Property`&&n.get(e)?.type===`ObjectExpression`&&!e.shorthand&&!e.method&&e.kind===`init`){s.add(e);continue}if(e.type!==`MemberExpression`||e.object?.type!==`Identifier`||r.has(`StillMade`)||i.has(`StillMade`))continue;let t=e.object.name;if(r.get(t)!==1||i.has(t))continue;let o=n.get(e);for(;o?.type===`ChainExpression`;)o=n.get(o);if((![`CallExpression`,`NewExpression`,`TaggedTemplateExpression`].includes(o?.type)||o.callee!==e&&o.tag!==e&&o.callee?.type!==`ChainExpression`)&&!(o?.type===`MemberExpression`&&o.object===e&&[`call`,`apply`,`bind`].includes(PH(o)))){for(let r=n.get(e);r;r=n.get(r))if(a.get(r)===t){s.add(e);break}}}return{nodes:t,parents:n,allowed:s}}function SH(e){if(VH(e))return EH(e);B(vt(e)&&Object.keys(e).every(e=>[`html`,`css`,`javascript`,`themedCss`,`appearance`].includes(e)),`VIEW`,`View must contain only html, css, javascript, optional themedCss, and appearance`),B(e.appearance===void 0||[`host`,`original`].includes(e.appearance),`VIEW`,`View appearance must be host or original`);for(let t of[`html`,`css`,`javascript`,`themedCss`])(t===`html`||e[t]!==void 0)&&B(typeof e[t]==`string`&&kH(e[t])<=OH[`${t===`themedCss`?`css`:t}Bytes`]&&(t!==`html`||e[t].trim().length>0),`VIEW`,`View ${t} exceeds its size limit or is empty`);let t=e.html,n=/<\/?([a-z][a-z0-9-]*)(?:\s+[a-z_:][a-z0-9_:.-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'`=<>]+))?)*\s*\/?>/gi;B(!t.replace(n,``).includes(`<`),`VIEW`,`Use complete HTML control tags; declarations, comments, and malformed markup are unsupported`);for(let e of t.matchAll(n)){B(NH.has(e[1].toLowerCase()),`VIEW`,`Unsupported view element: ${e[1]}`);let t=e[0].slice(e[0].indexOf(e[1])+e[1].length).replace(/\/?>$/,``);for(let e of t.matchAll(/\s+([a-z_:][a-z0-9_:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'`=<>]+)))?/gi)){let t=e[1].toLowerCase(),n=e[2]??e[3]??e[4]??``;B(!t.startsWith(`on`)&&![`href`,`srcdoc`,`action`,`formaction`,`form`,`target`,`download`,`ping`,`autofocus`,`nonce`,`is`].includes(t)&&!t.includes(`:`),`VIEW`,`View markup contains an unsupported executable or navigation attribute`),[`src`,`poster`].includes(t)&&B(/^(?:data:|blob:)/i.test(n),`VIEW`,`View media must use data or blob URLs`)}}let r=[...t.matchAll(/\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi)].map(e=>e[1]??e[2]??e[3]);if(B(!/@import|@font-face|url\s*\(|expression\s*\(|-moz-binding|<\/style/i.test([e.css||``,e.themedCss||``,...r].join(`
1179
- `)),`VIEW`,`View CSS cannot load resources or contain markup`),e.javascript){let t;try{t=CB(`"use strict";\n${e.javascript}`,{ecmaVersion:2022,sourceType:`script`})}catch(e){throw Object.assign(Error(`View JavaScript syntax: ${e.message}`),{code:`VIEW`})}let{nodes:n,parents:r,allowed:i}=xH(t),a=new Map;for(let e of n){B(!MH.includes(e.type),`VIEW`,`Unsupported view syntax: ${e.type}`),e.type===`FunctionExpression`&&B(!e.id,`VIEW`,`Named recursive functions are unsupported in view code`),e.type===`VariableDeclarator`&&e.id?.type===`Identifier`&&[`FunctionExpression`,`ArrowFunctionExpression`].includes(e.init?.type)&&a.set(e.id.name,e.init),e.type===`CallExpression`&&e.callee?.type===`Identifier`&&B(![`addEventListener`,`removeEventListener`,`dispatchEvent`].includes(e.callee.name),`VIEW`,`Attach events to declared controls, not the global frame`);let t=r.get(e),n=i.has(t)&&(t.property||t.key)===e;if(e.type===`Identifier`&&B(n||!AH.has(e.name),`VIEW`,`Unsupported view API: ${e.name}. View code cannot use this name, even for its own variable; rename it.`),[`MemberExpression`,`Property`,`MethodDefinition`].includes(e.type)&&!e.computed&&B(i.has(e)||!jH.has(PH(e)),`VIEW`,`Unsupported view property`),[`MemberExpression`,`Property`,`MethodDefinition`].includes(e.type)&&e.computed){let t=e.property||e.key;B(t?.type===`Literal`&&(typeof t.value==`string`||Number.isInteger(t.value))&&!jH.has(t.value),`VIEW`,`View property access must use a safe literal key`)}}B(a.size<=128,`VIEW`,`View contains too many helper functions`);let o=0,s=e=>{let t=new Set,n=[e];for(;n.length;){let e=n.pop();B(++o<=1e5,`VIEW`,`View helpers exceed review complexity`);let i=r.get(e),a=i?.type===`MemberExpression`&&!i.computed&&i.property===e||i?.type===`Property`&&!i.computed&&!i.shorthand&&i.key===e;e.type===`Identifier`&&!a&&t.add(e.name);for(let t of Object.values(e))Array.isArray(t)?n.push(...t.filter(e=>e&&typeof e==`object`)):t&&typeof t==`object`&&n.push(t)}return t},c=new Map([...a].map(([e,t])=>[e,[...s(t.body)].filter(e=>a.has(e))])),l=new Set,u=(e,t=new Set)=>{if(l.has(e))return;B(!t.has(e),`VIEW`,`Recursive UI functions are unsupported; move computation into the Block runtime`);let n=new Set([...t,e]);for(let t of c.get(e)||[])u(t,n);l.add(e)};for(let e of c.keys())u(e)}return!0}function CH(e,t){B(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t),`VIEW`,`Invalid interface guard`);let n=[CB(`"use strict";
1180
- `+e,{ecmaVersion:2022})],r=[];for(;n.length;){let e=n.pop();[`ArrowFunctionExpression`,`FunctionExpression`,`FunctionDeclaration`].includes(e.type)&&(e.body.type===`BlockStatement`?r.push({position:e.body.start+1-14,text:`${t}();`}):(r.push({position:e.body.start-14,text:`(${t}(),`}),r.push({position:e.body.end-14,text:`)`})));for(let t of Object.values(e))Array.isArray(t)?n.push(...t.filter(e=>e&&typeof e==`object`)):t&&typeof t==`object`&&n.push(t)}for(let t of r.sort((e,t)=>t.position-e.position))e=e.slice(0,t.position)+t.text+e.slice(t.position);return e}function wH(e){try{return{ast:CB(e,{ecmaVersion:`latest`,sourceType:`script`})}}catch(t){let n=!1;try{CB(e,{ecmaVersion:`latest`,sourceType:`module`}),n=!0}catch{}throw Object.assign(Error(n?`Frame view JavaScript must be one classic script: bundle it as an IIFE (for example esbuild --format=iife).`:`View JavaScript syntax: ${t.message}`),{code:`VIEW`})}}function TH(e,t,n){B(typeof e==`string`&&kH(e)<=FH.codeFileBytes,`VIEW`,`Code file ${t} exceeds ${Math.round(FH.codeFileBytes/1048576)} MiB`);let r;try{r=wH(e).ast}catch(e){throw Object.assign(Error(`Code file ${t}: ${e.message}`),{code:`VIEW`})}let i=[r],a=0;for(;i.length;){let e=i.pop();B(++a<=4e6,`VIEW`,`Code file ${t} is too complex to compile`),B(e.type!==`ImportExpression`,`VIEW`,`Code file ${t} uses import(); load more code with StillMade.loadCode instead`);for(let t of Object.values(e))if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&i.push(e);else t&&typeof t==`object`&&typeof t.type==`string`&&i.push(t)}return n===void 0?e:DH(e,n)}function EH(e){B(Object.keys(e).every(e=>RH.includes(e)),`VIEW`,`A frame view contains runtime "frame", html and optional css, themedCss, javascript, appearance and files`),B(e.appearance===void 0||[`host`,`original`].includes(e.appearance),`VIEW`,`View appearance must be host or original`);for(let t of[`html`,`css`,`javascript`,`themedCss`]){if(t!==`html`&&e[t]===void 0)continue;let n=FH[`${t===`themedCss`?`css`:t}Bytes`];B(typeof e[t]==`string`&&kH(e[t])<=n&&(t!==`html`||e[t].trim().length>0),`VIEW`,`Frame view ${t} exceeds ${Math.round(n/1024)} KiB or is empty`)}B(!zH.test(e.html),`VIEW`,`Frame view markup cannot contain script, frame, object, embed, base, meta or link elements; put code in view.javascript and assets in view.files`);for(let t of[e.css,e.themedCss])t&&B(!/@import|url\s*\(\s*["']?\s*(?:https?:|\/\/)|<\/style/i.test(t),`VIEW`,`Frame view CSS cannot load remote resources; ship them in view.files`);if(e.javascript){let{ast:t}=wH(e.javascript),n=[t],r=0;for(;n.length;){let e=n.pop();B(++r<=4e6,`VIEW`,`Frame view JavaScript is too complex to compile`),B(e.type!==`ImportExpression`,`VIEW`,`Bundle every dependency into view.javascript; frame views cannot import code`);for(let t of Object.values(e))if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&n.push(e);else t&&typeof t==`object`&&typeof t.type==`string`&&n.push(t)}}if(e.files!==void 0){B(vt(e.files)&&e.files.schemaVersion===1&&vt(e.files.files)&&Object.keys(e.files).every(e=>[`schemaVersion`,`files`].includes(e)),`VIEW`,`view.files is {schemaVersion: 1, files: {path: {sha256, bytes, mediaType}}}`);let t=Object.entries(e.files.files),n=0,r=0,i=0;for(let[e,a]of t)B(BH.test(e)&&vt(a)&&Object.keys(a).every(e=>[`sha256`,`bytes`,`mediaType`].includes(e))&&/^[a-f0-9]{64}$/.test(a.sha256||``)&&Number.isSafeInteger(a.bytes)&&a.bytes>0&&LH.includes(a.mediaType),`VIEW`,`View asset ${e} needs a safe path, its SHA-256, size and a supported media type`),HH(a)?(B(e.endsWith(`.js`),`VIEW`,`Code file ${e} needs a .js name`),B(a.bytes<=FH.codeFileBytes,`VIEW`,`Code file ${e} exceeds ${Math.round(FH.codeFileBytes/1048576)} MiB`),i++,r+=a.bytes):n+=a.bytes;B(t.length-i<=FH.assetFiles,`VIEW`,`A frame view ships at most ${FH.assetFiles} asset files`),B(n<=FH.assetBytes,`VIEW`,`Frame view assets exceed 8 MiB in total`),B(i<=FH.codeFiles,`VIEW`,`A frame view ships at most ${FH.codeFiles} code files`),B(r<=FH.codeBytes,`VIEW`,`Frame view code files exceed ${Math.round(FH.codeBytes/1048576)} MiB in total`)}return!0}function DH(e,t){B(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t),`VIEW`,`Invalid interface guard`);let{ast:n}=wH(e),r=[],i=[[n,0]],a=`${t}();`;for(;i.length;){let[e,n]=i.pop();[`ArrowFunctionExpression`,`FunctionExpression`,`FunctionDeclaration`].includes(e.type)&&(e.body.type===`BlockStatement`?r.push({position:e.body.start+1,text:a,depth:n,open:!0}):(r.push({position:e.body.start,text:`(${t}(),`,depth:n,open:!0}),r.push({position:e.body.end,text:`)`,depth:n,open:!1}))),[`WhileStatement`,`DoWhileStatement`,`ForStatement`,`ForInStatement`,`ForOfStatement`].includes(e.type)&&(e.body.type===`BlockStatement`?r.push({position:e.body.start+1,text:a,depth:n,open:!0}):(r.push({position:e.body.start,text:`{${a}`,depth:n,open:!0}),r.push({position:e.body.end,text:`}`,depth:n,open:!1})));for(let t of Object.values(e))if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&i.push([e,n+1]);else t&&typeof t==`object`&&typeof t.type==`string`&&i.push([t,n+1])}r.sort((e,t)=>t.position-e.position||(e.open===t.open?e.open?t.depth-e.depth:e.depth-t.depth:e.open?-1:1));let o=``,s=0;for(let t=r.length-1;t>=0;){let n=r[t].position,i=t;for(;i>0&&r[i-1].position===n;)i--;o+=e.slice(s,n);for(let e=t;e>=i;e--)o+=r[e].text;s=n,t=i-1}return o+e.slice(s)}var OH,kH,AH,jH,MH,NH,PH,FH,IH,LH,RH,zH,BH,VH,HH,UH=o((()=>{hH(),Et(),vH(),OH=Object.freeze({htmlBytes:65536,cssBytes:32768,javascriptBytes:65536,messageBytes:4194304,runsPerMinute:120,imagePreviewsPerMinute:240,voicePreviewsPerMinute:30,allowanceCredits:2e3,imagePreviewMs:15e3,imagePreviewEdge:512,imagePreviewMaxEdge:2048}),kH=e=>new TextEncoder().encode(e).length,AH=new Set(`eval.Function.AsyncFunction.GeneratorFunction.require.importScripts.process.globalThis.window.self.top.parent.opener.frames.location.navigation.history.navigator.localStorage.sessionStorage.indexedDB.caches.cookieStore.fetch.XMLHttpRequest.WebSocket.EventSource.Worker.SharedWorker.ServiceWorker.WebAssembly.Deno.Bun.Reflect.Proxy.DOMParser.MutationObserver.postMessage.open.close.print.alert.confirm.prompt.setInterval.setTimeout.queueMicrotask.arguments.constructor.__proto__.prototype.__lookupGetter__.__lookupSetter__.__defineGetter__.__defineSetter__.getPrototypeOf.setPrototypeOf.getOwnPropertyDescriptor.getOwnPropertyDescriptors.getOwnPropertyNames.getOwnPropertySymbols.defineProperty.defineProperties.defaultView.ownerGlobal.contentWindow.contentDocument.cookie.domain.documentURI.URL.baseURI.referrer.write.writeln.innerHTML.outerHTML.insertAdjacentHTML.createElement.createElementNS.createContextualFragment.createRange.setAttribute.setAttributeNS.attributes.attributeStyleMap.adoptNode.importNode.execCommand.replaceChildren.setHTML.setHTMLUnsafe.parseHTML.parseHTMLUnsafe`.split(`.`));for(let e of[`showSaveFilePicker`,`showDirectoryPicker`,`saveAs`,`FileSystemWritableFileStream`,`createWritable`,`msSaveBlob`,`msSaveOrOpenBlob`,`download`])AH.add(e);jH=new Set([...AH,`assign`,`values`,`entries`,`fromEntries`]),Object.freeze([...AH]),Object.freeze([`assign`,`values`,`entries`,`fromEntries`]),MH=Object.freeze([`ImportExpression`,`ImportDeclaration`,`WithStatement`,`ThisExpression`,`MetaProperty`,`WhileStatement`,`DoWhileStatement`,`ForStatement`,`ForInStatement`,`ForOfStatement`,`FunctionDeclaration`]),NH=new Set(`div.section.article.header.footer.main.aside.nav.h1.h2.h3.h4.p.span.strong.em.i.small.br.hr.label.input.textarea.button.select.option.optgroup.fieldset.legend.output.progress.meter.ul.ol.li.dl.dt.dd.figure.figcaption.img.video.audio.source.canvas.table.thead.tbody.tfoot.tr.th.td.pre.code.details.summary`.split(`.`)),Object.freeze([...NH]),PH=e=>(e.property||e.key)?.name??(e.property||e.key)?.value,FH=Object.freeze({htmlBytes:262144,cssBytes:262144,javascriptBytes:4194304,assetFiles:32,assetBytes:8388608,codeFiles:64,codeFileBytes:4194304,codeBytes:16777216,mediaPreviews:24,taskMs:250,longTaskMs:1e3}),IH=`text/javascript`,LH=Object.freeze([`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/svg+xml`,`font/woff2`,`application/json`,`text/plain`,`audio/mpeg`,`audio/wav`,`video/mp4`,`application/octet-stream`,IH]),RH=[`runtime`,`html`,`css`,`themedCss`,`javascript`,`appearance`,`files`],zH=/<\s*(script|iframe|frame|frameset|object|embed|applet|base|meta|link|portal|noscript)\b/i,BH=/^(?!\/)(?!.*\.\.)(?!.*\/\/)[A-Za-z0-9._\/-]{1,160}$/,VH=e=>vt(e)&&e.runtime===`frame`,HH=e=>e?.mediaType===IH}));UH();function WH(e,t,n,{guardName:r,taskMs:i,assets:a}){let o=parent,s=performance.now.bind(performance),c=setTimeout.bind(globalThis),l=Error,u=`This interface ran too long without pausing and was stopped. Move long work into a Worker or the Block runtime.`,d=!1,f=0,p=0,m=0,h=!1,g=s(),_=0,v=!1,y=()=>{d&&(_+=Math.max(0,p-f)),d=!1,m=0,h=!1;let r=s();r-g>=5e3&&(!v&&_/(r-g)>.7&&(v=!0,n({channel:e,session:t,op:`unresponsive`},`*`)),g=r,_=0)};Object.defineProperty(globalThis,r,{value:()=>{if(h)throw new l(u);if(!d){d=!0,f=p=s(),c(y,0);return}if(!(++m&255)&&(p=s(),p-f>i))throw h=!0,new l(u)},writable:!1,configurable:!1,enumerable:!1});try{globalThis.navigation?.addEventListener(`navigate`,e=>{e.cancelable&&e.preventDefault()})}catch{}addEventListener(`pagehide`,()=>n({channel:e,session:t,op:`navigated`},`*`)),addEventListener(`message`,r=>{let i=r.data;r.source===o&&i&&i.channel===e&&i.session===t&&i.op===`ping`&&typeof i.id==`string`&&n({channel:e,session:t,op:`pong`,id:i.id},`*`)});let b=new Map,x=new Map,S=e=>{let t=Object.hasOwn(a,e)?a[e]:null;if(!t)throw new l(`${String(e).slice(0,160)} is not one of this view's files`);if(!b.has(e)){let n=atob(t.base64),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);b.set(e,r)}return b.get(e)};return Object.freeze({asset(e){return x.has(e)||x.set(e,URL.createObjectURL(new Blob([S(e)],{type:a[e].mediaType}))),x.get(e)},assetBytes(e){return S(e).slice().buffer}})}function GH(e,t,n,r){let i=Reflect.apply,a=Object.defineProperty,o=Reflect.deleteProperty,s=Error,c={create:Document.prototype.createElement,append:Node.prototype.appendChild,detach:Element.prototype.remove,text:Object.getOwnPropertyDescriptor(Node.prototype,`textContent`).set,nonce:Object.getOwnPropertyDescriptor(HTMLElement.prototype,`nonce`).set,connected:Object.getOwnPropertyDescriptor(Node.prototype,`isConnected`).get,listen:EventTarget.prototype.addEventListener,unlisten:EventTarget.prototype.removeEventListener},l=i(c.create,document,[`div`]);l.hidden=!0;let u=l.attachShadow({mode:`closed`});i(c.append,document.head||document.documentElement,[l]);let d=String(t).replace(/[^a-zA-Z0-9]/g,``),f=new Map,p=new Map,m=0,h=0,g=(e,t)=>{i(c.connected,l,[])||i(c.append,document.documentElement,[l]);let n=`__sm_code_${d}_${++h}`,f=!1,p=null;a(globalThis,n,{configurable:!0,value:()=>{f=!0}});let m=t=>{p||=t.error instanceof s?t.error:new s(String(t.message||`${e} stopped with an error.`))};i(c.listen,globalThis,[`error`,m,!0]);let g=i(c.create,document,[`script`]);try{i(c.nonce,g,[r]),i(c.text,g,[`${t}\n;globalThis.${n}();`]),i(c.append,u,[g])}finally{i(c.nonce,g,[``]),i(c.detach,g,[]),i(c.unlisten,globalThis,[`error`,m,!0]),o(globalThis,n)}if(!f)throw p||new s(`${e} could not run in this frame.`)},_=/^(?!\/)(?!.*\.\.)(?!.*\/\/)[A-Za-z0-9._/-]{1,160}\.js$/;return Object.freeze({load(r){if(typeof r!=`string`||!_.test(r))return Promise.reject(new s(`Name one of this view's code files, as in StillMade.loadCode('code/editor.js').`));if(f.has(r))return f.get(r);let i=new Promise((i,a)=>{let o=String(++m);p.set(o,{path:r,resolve:i,reject:a}),n({channel:e,session:t,op:`code`,id:o,path:r},`*`)});return f.set(r,i),i.catch(()=>f.delete(r)),i},result(e){let t=typeof e.id==`string`&&p.get(e.id);if(!t)return!1;if(p.delete(e.id),typeof e.source!=`string`)return t.reject(new s(String(e.error||`${t.path} could not be loaded.`).slice(0,1e3))),!0;try{g(t.path,e.source),t.resolve()}catch(e){t.reject(e)}return!0}})}Et();var KH=Object.freeze([`style`,`cssText`,`setProperty`,`removeProperty`,`insertRule`,`deleteRule`,`styleSheets`,`adoptedStyleSheets`,`animate`]),qH=Object.freeze(`--bg.--bg-elev-1.--bg-elev-2.--bg-inset.--fg.--fg-muted.--fg-subtle.--fg-on-accent.--border-tok.--border-strong.--divider.--hover-wash.--press-wash.--selection-bg.--selection-fg.--signal.--signal-dim.--signal-glow.--accent.--accent-hover.--accent-dim.--accent-glow.--accent-contrast.--bg-primary.--bg-secondary.--bg-tertiary.--bg-elevated.--bg-hover.--border.--border-light.--text-primary.--text-secondary.--text-muted.--success.--warning.--danger.--shadow.--shadow-lg.--shadow-1.--shadow-2.--editor-standout-bg.--editor-standout-fg.--scrim`.split(`.`)),JH=new Set(qH),YH=/^(?:color|background(?:-color|-image)?|(?:border|outline)(?:-(?:top|right|bottom|left|inline|block|inline-start|inline-end|block-start|block-end))?(?:-color)?|(?:box|text)-shadow|fill|stroke|caret-color|accent-color|text-decoration(?:-color)?|column-rule(?:-color)?|-webkit-text-fill-color)$/;function XH(e,{original:t=!1}={}){let n=e.replace(/\/\*[\s\S]*?\*\//g,``);B(!/[\\&]|@(?:property|supports|layer|keyframes)|(?:^|[;{])\s*(?:all|filter|backdrop-filter|mix-blend-mode)\s*:/i.test(n),`APPEARANCE`,`Use plain theme rules; CSS escapes, nesting, filters and color blending need adaptation.`);for(let e of n.matchAll(/(?:^|[;{])\s*([\w-]+)\s*:\s*([^;{}]+)/g)){let n=e[1].toLowerCase(),r=e[2].trim();if(t||(B(!JH.has(n),`APPEARANCE`,`Do not redefine StillMade appearance tokens.`),!YH.test(n)&&!n.endsWith(`-color`)&&![`border-image`,`border-image-source`,`-webkit-text-stroke`].includes(n)&&!n.startsWith(`--`)))continue;let i=r.replace(/var\(\s*(--[\w-]+)\s*\)/g,(e,t)=>(B(JH.has(t),`APPEARANCE`,`Use a StillMade semantic color token instead of ${t}.`),` token `)).replace(/!important/gi,``);if(n.startsWith(`--`)&&!/#|\b(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\s*\(/i.test(i))continue;let a=i.replace(/-?\d*\.?\d+(?:px|rem|em|vh|vw|%|deg|turn)?/g,``).replace(/[(),\s/.-]/g,` `).trim().split(/\s+/).filter(Boolean),o=new Set(`token.transparent.currentColor.currentcolor.inherit.initial.unset.none.auto.solid.dashed.dotted.double.inset.outset.thin.medium.thick.linear.radial.conic.repeating.gradient.to.top.right.bottom.left.circle.ellipse.at.center`.split(`.`));B(a.every(e=>o.has(e))&&!/#|\b(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color|var)\s*\(/i.test(i),`APPEARANCE`,`Use semantic theme tokens for ${n}; keep original colors in view.css and provide view.themedCss.`)}}function ZH(e,{appearance:t=e?.appearance??`host`}={}){if(!e)return!0;B([`host`,`original`].includes(t),`APPEARANCE`,`View appearance must be host or original.`);let n=t===`original`;B(!/\s(?:bgcolor|bordercolor|color|text|link|vlink|alink)\s*=/i.test(e.html),`APPEARANCE`,`Move presentational HTML colors into the original and themed stylesheets.`),XH(n?e.css??``:e.themedCss??e.css??``,{original:n}),n&&e.themedCss!==void 0&&XH(e.themedCss);for(let t of e.html.matchAll(/\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi))XH(t[1]??t[2]??t[3],{original:n});return B(!RegExp(`\\b(?:${KH.join(`|`)})\\b`).test(e.javascript||``),`APPEARANCE`,`Use CSS classes for interface changes; put themed colors in the stylesheet instead of setting styles in JavaScript.`),!0}var QH=`@font-face{font-family:"Hanken Grotesk";font-style:normal;font-weight:100 900;font-display:swap;src:url("/fonts/HankenGrotesk-Variable.ttf") format("truetype")}
1178
+ `;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return qz(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return Wz(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},fH.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},fH.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(Vz(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?Bz:Vz)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=qz(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},fH.readWord=function(){var e=this.readWord1(),t=$.name;return this.keywords.test(e)&&(t=LB[e]),this.finishToken(t,e)},mH=`8.18.0`,_V.acorn={Parser:_V,version:mH,defaultOptions:ZB,Position:YB,SourceLocation:XB,getLineInfo:Jz,Node:RV,TokenType:PB,tokTypes:$,keywordTypes:LB,TokContext:AV,tokContexts:jV,isIdentifierChar:Vz,isIdentifierStart:Bz,Token:dH,isNewLine:Wz,lineBreak:RB,lineBreakG:zB,nonASCIIwhitespace:BB}}));async function gH(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=await globalThis.crypto.subtle.digest(`SHA-256`,t);return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function _H(e,t,n){let r=e.files[t];B(r,`MODULE_FILE`,`${t} is not part of this module`);let i=n instanceof Uint8Array?n:new Uint8Array(n);return B(i.byteLength===r.bytes&&await gH(i)===r.sha256,`MODULE_FILE`,`${t} does not match its recorded digest`),i}var vH=o((()=>{Et(),Object.freeze({files:64,fileBytes:67108864,totalBytes:134217728,path:160,wallClockMs:12e4,maxWallClockMs:18e5,progressGraceMs:6e4,messageBytes:16777216,logEntries:500}),Object.freeze([`text/javascript`,`application/wasm`,`application/json`,`text/plain`,`image/png`,`image/jpeg`,`image/webp`,`font/woff2`,`application/octet-stream`]),Object.freeze([`input`,`signal`,`progress`,`log`,`asset`,`files.read`,`files.write`,`media.transform`,`actions.run`,`hosted.run`,`connections.call`,`net.fetch`,`net.connect`,`storage.info`,`storage.list`,`storage.get`,`storage.set`,`storage.remove`,`storage.putFile`,`storage.getFile`,`project.read`,`assets.create`,`assets.appendVersion`])}));function yH(e,{original:t=!1}={}){let n=e.replace(/\/\*[\s\S]*?\*\//g,``);B(!/[\\&]|@(?:property|supports|layer|keyframes)|(?:^|[;{])\s*(?:all|filter|backdrop-filter|mix-blend-mode)\s*:/i.test(n),`APPEARANCE`,`Use plain theme rules; CSS escapes, nesting, filters and color blending need adaptation.`);for(let e of n.matchAll(/(?:^|[;{])\s*([\w-]+)\s*:\s*([^;{}]+)/g)){let n=e[1].toLowerCase(),r=e[2].trim();if(t||(B(!wH.has(n),`APPEARANCE`,`Do not redefine StillMade appearance tokens.`),!TH.test(n)&&!n.endsWith(`-color`)&&![`border-image`,`border-image-source`,`-webkit-text-stroke`].includes(n)&&!n.startsWith(`--`)))continue;let i=r.replace(/var\(\s*(--[\w-]+)\s*\)/g,(e,t)=>(B(wH.has(t),`APPEARANCE`,`Use a StillMade semantic color token instead of ${t}.`),` token `)).replace(/!important/gi,``);if(n.startsWith(`--`)&&!/#|\b(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\s*\(/i.test(i))continue;let a=i.replace(/-?\d*\.?\d+(?:px|rem|em|vh|vw|%|deg|turn)?/g,``).replace(/[(),\s/.-]/g,` `).trim().split(/\s+/).filter(Boolean),o=new Set(`token.transparent.currentColor.currentcolor.inherit.initial.unset.none.auto.solid.dashed.dotted.double.inset.outset.thin.medium.thick.linear.radial.conic.repeating.gradient.to.top.right.bottom.left.circle.ellipse.at.center`.split(`.`));B(a.every(e=>o.has(e))&&!/#|\b(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color|var)\s*\(/i.test(i),`APPEARANCE`,`Use semantic theme tokens for ${n}; keep original colors in view.css and provide view.themedCss.`)}}function bH(e,{appearance:t=e?.appearance??`host`}={}){if(!e)return!0;if(B(xH.includes(t),`APPEARANCE`,`View appearance must be host, original or none.`),t===`none`){if(e.runtime===`frame`)return!0;let t=[...e.html.matchAll(/\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi)].map(e=>e[1]??e[2]??e[3]);for(let n of[e.css,e.themedCss,...t])B(!String(n??``).replace(/\/\*[\s\S]*?\*\//g,``).includes(`\\`),`APPEARANCE`,`A standard view's CSS cannot use escapes; write the characters themselves.`);return EH(e),!0}let n=t===`original`;B(!/\s(?:bgcolor|bordercolor|color|text|link|vlink|alink)\s*=/i.test(e.html),`APPEARANCE`,`Move presentational HTML colors into the original and themed stylesheets.`),yH(n?e.css??``:e.themedCss??e.css??``,{original:n}),n&&e.themedCss!==void 0&&yH(e.themedCss);for(let t of e.html.matchAll(/\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi))yH(t[1]??t[2]??t[3],{original:n});return EH(e),!0}var xH,SH,CH,wH,TH,EH,DH=o((()=>{Et(),xH=Object.freeze([`host`,`original`,`none`]),SH=Object.freeze([`style`,`cssText`,`setProperty`,`removeProperty`,`insertRule`,`deleteRule`,`styleSheets`,`adoptedStyleSheets`,`animate`]),CH=Object.freeze(`--bg.--bg-elev-1.--bg-elev-2.--bg-inset.--fg.--fg-muted.--fg-subtle.--fg-on-accent.--border-tok.--border-strong.--divider.--hover-wash.--press-wash.--selection-bg.--selection-fg.--signal.--signal-dim.--signal-glow.--accent.--accent-hover.--accent-dim.--accent-glow.--accent-contrast.--bg-primary.--bg-secondary.--bg-tertiary.--bg-elevated.--bg-hover.--border.--border-light.--text-primary.--text-secondary.--text-muted.--success.--warning.--danger.--shadow.--shadow-lg.--shadow-1.--shadow-2.--editor-standout-bg.--editor-standout-fg.--scrim`.split(`.`)),wH=new Set(CH),TH=/^(?:color|background(?:-color|-image)?|(?:border|outline)(?:-(?:top|right|bottom|left|inline|block|inline-start|inline-end|block-start|block-end))?(?:-color)?|(?:box|text)-shadow|fill|stroke|caret-color|accent-color|text-decoration(?:-color)?|column-rule(?:-color)?|-webkit-text-fill-color)$/,EH=e=>B(!RegExp(`\\b(?:${SH.join(`|`)})\\b`).test(e.javascript||``),`APPEARANCE`,`Use CSS classes for interface changes; put themed colors in the stylesheet instead of setting styles in JavaScript.`)}));function OH(e){return e?e.type===`Identifier`?[e.name]:e.type===`RestElement`?OH(e.argument):e.type===`AssignmentPattern`?OH(e.left):e.type===`ArrayPattern`?e.elements.flatMap(OH):e.type===`ObjectPattern`?e.properties.flatMap(e=>OH(e.type===`RestElement`?e.argument:e.value)):[]:[]}function kH(e){return e?.type===`MemberExpression`?kH(e.object):OH(e)}function AH(e){let t=[],n=new Map,r=new Map,i=new Set,a=new Map,o=[e];for(;o.length;){let e=o.pop();B(t.length<25e3,`VIEW`,`View JavaScript exceeds review complexity`),t.push(e);let s=e.type===`VariableDeclarator`?[e.id]:[`FunctionExpression`,`ArrowFunctionExpression`,`FunctionDeclaration`].includes(e.type)?[e.id,...e.params]:[`ClassDeclaration`,`ClassExpression`].includes(e.type)?[e.id]:e.type===`CatchClause`?[e.param]:[];for(let e of s)for(let t of OH(e))r.set(t,(r.get(t)||0)+1);if(e.type===`AssignmentExpression`)for(let t of kH(e.left))i.add(t);if(e.type===`UpdateExpression`||e.type===`UnaryExpression`&&e.operator===`delete`)for(let t of kH(e.argument))i.add(t);if(e.type===`CallExpression`&&e.callee?.type===`MemberExpression`&&!e.callee.computed&&e.callee.object?.type===`Identifier`&&e.callee.object.name===`StillMade`&&e.callee.property.name===`onInput`&&e.arguments.length===1){let t=e.arguments[0];[`ArrowFunctionExpression`,`FunctionExpression`].includes(t.type)&&t.params.length===1&&t.params[0].type===`Identifier`&&a.set(t,t.params[0].name)}for(let t of Object.values(e))for(let r of Array.isArray(t)?t:[t])r&&typeof r==`object`&&(n.set(r,e),o.push(r))}let s=new Set;for(let e of t){if(e.computed||UH(e)!==`prompt`)continue;if(e.type===`Property`&&n.get(e)?.type===`ObjectExpression`&&!e.shorthand&&!e.method&&e.kind===`init`){s.add(e);continue}if(e.type!==`MemberExpression`||e.object?.type!==`Identifier`||r.has(`StillMade`)||i.has(`StillMade`))continue;let t=e.object.name;if(r.get(t)!==1||i.has(t))continue;let o=n.get(e);for(;o?.type===`ChainExpression`;)o=n.get(o);if((![`CallExpression`,`NewExpression`,`TaggedTemplateExpression`].includes(o?.type)||o.callee!==e&&o.tag!==e&&o.callee?.type!==`ChainExpression`)&&!(o?.type===`MemberExpression`&&o.object===e&&[`call`,`apply`,`bind`].includes(UH(o)))){for(let r=n.get(e);r;r=n.get(r))if(a.get(r)===t){s.add(e);break}}}return{nodes:t,parents:n,allowed:s}}function jH(e){if(XH(e))return FH(e);B(vt(e)&&Object.keys(e).every(e=>[`html`,`css`,`javascript`,`themedCss`,`appearance`].includes(e)),`VIEW`,`View must contain only html, css, javascript, optional themedCss, and appearance`),B(e.appearance===void 0||xH.includes(e.appearance),`VIEW`,`View appearance must be host, original or none`);for(let t of[`html`,`css`,`javascript`,`themedCss`])(t===`html`||e[t]!==void 0)&&B(typeof e[t]==`string`&&RH(e[t])<=LH[`${t===`themedCss`?`css`:t}Bytes`]&&(t!==`html`||e[t].trim().length>0),`VIEW`,`View ${t} exceeds its size limit or is empty`);let t=e.html,n=/<\/?([a-z][a-z0-9-]*)(?:\s+[a-z_:][a-z0-9_:.-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'`=<>]+))?)*\s*\/?>/gi;B(!t.replace(n,``).includes(`<`),`VIEW`,`Use complete HTML control tags; declarations, comments, and malformed markup are unsupported`);for(let e of t.matchAll(n)){B(HH.has(e[1].toLowerCase()),`VIEW`,`Unsupported view element: ${e[1]}`);let t=e[0].slice(e[0].indexOf(e[1])+e[1].length).replace(/\/?>$/,``);for(let e of t.matchAll(/\s+([a-z_:][a-z0-9_:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'`=<>]+)))?/gi)){let t=e[1].toLowerCase(),n=e[2]??e[3]??e[4]??``;B(!t.startsWith(`on`)&&![`href`,`srcdoc`,`action`,`formaction`,`form`,`target`,`download`,`ping`,`autofocus`,`nonce`,`is`].includes(t)&&!t.includes(`:`),`VIEW`,`View markup contains an unsupported executable or navigation attribute`),[`src`,`poster`].includes(t)&&B(/^(?:data:|blob:)/i.test(n),`VIEW`,`View media must use data or blob URLs`)}}let r=[...t.matchAll(/\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi)].map(e=>e[1]??e[2]??e[3]);if(B(!/@import|@font-face|url\s*\(|expression\s*\(|-moz-binding|<\/style/i.test([e.css||``,e.themedCss||``,...r].join(`
1179
+ `)),`VIEW`,`View CSS cannot load resources or contain markup`),e.javascript){let t;try{t=CB(`"use strict";\n${e.javascript}`,{ecmaVersion:2022,sourceType:`script`})}catch(e){throw Object.assign(Error(`View JavaScript syntax: ${e.message}`),{code:`VIEW`})}let{nodes:n,parents:r,allowed:i}=AH(t),a=new Map;for(let e of n){B(!VH.includes(e.type),`VIEW`,`Unsupported view syntax: ${e.type}`),e.type===`FunctionExpression`&&B(!e.id,`VIEW`,`Named recursive functions are unsupported in view code`),e.type===`VariableDeclarator`&&e.id?.type===`Identifier`&&[`FunctionExpression`,`ArrowFunctionExpression`].includes(e.init?.type)&&a.set(e.id.name,e.init),e.type===`CallExpression`&&e.callee?.type===`Identifier`&&B(![`addEventListener`,`removeEventListener`,`dispatchEvent`].includes(e.callee.name),`VIEW`,`Attach events to declared controls, not the global frame`);let t=r.get(e),n=i.has(t)&&(t.property||t.key)===e;if(e.type===`Identifier`&&B(n||!zH.has(e.name),`VIEW`,`Unsupported view API: ${e.name}. View code cannot use this name, even for its own variable; rename it.`),[`MemberExpression`,`Property`,`MethodDefinition`].includes(e.type)&&!e.computed&&B(i.has(e)||!BH.has(UH(e)),`VIEW`,`Unsupported view property`),[`MemberExpression`,`Property`,`MethodDefinition`].includes(e.type)&&e.computed){let t=e.property||e.key;B(t?.type===`Literal`&&(typeof t.value==`string`||Number.isInteger(t.value))&&!BH.has(t.value),`VIEW`,`View property access must use a safe literal key`)}}B(a.size<=128,`VIEW`,`View contains too many helper functions`);let o=0,s=e=>{let t=new Set,n=[e];for(;n.length;){let e=n.pop();B(++o<=1e5,`VIEW`,`View helpers exceed review complexity`);let i=r.get(e),a=i?.type===`MemberExpression`&&!i.computed&&i.property===e||i?.type===`Property`&&!i.computed&&!i.shorthand&&i.key===e;e.type===`Identifier`&&!a&&t.add(e.name);for(let t of Object.values(e))Array.isArray(t)?n.push(...t.filter(e=>e&&typeof e==`object`)):t&&typeof t==`object`&&n.push(t)}return t},c=new Map([...a].map(([e,t])=>[e,[...s(t.body)].filter(e=>a.has(e))])),l=new Set,u=(e,t=new Set)=>{if(l.has(e))return;B(!t.has(e),`VIEW`,`Recursive UI functions are unsupported; move computation into the Block runtime`);let n=new Set([...t,e]);for(let t of c.get(e)||[])u(t,n);l.add(e)};for(let e of c.keys())u(e)}return!0}function MH(e,t){B(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t),`VIEW`,`Invalid interface guard`);let n=[CB(`"use strict";
1180
+ `+e,{ecmaVersion:2022})],r=[];for(;n.length;){let e=n.pop();[`ArrowFunctionExpression`,`FunctionExpression`,`FunctionDeclaration`].includes(e.type)&&(e.body.type===`BlockStatement`?r.push({position:e.body.start+1-14,text:`${t}();`}):(r.push({position:e.body.start-14,text:`(${t}(),`}),r.push({position:e.body.end-14,text:`)`})));for(let t of Object.values(e))Array.isArray(t)?n.push(...t.filter(e=>e&&typeof e==`object`)):t&&typeof t==`object`&&n.push(t)}for(let t of r.sort((e,t)=>t.position-e.position))e=e.slice(0,t.position)+t.text+e.slice(t.position);return e}function NH(e){try{return{ast:CB(e,{ecmaVersion:`latest`,sourceType:`script`})}}catch(t){let n=!1;try{CB(e,{ecmaVersion:`latest`,sourceType:`module`}),n=!0}catch{}throw Object.assign(Error(n?`Frame view JavaScript must be one classic script: bundle it as an IIFE (for example esbuild --format=iife).`:`View JavaScript syntax: ${t.message}`),{code:`VIEW`})}}function PH(e,t,n){B(typeof e==`string`&&RH(e)<=WH.codeFileBytes,`VIEW`,`Code file ${t} exceeds ${Math.round(WH.codeFileBytes/1048576)} MiB`);let r;try{r=NH(e).ast}catch(e){throw Object.assign(Error(`Code file ${t}: ${e.message}`),{code:`VIEW`})}let i=[r],a=0;for(;i.length;){let e=i.pop();B(++a<=4e6,`VIEW`,`Code file ${t} is too complex to compile`),B(e.type!==`ImportExpression`,`VIEW`,`Code file ${t} uses import(); load more code with StillMade.loadCode instead`);for(let t of Object.values(e))if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&i.push(e);else t&&typeof t==`object`&&typeof t.type==`string`&&i.push(t)}return n===void 0?e:IH(e,n)}function FH(e){B(Object.keys(e).every(e=>qH.includes(e)),`VIEW`,`A frame view contains runtime "frame", html and optional css, themedCss, javascript, appearance and files`),B(e.appearance===void 0||xH.includes(e.appearance),`VIEW`,`View appearance must be host, original or none`);for(let t of[`html`,`css`,`javascript`,`themedCss`]){if(t!==`html`&&e[t]===void 0)continue;let n=WH[`${t===`themedCss`?`css`:t}Bytes`];B(typeof e[t]==`string`&&RH(e[t])<=n&&(t!==`html`||e[t].trim().length>0),`VIEW`,`Frame view ${t} exceeds ${Math.round(n/1024)} KiB or is empty`)}B(!JH.test(e.html),`VIEW`,`Frame view markup cannot contain script, frame, object, embed, base, meta or link elements; put code in view.javascript and assets in view.files`);for(let t of[e.css,e.themedCss])t&&B(!/@import|url\s*\(\s*["']?\s*(?:https?:|\/\/)|<\/style/i.test(t),`VIEW`,`Frame view CSS cannot load remote resources; ship them in view.files`);if(e.javascript){let{ast:t}=NH(e.javascript),n=[t],r=0;for(;n.length;){let e=n.pop();B(++r<=4e6,`VIEW`,`Frame view JavaScript is too complex to compile`),B(e.type!==`ImportExpression`,`VIEW`,`Bundle every dependency into view.javascript; frame views cannot import code`);for(let t of Object.values(e))if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&n.push(e);else t&&typeof t==`object`&&typeof t.type==`string`&&n.push(t)}}if(e.files!==void 0){B(vt(e.files)&&e.files.schemaVersion===1&&vt(e.files.files)&&Object.keys(e.files).every(e=>[`schemaVersion`,`files`].includes(e)),`VIEW`,`view.files is {schemaVersion: 1, files: {path: {sha256, bytes, mediaType}}}`);let t=Object.entries(e.files.files),n=0,r=0,i=0;for(let[e,a]of t)B(YH.test(e)&&vt(a)&&Object.keys(a).every(e=>[`sha256`,`bytes`,`mediaType`].includes(e))&&/^[a-f0-9]{64}$/.test(a.sha256||``)&&Number.isSafeInteger(a.bytes)&&a.bytes>0&&KH.includes(a.mediaType),`VIEW`,`View asset ${e} needs a safe path, its SHA-256, size and a supported media type`),ZH(a)?(B(e.endsWith(`.js`),`VIEW`,`Code file ${e} needs a .js name`),B(a.bytes<=WH.codeFileBytes,`VIEW`,`Code file ${e} exceeds ${Math.round(WH.codeFileBytes/1048576)} MiB`),i++,r+=a.bytes):n+=a.bytes;B(t.length-i<=WH.assetFiles,`VIEW`,`A frame view ships at most ${WH.assetFiles} asset files`),B(n<=WH.assetBytes,`VIEW`,`Frame view assets exceed 8 MiB in total`),B(i<=WH.codeFiles,`VIEW`,`A frame view ships at most ${WH.codeFiles} code files`),B(r<=WH.codeBytes,`VIEW`,`Frame view code files exceed ${Math.round(WH.codeBytes/1048576)} MiB in total`)}return!0}function IH(e,t){B(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t),`VIEW`,`Invalid interface guard`);let{ast:n}=NH(e),r=[],i=[[n,0]],a=`${t}();`;for(;i.length;){let[e,n]=i.pop();[`ArrowFunctionExpression`,`FunctionExpression`,`FunctionDeclaration`].includes(e.type)&&(e.body.type===`BlockStatement`?r.push({position:e.body.start+1,text:a,depth:n,open:!0}):(r.push({position:e.body.start,text:`(${t}(),`,depth:n,open:!0}),r.push({position:e.body.end,text:`)`,depth:n,open:!1}))),[`WhileStatement`,`DoWhileStatement`,`ForStatement`,`ForInStatement`,`ForOfStatement`].includes(e.type)&&(e.body.type===`BlockStatement`?r.push({position:e.body.start+1,text:a,depth:n,open:!0}):(r.push({position:e.body.start,text:`{${a}`,depth:n,open:!0}),r.push({position:e.body.end,text:`}`,depth:n,open:!1})));for(let t of Object.values(e))if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&i.push([e,n+1]);else t&&typeof t==`object`&&typeof t.type==`string`&&i.push([t,n+1])}r.sort((e,t)=>t.position-e.position||(e.open===t.open?e.open?t.depth-e.depth:e.depth-t.depth:e.open?-1:1));let o=``,s=0;for(let t=r.length-1;t>=0;){let n=r[t].position,i=t;for(;i>0&&r[i-1].position===n;)i--;o+=e.slice(s,n);for(let e=t;e>=i;e--)o+=r[e].text;s=n,t=i-1}return o+e.slice(s)}var LH,RH,zH,BH,VH,HH,UH,WH,GH,KH,qH,JH,YH,XH,ZH,QH=o((()=>{hH(),Et(),vH(),DH(),LH=Object.freeze({htmlBytes:65536,cssBytes:32768,javascriptBytes:65536,messageBytes:4194304,runsPerMinute:120,imagePreviewsPerMinute:240,voicePreviewsPerMinute:30,allowanceCredits:2e3,imagePreviewMs:15e3,imagePreviewEdge:512,imagePreviewMaxEdge:2048}),RH=e=>new TextEncoder().encode(e).length,zH=new Set(`eval.Function.AsyncFunction.GeneratorFunction.require.importScripts.process.globalThis.window.self.top.parent.opener.frames.location.navigation.history.navigator.localStorage.sessionStorage.indexedDB.caches.cookieStore.fetch.XMLHttpRequest.WebSocket.EventSource.Worker.SharedWorker.ServiceWorker.WebAssembly.Deno.Bun.Reflect.Proxy.DOMParser.MutationObserver.postMessage.open.close.print.alert.confirm.prompt.setInterval.setTimeout.queueMicrotask.arguments.constructor.__proto__.prototype.__lookupGetter__.__lookupSetter__.__defineGetter__.__defineSetter__.getPrototypeOf.setPrototypeOf.getOwnPropertyDescriptor.getOwnPropertyDescriptors.getOwnPropertyNames.getOwnPropertySymbols.defineProperty.defineProperties.defaultView.ownerGlobal.contentWindow.contentDocument.cookie.domain.documentURI.URL.baseURI.referrer.write.writeln.innerHTML.outerHTML.insertAdjacentHTML.createElement.createElementNS.createContextualFragment.createRange.setAttribute.setAttributeNS.attributes.attributeStyleMap.adoptNode.importNode.execCommand.replaceChildren.setHTML.setHTMLUnsafe.parseHTML.parseHTMLUnsafe`.split(`.`));for(let e of[`showSaveFilePicker`,`showDirectoryPicker`,`saveAs`,`FileSystemWritableFileStream`,`createWritable`,`msSaveBlob`,`msSaveOrOpenBlob`,`download`])zH.add(e);BH=new Set([...zH,`assign`,`values`,`entries`,`fromEntries`]),Object.freeze([...zH]),Object.freeze([`assign`,`values`,`entries`,`fromEntries`]),VH=Object.freeze([`ImportExpression`,`ImportDeclaration`,`WithStatement`,`ThisExpression`,`MetaProperty`,`WhileStatement`,`DoWhileStatement`,`ForStatement`,`ForInStatement`,`ForOfStatement`,`FunctionDeclaration`]),HH=new Set(`div.section.article.header.footer.main.aside.nav.h1.h2.h3.h4.p.span.strong.em.i.small.br.hr.label.input.textarea.button.select.option.optgroup.fieldset.legend.output.progress.meter.ul.ol.li.dl.dt.dd.figure.figcaption.img.video.audio.source.canvas.table.thead.tbody.tfoot.tr.th.td.pre.code.details.summary`.split(`.`)),Object.freeze([...HH]),UH=e=>(e.property||e.key)?.name??(e.property||e.key)?.value,WH=Object.freeze({htmlBytes:262144,cssBytes:262144,javascriptBytes:4194304,assetFiles:32,assetBytes:8388608,codeFiles:64,codeFileBytes:4194304,codeBytes:16777216,mediaPreviews:24,taskMs:250,longTaskMs:1e3}),GH=`text/javascript`,KH=Object.freeze([`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/svg+xml`,`font/woff2`,`application/json`,`text/plain`,`audio/mpeg`,`audio/wav`,`video/mp4`,`application/octet-stream`,GH]),qH=[`runtime`,`html`,`css`,`themedCss`,`javascript`,`appearance`,`files`],JH=/<\s*(script|iframe|frame|frameset|object|embed|applet|base|meta|link|portal|noscript)\b/i,YH=/^(?!\/)(?!.*\.\.)(?!.*\/\/)[A-Za-z0-9._\/-]{1,160}$/,XH=e=>vt(e)&&e.runtime===`frame`,ZH=e=>e?.mediaType===GH}));QH();function $H(e,t,n,{guardName:r,taskMs:i,assets:a}){let o=parent,s=performance.now.bind(performance),c=setTimeout.bind(globalThis),l=Error,u=`This interface ran too long without pausing and was stopped. Move long work into a Worker or the Block runtime.`,d=!1,f=0,p=0,m=0,h=!1,g=s(),_=0,v=!1,y=()=>{d&&(_+=Math.max(0,p-f)),d=!1,m=0,h=!1;let r=s();r-g>=5e3&&(!v&&_/(r-g)>.7&&(v=!0,n({channel:e,session:t,op:`unresponsive`},`*`)),g=r,_=0)};Object.defineProperty(globalThis,r,{value:()=>{if(h)throw new l(u);if(!d){d=!0,f=p=s(),c(y,0);return}if(!(++m&255)&&(p=s(),p-f>i))throw h=!0,new l(u)},writable:!1,configurable:!1,enumerable:!1});try{globalThis.navigation?.addEventListener(`navigate`,e=>{e.cancelable&&e.preventDefault()})}catch{}addEventListener(`pagehide`,()=>n({channel:e,session:t,op:`navigated`},`*`)),addEventListener(`message`,r=>{let i=r.data;r.source===o&&i&&i.channel===e&&i.session===t&&i.op===`ping`&&typeof i.id==`string`&&n({channel:e,session:t,op:`pong`,id:i.id},`*`)});let b=new Map,x=new Map,S=e=>{let t=Object.hasOwn(a,e)?a[e]:null;if(!t)throw new l(`${String(e).slice(0,160)} is not one of this view's files`);if(!b.has(e)){let n=atob(t.base64),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);b.set(e,r)}return b.get(e)};return Object.freeze({asset(e){return x.has(e)||x.set(e,URL.createObjectURL(new Blob([S(e)],{type:a[e].mediaType}))),x.get(e)},assetBytes(e){return S(e).slice().buffer}})}function eU(e,t,n,r){let i=Reflect.apply,a=Object.defineProperty,o=Reflect.deleteProperty,s=Error,c={create:Document.prototype.createElement,append:Node.prototype.appendChild,detach:Element.prototype.remove,text:Object.getOwnPropertyDescriptor(Node.prototype,`textContent`).set,nonce:Object.getOwnPropertyDescriptor(HTMLElement.prototype,`nonce`).set,connected:Object.getOwnPropertyDescriptor(Node.prototype,`isConnected`).get,listen:EventTarget.prototype.addEventListener,unlisten:EventTarget.prototype.removeEventListener},l=i(c.create,document,[`div`]);l.hidden=!0;let u=l.attachShadow({mode:`closed`});i(c.append,document.head||document.documentElement,[l]);let d=String(t).replace(/[^a-zA-Z0-9]/g,``),f=new Map,p=new Map,m=0,h=0,g=(e,t)=>{i(c.connected,l,[])||i(c.append,document.documentElement,[l]);let n=`__sm_code_${d}_${++h}`,f=!1,p=null;a(globalThis,n,{configurable:!0,value:()=>{f=!0}});let m=t=>{p||=t.error instanceof s?t.error:new s(String(t.message||`${e} stopped with an error.`))};i(c.listen,globalThis,[`error`,m,!0]);let g=i(c.create,document,[`script`]);try{i(c.nonce,g,[r]),i(c.text,g,[`${t}\n;globalThis.${n}();`]),i(c.append,u,[g])}finally{i(c.nonce,g,[``]),i(c.detach,g,[]),i(c.unlisten,globalThis,[`error`,m,!0]),o(globalThis,n)}if(!f)throw p||new s(`${e} could not run in this frame.`)},_=/^(?!\/)(?!.*\.\.)(?!.*\/\/)[A-Za-z0-9._/-]{1,160}\.js$/;return Object.freeze({load(r){if(typeof r!=`string`||!_.test(r))return Promise.reject(new s(`Name one of this view's code files, as in StillMade.loadCode('code/editor.js').`));if(f.has(r))return f.get(r);let i=new Promise((i,a)=>{let o=String(++m);p.set(o,{path:r,resolve:i,reject:a}),n({channel:e,session:t,op:`code`,id:o,path:r},`*`)});return f.set(r,i),i.catch(()=>f.delete(r)),i},result(e){let t=typeof e.id==`string`&&p.get(e.id);if(!t)return!1;if(p.delete(e.id),typeof e.source!=`string`)return t.reject(new s(String(e.error||`${t.path} could not be loaded.`).slice(0,1e3))),!0;try{g(t.path,e.source),t.resolve()}catch(e){t.reject(e)}return!0}})}var tU=`@font-face{font-family:"Hanken Grotesk";font-style:normal;font-weight:100 900;font-display:swap;src:url("/fonts/HankenGrotesk-Variable.ttf") format("truetype")}
1181
1181
  @font-face{font-family:"Hanken Grotesk";font-style:italic;font-weight:100 900;font-display:swap;src:url("/fonts/HankenGrotesk-Italic-Variable.ttf") format("truetype")}
1182
1182
  /* Shared StillMade foundations. App and public listing pages use this file. */
1183
1183
  :root {
@@ -1450,7 +1450,7 @@ a[data-icon-action="true"] {flex:0 0 auto !important;align-self:center;} /* an i
1450
1450
  @media (pointer:coarse) {button[data-icon-action="true"],a[data-icon-action="true"] {min-width:44px !important;min-height:44px !important;}}
1451
1451
  /* What an icon-only control does, after a short hover (icon-tips.js). */
1452
1452
  .sm-icon-tip {position:fixed;z-index:2147483647;max-width:260px;padding:6px 10px;border-radius:var(--r-2,4px);background:var(--fg,#0a0a0a);color:var(--bg,#f6f0e0);font:400 12px/1.35 var(--font-ui,inherit);box-shadow:0 6px 20px #0002;pointer-events:none;white-space:normal}
1453
- `,$H=`/* Shared containment for creator-authored form rows, including installed pins.
1453
+ `,nU=`/* Shared containment for creator-authored form rows, including installed pins.
1454
1454
  This is host presentation only; it does not alter a Block's source or inputs. */
1455
1455
  :where(section, div, fieldset, form):has(> label + label) {
1456
1456
  flex-wrap: wrap;
@@ -1481,7 +1481,7 @@ label:has(> textarea) {
1481
1481
  min-block-size: 44px !important;
1482
1482
  block-size: 44px !important;
1483
1483
  }
1484
- `,eU=`/* StillMade Block kit: the default build-out for every Block interface.
1484
+ `,rU=`/* StillMade Block kit: the default build-out for every Block interface.
1485
1485
  The host injects this file into every Block view (standard and frame), after
1486
1486
  the theme and before the Block's own CSS, so any Block can use these classes
1487
1487
  without shipping styles. Every rule sits inside :where() so a Block's own
@@ -1837,7 +1837,7 @@ label:has(> textarea) {
1837
1837
  :where(.sm-stage) > :where(.sm-actions){position:static;order:-1;justify-self:end;max-width:100%;margin-bottom:var(--s-3,12px)}
1838
1838
  :where(.sm-stage) > :where(.sm-actions) > :where(.sm-primary){flex:0 1 auto}
1839
1839
  }
1840
- `;function tU(e){let t=e=>Number.isFinite(e)&&e>=0&&e<=1;return!e||typeof e!=`object`||Array.isArray(e)||!t(e.x)||!t(e.y)||e.id!==void 0&&(typeof e.id!=`string`||!e.id.length||e.id.length>160)?null:{x:e.x,y:e.y,...e.id===void 0?{}:{id:e.id}}}function nU(e,t,n){if(t=tU(t),!t)return null;let r,i;if(t.id!==void 0){let n=e.getElementById(t.id);if(!n)return null;let a=n.getBoundingClientRect();if(a.width<=0||a.height<=0)return null;r=a.left+a.width*t.x,i=a.top+a.height*t.y;let o=e.elementFromPoint?.(r,i);if(o&&!n.contains(o))return null}else r=t.x*e.documentElement.scrollWidth-n.scrollX,i=t.y*e.documentElement.scrollHeight-n.scrollY;return Number.isFinite(r)&&Number.isFinite(i)&&r>=0&&i>=0&&r<=n.width&&i<=n.height?{x:r,y:i}:null}function rU(e,t,n){let r=null,i=null,a=null,o=!1,s=e=>Math.max(0,Math.min(1,e)),c=[],l=null,u=null,d=null,f=new Map,p=()=>{if(u=null,o||!n)return;!l&&c.length&&(l=document.createElement(`div`),l.style.cssText=`position:fixed;inset:0;pointer-events:none;z-index:2147483647;overflow:hidden`,l.setAttribute(`aria-hidden`,`true`),l.setAttribute(`data-stillmade-host`,``),document.body.append(l));let e=new Set(c.map(e=>e.id));for(let[t,n]of f)e.has(t)||(n.remove(),f.delete(t));for(let e of c){let t=f.get(e.id);t||(t=document.createElement(`div`),t.style.cssText=`position:absolute;left:0;top:0;pointer-events:none;color:var(--fg);white-space:nowrap;font:12px var(--font-body,sans-serif)`,typeof matchMedia==`function`&&!matchMedia(`(prefers-reduced-motion: reduce)`).matches&&(t.style.transition=`transform 100ms linear`),l.append(t),f.set(e.id,t)),t.textContent=`↖ `+e.label;let r=n(document,e.anchor,{width:innerWidth,height:innerHeight,scrollX,scrollY});t.hidden=!r,r&&(t.style.transform=`translate(`+r.x+`px,`+r.y+`px)`)}},m=()=>{u===null&&(u=setTimeout(p,50))},h=()=>{if(i=null,!o&&r){if(r.visible&&a){let e=(document.elementFromPoint?.(a.x,a.y)||a.target)?.closest?.(`[id]`),t=e?.id,n=t&&t.length<=160?e.getBoundingClientRect():null;if(n?.width>0&&n?.height>0)r.anchor={id:t,x:s((a.x-n.left)/n.width),y:s((a.y-n.top)/n.height)};else{let e=document.documentElement;r.anchor={x:s((a.x+scrollX)/Math.max(1,e.scrollWidth)),y:s((a.y+scrollY)/Math.max(1,e.scrollHeight))}}}parent.postMessage({channel:e,session:t,op:`cursor`,cursor:r},`*`),r=null}},g=e=>{a={x:e.clientX,y:e.clientY,target:e.target},r={x:s(e.clientX/Math.max(1,innerWidth)),y:s(e.clientY/Math.max(1,innerHeight)),visible:!0},i===null&&(i=setTimeout(h,50))},_=()=>{a=null,r={x:0,y:0,visible:!1},i===null&&(i=setTimeout(h,0))},v=()=>{a&&g({clientX:a.x,clientY:a.y,target:a.target}),m()},y=n=>{let s=n.data;if(!(o||n.source!==parent||s?.channel!==e||s.session!==t)){if(s.op===`peer-cursors`){c=(Array.isArray(s.peers)?s.peers:[]).slice(0,50).filter(e=>e&&typeof e.id==`string`&&e.id.length<=200&&typeof e.label==`string`&&e.label.length<=120).map(e=>({id:e.id,label:e.label,anchor:e.anchor})),m();return}s.op===`dispose`&&(o=!0,clearTimeout(i),clearTimeout(u),d?.disconnect(),r=null,a=null,c=[],f.clear(),l?.remove(),removeEventListener(`pointermove`,g),removeEventListener(`scroll`,v,!0),removeEventListener(`resize`,v),removeEventListener(`blur`,_),removeEventListener(`message`,y),document.documentElement.removeEventListener(`pointerleave`,_))}};addEventListener(`pointermove`,g,{passive:!0}),addEventListener(`scroll`,v,{passive:!0,capture:!0}),addEventListener(`resize`,v,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,_),addEventListener(`blur`,_),addEventListener(`message`,y),typeof MutationObserver==`function`&&(d=new MutationObserver(e=>{c.length&&e.some(e=>!l?.contains(e.target))&&m()}),d.observe(document.body,{subtree:!0,childList:!0,attributes:!0,characterData:!0}))}function iU(e,t,n){let r=!1,i=0,a=null,o=!1,s=n=>parent.postMessage({channel:e,session:t,...n},`*`),c=e=>{let t=String(e.tagName||`element`).toLowerCase(),n=typeof e.id==`string`?e.id.replace(/[^\w-]/g,``).slice(0,60):``;if(n)return t+`#`+n;let r=typeof e.className==`string`?e.className.split(/\s+/).find(e=>/^[A-Za-z_][\w-]{0,59}$/.test(e)):``;return r?t+`.`+r:t},l=(e,t)=>{let n=document.elementFromPoint(e,t);return n&&n!==document.documentElement&&n!==document.body?n:null},u=()=>{if(i=0,!r||o)return;let e=a?l(a.x,a.y):null;if(!e){s({op:`pick-hover`,hover:null});return}let t=e.getBoundingClientRect(),n=getComputedStyle(e),u=e=>Math.max(0,parseFloat(n[`padding`+e])||0);s({op:`pick-hover`,hover:{rect:{x:t.left,y:t.top,width:t.width,height:t.height},padding:{top:u(`Top`),right:u(`Right`),bottom:u(`Bottom`),left:u(`Left`)},cursor:{x:a.x,y:a.y},selector:c(e)}})},d=()=>{r&&!i&&(i=requestAnimationFrame(u))},f=e=>{a={x:e.clientX,y:e.clientY},d()},p=()=>{a=null,d()},m=e=>{e.preventDefault(),e.stopImmediatePropagation()},h=e=>{m(e);let t=l(e.clientX,e.clientY)||e.target,r=null;try{r=n(t,document.body,{x:e.clientX,y:e.clientY})}catch{}y(),s(r?{op:`pick-result`,target:r}:{op:`pick-cancel`})},g=e=>{e.key===`Escape`&&(m(e),y(),s({op:`pick-cancel`}))},_=[`pointerdown`,`pointerup`,`mousedown`,`mouseup`,`dblclick`,`contextmenu`,`touchstart`,`touchend`],v=()=>{if(!(r||o)){r=!0,document.documentElement.setAttribute(`data-stillmade-pick`,``),addEventListener(`pointermove`,f,{passive:!0,capture:!0}),document.documentElement.addEventListener(`pointerleave`,p),addEventListener(`scroll`,d,{passive:!0,capture:!0});for(let e of _)addEventListener(e,m,!0);addEventListener(`click`,h,!0),addEventListener(`keydown`,g,!0)}},y=()=>{if(r){r=!1,cancelAnimationFrame(i),i=0,a=null,document.documentElement.removeAttribute(`data-stillmade-pick`),removeEventListener(`pointermove`,f,{capture:!0}),document.documentElement.removeEventListener(`pointerleave`,p),removeEventListener(`scroll`,d,{capture:!0});for(let e of _)removeEventListener(e,m,!0);removeEventListener(`click`,h,!0),removeEventListener(`keydown`,g,!0)}};addEventListener(`message`,n=>{let r=n.data;!o&&n.source===parent&&r&&r.channel===e&&r.session===t&&(r.op===`pick-start`?v():r.op===`pick-stop`?y():r.op===`dispose`&&(y(),o=!0))})}Object.freeze({start:`pick-start`,stop:`pick-stop`,hover:`pick-hover`,result:`pick-result`,cancel:`pick-cancel`});var aU=Object.freeze({control:`stillmade:view-pick`,hover:`stillmade:view-pick-hover`,result:`stillmade:view-pick-result`,cancel:`stillmade:view-pick-cancel`});function oU(e,t,n=null){let r=(e,t)=>{let n=String(e??``).replace(/\s+/g,` `).trim();return n.length>t?n.slice(0,t-1)+`…`:n},i=t=>typeof e.getAttribute==`function`&&e.getAttribute(t)||``,a=String(e.tagName||`element`).toLowerCase(),o=r(i(`role`),40).toLowerCase(),s=r(i(`type`),20).toLowerCase(),c=[`input`,`textarea`,`select`].includes(a),l=e.isContentEditable===!0,u=e=>{let t=String(e.tagName||`element`).toLowerCase(),n=t=>typeof e.getAttribute==`function`?String(e.getAttribute(t)||``).trim().toLowerCase():``,r=n(`role`),i=n(`type`),a=[`input`,`textarea`,`select`].includes(t);return r===`button`||t===`button`||t===`summary`||a&&[`button`,`submit`,`reset`,`image`].includes(i)?`button`:r===`link`||t===`a`?`link`:r===`checkbox`||r===`switch`||a&&i===`checkbox`?`checkbox`:r===`radio`||a&&i===`radio`?`choice`:r===`tab`?`tab`:t===`select`||r===`combobox`||r===`listbox`?`menu`:a&&i===`file`?`file-picker`:r===`slider`||a&&i===`range`?`slider`:t===`textarea`||e.isContentEditable===!0||a?`text-field`:t===`img`||t===`svg`||t===`picture`||t===`canvas`||r===`img`?`image`:t===`video`?`video`:t===`audio`?`audio`:/^h[1-6]$/.test(t)||r===`heading`?`heading`:t===`label`?`label`:t===`li`||r===`listitem`||r===`option`||r===`menuitem`?`list-item`:t===`ul`||t===`ol`||r===`list`||r===`menu`?`list`:t===`table`?`table`:[`p`,`span`,`small`,`strong`,`em`,`b`,`i`,`code`,`legend`,`figcaption`,`output`,`time`,`td`,`th`,`dt`,`dd`,`blockquote`,`pre`].includes(t)||r===`status`||!e.children?.length&&String(e.textContent||``).trim()?`text`:`area`},d=u(e),f=typeof e.parentElement?.closest==`function`?e.parentElement.closest(`button,a,[role="button"],[role="link"],[role="tab"],label,li,[role="listitem"],[role="option"],[role="menuitem"],details,fieldset,form,table`):null,p=f&&f!==t&&(typeof t?.contains!=`function`||t.contains(f))?{kind:u(f),name:r(f.getAttribute(`aria-label`)||f.innerText||f.textContent,120)}:null,m=r(e.innerText??e.textContent,240),h=typeof e.labels==`object`&&e.labels?.[0]?r(e.labels[0].textContent,120):``,g=i(`aria-labelledby`)?r(i(`aria-labelledby`).split(/\s+/).map(t=>e.ownerDocument?.getElementById?.(t)?.textContent||``).join(` `),120):``,_=r(i(`aria-label`)||g||h||i(`alt`)||i(`title`)||i(`placeholder`),120)||(d===`image`?``:m.slice(0,120)),v=[];(e.disabled===!0||i(`aria-disabled`)===`true`)&&v.push(`disabled`),(e.checked===!0||i(`aria-checked`)===`true`||i(`aria-pressed`)===`true`)&&v.push(d===`button`?`pressed`:`checked`),(i(`aria-selected`)===`true`||i(`aria-current`))&&v.push(`selected`),(e.open===!0||i(`aria-expanded`)===`true`)&&v.push(`open`),i(`aria-expanded`)===`false`&&v.push(`closed`),(e.required===!0||i(`aria-required`)===`true`)&&v.push(`required`),e.readOnly===!0&&v.push(`read only`);let y=``;a===`select`?y=r(e.selectedOptions?.[0]?.textContent??e.value,120):c&&![`password`,`file`,`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`hidden`].includes(s)?y=r(e.value,120):l&&(y=m.slice(0,120));let b=typeof e.className==`string`?e.className.split(/\s+/).filter(e=>/^[A-Za-z_][\w-]{0,59}$/.test(e)).slice(0,4):[],x={};for(let t of Array.from(e.attributes||[])){if(Object.keys(x).length>=6)break;t.name.startsWith(`data-`)&&t.name.length<=60&&!t.name.startsWith(`data-stillmade`)&&(x[t.name.slice(5)]=r(t.value,80))}let S=(e,t)=>{let n=String(e.tagName||`element`).toLowerCase(),r=typeof e.id==`string`?e.id.replace(/[^\w-]/g,``).slice(0,60):``;if(r)return n+`#`+r;let i=typeof e.className==`string`?e.className.split(/\s+/).filter(e=>/^[A-Za-z_][\w-]{0,59}$/.test(e)).slice(0,t):[];if(i.length&&(n+=`.`+i.join(`.`)),t===1)return n;let a=e.parentElement?Array.from(e.parentElement.children).filter(t=>t.tagName===e.tagName):[];return a.length>1&&(n+=`:nth-of-type(${a.indexOf(e)+1})`),n},C=[],w=e;for(;w&&w!==t&&C.length<6;)C.unshift(S(w,2)),w=w.parentElement;let T=typeof t?.getBoundingClientRect==`function`?t.getBoundingClientRect():{left:0,top:0,width:0,height:0},E=typeof e.getBoundingClientRect==`function`?e.getBoundingClientRect():{left:0,top:0,width:0,height:0},D=(e,t)=>Math.max(0,Math.min(1,t>0?e/t:0)),O={x:D(E.left-T.left,T.width),y:D(E.top-T.top,T.height),width:D(E.width,T.width),height:D(E.height,T.height)},k=O.x+O.width/2,A=O.y+O.height/2,j=`${A<.34?`top`:A>.66?`bottom`:`middle`} ${k<.34?`left`:k>.66?`right`:`center`}`,M=``;if(d!==`heading`&&typeof t?.querySelectorAll==`function`){for(let n of t.querySelectorAll(`h1,h2,h3,h4,h5,h6,[role="heading"]`))if(!n.contains(e)){if(n.compareDocumentPosition(e)&4)M=r(n.textContent,80);else break}}let N=e.parentElement&&e.parentElement!==t?r(e.parentElement.innerText??e.parentElement.textContent,600):``,P=e=>({img:`image`,video:`video`,audio:`audio`,canvas:`canvas`})[String(e?.tagName||``).toLowerCase()]||``,F=e=>{let t=typeof e.getBoundingClientRect==`function`?e.getBoundingClientRect():null;return P(e)===`audio`||!t||t.width>=24&&t.height>=24},I=e=>typeof e?.querySelectorAll==`function`?Array.from(e.querySelectorAll(`img,video,audio,canvas`)).filter(F):[],ee=P(e)?e:null;if(!ee){let t=I(e);t.length===1&&(ee=t[0])}if(!ee){let r=n&&Number.isFinite(n.x)?n:{x:E.left+E.width/2,y:E.top+E.height/2},i=e.parentElement;for(let e=0;i&&i!==t&&e<3;e++,i=i.parentElement){let e=I(i);if(e.length>1)break;if(e.length===1){let t=e[0].getBoundingClientRect();r.x>=t.left&&r.x<=t.right&&r.y>=t.top&&r.y<=t.bottom&&(ee=e[0]);break}}}let te=``;if(!ee&&!m)try{let t=/url\(["']?([^"')]+)["']?\)/.exec((e.ownerDocument?.defaultView||globalThis).getComputedStyle(e).backgroundImage||``);t&&(te=t[1])}catch{}let L=null;if(ee||te){let t=ee,n=t?P(t):`image`,i=String(t?t.currentSrc||t.src||t.getAttribute?.(`src`)||t.querySelector?.(`source`)?.getAttribute(`src`)||``:te),a=/^(https?:|blob:|sm-media:)/i.test(i)&&i.length<=2e3?i:``,o=``;if(/^https?:/i.test(a))try{let e=decodeURIComponent(new URL(a).pathname.split(`/`).pop()||``);/\.[a-z0-9]{2,5}$/i.test(e)&&(o=r(e,80))}catch{}let s=Math.round(t?.naturalWidth||t?.videoWidth||(n===`canvas`?t.width:0)||0),c=Math.round(t?.naturalHeight||t?.videoHeight||(n===`canvas`?t.height:0)||0),l=e=>Number.isFinite(e)&&e>=0?Math.round(e*10)/10:null,u=n===`video`||n===`audio`;L={kind:n,...a?{src:a}:{},...o?{file:o}:{},...s&&c?{natural:{width:s,height:c}}:{},...u&&l(t.duration)!==null?{duration:l(t.duration)}:{},...u?{time:l(t.currentTime)??0,paused:t.paused!==!1}:{},...t&&t!==e?{around:!0}:{},...t&&t!==e&&r(t.getAttribute?.(`alt`)||t.getAttribute?.(`aria-label`)||t.getAttribute?.(`title`),120)?{name:r(t.getAttribute(`alt`)||t.getAttribute(`aria-label`)||t.getAttribute(`title`),120)}:{}}}let R=t=>typeof e.closest==`function`?e.closest(t):null,ne=R(`[data-agent-input-key]`),re=R(`[data-agent-output-key]`),ie=R(`[data-agent-media-asset]`),ae=R(`.react-flow__node[data-id]`),oe=ne?{key:r(ne.getAttribute(`data-agent-input-key`),80),name:r(ne.querySelector(`label,h3,strong,legend`)?.textContent,80)||(e=>{let t=e;for(let e=0;t&&e<5;e++){let e=Array.from(t.children||[]).find(e=>String(e.textContent||``).trim());if(!e||(t=e,!e.children?.length))break}return t&&t!==e?r(t.textContent,80):``})(ne)}:null,se=re?{key:r(re.getAttribute(`data-agent-output-key`),80),...r(re.querySelector(`h3`)?.textContent,80)?{name:r(re.querySelector(`h3`).textContent,80)}:{}}:null,ce=ie?{assetId:r(ie.getAttribute(`data-agent-media-asset`),120),...ie.getAttribute(`data-agent-media-version`)?{versionId:r(ie.getAttribute(`data-agent-media-version`),120)}:{},...ie.getAttribute(`data-agent-media-kind`)?{kind:r(ie.getAttribute(`data-agent-media-kind`),20)}:{},...ie.hasAttribute(`data-agent-media-local`)?{local:!0}:{}}:null,le=r(ae?.getAttribute(`data-id`),120),ue=ae&&typeof ae.className==`string`&&(/(?:^|\s)react-flow__node-([\w-]{1,60})/.exec(ae.className)||[])[1]||``,de=r(R(`[data-stillmade-share]`)?.getAttribute(`data-stillmade-share`),80),fe=R(`li,[role="listitem"],[role="option"],[role="row"],[role="gridcell"]`),pe=fe?.parentElement?Array.from(fe.parentElement.children).filter(e=>e.tagName===fe.tagName&&(e.getAttribute(`role`)||``)===(fe.getAttribute(`role`)||``)):[],me=fe&&fe!==t&&pe.length>1?{index:pe.indexOf(fe)+1,count:pe.length}:null,he=c&&[`range`,`number`].includes(s)&&(i(`min`)||i(`max`))?{...i(`min`)?{min:r(i(`min`),20)}:{},...i(`max`)?{max:r(i(`max`),20)}:{}}:null;return{kind:d,tag:a,...o?{role:o}:{},name:_,text:m,...y?{value:y}:{},state:v,...p?{within:p}:{},selector:S(e,1),path:C.join(` > `).slice(0,300)||`view`,...b.length?{classes:b}:{},...Object.keys(x).length?{data:x}:{},size:{width:Math.round(E.width),height:Math.round(E.height)},region:O,place:j,...M?{heading:M}:{},...N?{around:N}:{},...L?{media:L}:{},...oe?.key?{setting:oe}:{},...se?.key?{output:se}:{},...ce?.assetId?{mediaRef:ce}:{},...le?{nodeId:le,...ue?{nodeType:ue}:{}}:{},...de?{shared:de}:{},...me?{position:me}:{},...he?{bounds:he}:{},...n&&Number.isFinite(n.x)&&Number.isFinite(n.y)?{point:{x:D(n.x-T.left,T.width),y:D(n.y-T.top,T.height)}}:{}}}var sU={button:`Button`,link:`Link`,checkbox:`Checkbox`,choice:`Choice`,tab:`Tab`,menu:`Menu`,"file-picker":`File picker`,slider:`Slider`,"text-field":`Text field`,image:`Image`,video:`Video`,audio:`Audio`,heading:`Heading`,label:`Label`,"list-item":`List item`,list:`List`,table:`Table`,text:`Text`,area:`Area`},cU=(e,t=1e5)=>Number.isFinite(e)&&e>=-t&&e<=t,lU=(e,t)=>typeof e==`string`&&e.length<=t;function uU(e){if(e===null||!e||typeof e!=`object`||!e.rect||!e.padding||!e.cursor)return null;let{rect:t,padding:n,cursor:r}=e;return![`x`,`y`,`width`,`height`].every(e=>cU(t[e]))||t.width<0||t.height<0||![`top`,`right`,`bottom`,`left`].every(e=>cU(n[e],1e4)&&n[e]>=0)||!cU(r.x)||!cU(r.y)?null:{rect:{x:t.x,y:t.y,width:t.width,height:t.height},padding:{top:n.top,right:n.right,bottom:n.bottom,left:n.left},cursor:{x:r.x,y:r.y},selector:lU(e.selector,160)?e.selector:`element`}}function dU(e){if(!e||typeof e!=`object`||Array.isArray(e)||!lU(e.kind,20)||!sU[e.kind]||!lU(e.tag,40)||!lU(e.name,120)||!lU(e.text,240)||!lU(e.selector,160)||!lU(e.path,300))return null;let t=e=>e&&typeof e==`object`&&[`x`,`y`].every(t=>Number.isFinite(e[t])&&e[t]>=0&&e[t]<=1);if(!e.size||!cU(e.size.width)||!cU(e.size.height)||!t(e.region)||!Number.isFinite(e.region.width)||!Number.isFinite(e.region.height))return null;let n={kind:e.kind,tag:e.tag,name:e.name,text:e.text,selector:e.selector,path:e.path,size:{width:Math.round(e.size.width),height:Math.round(e.size.height)},region:{x:e.region.x,y:e.region.y,width:Math.max(0,Math.min(1,e.region.width)),height:Math.max(0,Math.min(1,e.region.height))},place:lU(e.place,20)?e.place:`middle center`,state:Array.isArray(e.state)?e.state.filter(e=>lU(e,20)).slice(0,8):[]};if(lU(e.role,40)&&e.role&&(n.role=e.role),lU(e.value,120)&&e.value&&(n.value=e.value),lU(e.heading,80)&&e.heading&&(n.heading=e.heading),lU(e.around,600)&&e.around&&(n.around=e.around),e.within&&typeof e.within==`object`&&lU(e.within.kind,20)&&sU[e.within.kind]&&lU(e.within.name,120)&&e.within.name&&(n.within={kind:e.within.kind,name:e.within.name}),Array.isArray(e.classes)){let t=e.classes.filter(e=>lU(e,60)).slice(0,4);t.length&&(n.classes=t)}if(e.data&&typeof e.data==`object`&&!Array.isArray(e.data)){let t={};for(let[n,r]of Object.entries(e.data).slice(0,6))lU(n,60)&&lU(r,80)&&(t[n]=r);Object.keys(t).length&&(n.data=t)}if(t(e.point)&&(n.point={x:e.point.x,y:e.point.y}),e.media&&typeof e.media==`object`&&[`image`,`video`,`audio`,`canvas`].includes(e.media.kind)){let t=e.media,r=e=>Number.isFinite(e)&&e>=0&&e<=604800;n.media={kind:t.kind},lU(t.src,2e3)&&/^(https?:|blob:|sm-media:)/i.test(t.src)&&(n.media.src=t.src),lU(t.file,80)&&t.file&&(n.media.file=t.file),lU(t.name,120)&&t.name&&(n.media.name=t.name),t.natural&&cU(t.natural.width)&&cU(t.natural.height)&&t.natural.width>0&&t.natural.height>0&&(n.media.natural={width:Math.round(t.natural.width),height:Math.round(t.natural.height)}),r(t.duration)&&(n.media.duration=t.duration),[`video`,`audio`].includes(t.kind)&&(n.media.time=r(t.time)?t.time:0,n.media.paused=t.paused!==!1),t.around===!0&&(n.media.around=!0)}if(e.position&&Number.isSafeInteger(e.position.index)&&Number.isSafeInteger(e.position.count)&&e.position.index>=1&&e.position.index<=e.position.count&&e.position.count<=1e4&&(n.position={index:e.position.index,count:e.position.count}),e.bounds&&typeof e.bounds==`object`){let t={};lU(e.bounds.min,20)&&(t.min=e.bounds.min),lU(e.bounds.max,20)&&(t.max=e.bounds.max),Object.keys(t).length&&(n.bounds=t)}return lU(e.shared,80)&&/^[\w.:-]{1,80}$/.test(e.shared)&&(n.shared=e.shared),n}function fU(e,t){let n=r=>{let i=r.data;r.source===parent&&i&&i.channel===e&&i.session===t&&(i.op===`theme`&&[`light`,`dark`,`white`].includes(i.mode)&&(document.documentElement.dataset.mode=i.mode),i.op===`dispose`&&removeEventListener(`message`,n))};addEventListener(`message`,n)}function pU(e,t){let n=parent,r=null,i=0,a=!1,o=()=>{if(r=null,a||document.documentElement.hasAttribute(`data-stillmade-stage`))return;let o=Math.ceil(Math.max(document.body.scrollHeight,document.body.getBoundingClientRect().height));o!==i&&(i=o,n.postMessage({channel:e,session:t,op:`content-size`,height:o},`*`))},s=()=>{!a&&r===null&&(r=setTimeout(o,100))},c=new ResizeObserver(s);c.observe(document.body);let l=i=>{i.source===n&&i.data?.channel===e&&i.data?.session===t&&i.data?.op===`dispose`&&(a=!0,clearTimeout(r),c.disconnect(),removeEventListener(`message`,l))};addEventListener(`message`,l),s()}var mU=.8,hU=1.6,gU=.1;function _U({width:e,available:t,heightAt:n,mode:r=`auto`}){let i=[860,520];if(!(e>=600))return 1;let a=e/(i.find(t=>e>=t)||e),o=e/520;if(typeof r==`number`&&Number.isFinite(r))return Math.round(Math.min(Math.max(r,.8),1.6,o)*100)/100;let s=Math.min(1.5,a);if(!(t>0)||s<=1.01||n(1)>t)return 1;let c=Math.floor(s*20)/20;if(n(c)<=t)return c;let l=1,u=s;for(let e=0;e<7;e++){let e=(l+u)/2;n(e)<=t?l=e:u=e}let d=Math.floor(l*20)/20;for(;d>1&&n(d)>t;)d=Math.round((d-.05)*100)/100;return Math.max(1,d)}function vU({canCenter:e=!1,width:t=0,height:n=0,frame:r=t,own:i=!1,padding:a=0,clipped:o=!1,boxes:s=[],drawn:c=[],flows:l=[],kept:u=null}){let d=t*n,f=(e,r)=>{let i=Math.min(e.left+e.width,t)-Math.max(e.left,0),a=Math.min(e.top+e.height,n)-Math.max(e.top,0);return i>0&&a>0&&i*a>=r*d};if(i||a<1||o)return{layout:`own`};if(!(d>0))return{layout:`none`};if(s.some(e=>e.fixed&&f(e,.5)||Math.abs(e.height-n)<=1||e.scrolls&&f(e,.5)||e.touchNone&&f(e,.4))||c.some(e=>f(e,.4)||e.touchNone&&e.width>=300&&e.height>=200))return{layout:`own`};if(!e||r<600)return{layout:`none`};for(let e=1;e<=l.length;e++){let t=l[e-1],n=t.items;if(t.loose||!t.block||!n.length||n.some(e=>e.inline))return{layout:`none`};if(u?.depth===e&&u.frame===r)return{layout:`center`,depth:e};let i=Math.min(...n.map(e=>e.left)),a=Math.max(...n.map(e=>e.right)),o=t.right-t.left;if(Math.abs(i-t.left)>1)return{layout:`none`};if(n.every(e=>Math.abs(e.left-i)<=1&&Math.abs(e.right-a)<=1)&&o-(a-i)>=Math.max(48,o*.1))return{layout:`center`,depth:e};if(n.length!==1)return{layout:`none`}}return{layout:`none`}}function yU(e,t,n,r,i,a){let o=parent,s=document.documentElement,c=typeof CSS<`u`&&CSS.supports?.(`zoom`,`2`)===!0&&`currentCSSZoom`in Element.prototype,l=r===`auto`||typeof r==`number`?r:`auto`,u=null,d=1,f=0,p=null,m=!1,h=!1,g=null,_=[],v=new Set,y=document.querySelector(`[data-stillmade-layout="own"]`)?`own`:`none`,b=()=>o.postMessage({channel:e,session:t,op:`zoom-state`,supported:c&&y!==`own`,zoom:d,auto:l===`auto`},`*`),x=e=>(s.style.zoom=e===1?``:String(e),Math.ceil(document.body.getBoundingClientRect().height)),S=()=>{let e=document.body,t=e=>getComputedStyle(e),n=(e,t)=>parseFloat(e[t])||0,r=t(e),i=[],o=[],l=[],u=c&&s.currentCSSZoom>0?s.currentCSSZoom:1,d=e=>{let t=e.getBoundingClientRect();return{left:t.left/u,top:t.top/u,width:t.width/u,height:t.height/u,right:t.right/u}},f=e,p=r;_=[e];for(let e=0;e<3&&f;e++){let r=[],a=[],s=!1;for(let e of[...f.children].slice(0,200)){if(/^(?:SCRIPT|STYLE|TEMPLATE|LINK|META|NOSCRIPT)$/.test(e.tagName)||e.hasAttribute(`data-stillmade-host`))continue;let n=t(e);if(n.display===`none`||n.display===`contents`)continue;let o=d(e),c=n.position===`fixed`||n.position===`absolute`,l=t=>!/^(?:TEXTAREA|SELECT|INPUT)$/.test(e.tagName)&&/auto|scroll/.test(n[`overflow`+t])&&(t===`Y`?e.scrollHeight>e.clientHeight+1:e.scrollWidth>e.clientWidth+1);i.push({left:o.left,top:o.top,width:o.width,height:o.height,fixed:c,scrolls:l(`Y`)||l(`X`),touchNone:n.touchAction===`none`}),_.push(e),c||/left|right|start|end/.test(n.float)?o.width>=2&&o.height>=2&&(s=!0):o.width>0&&(r.push({left:o.left,right:o.right,inline:n.display.startsWith(`inline`)}),a.push(e))}if(e<2){let e=d(f);o.push({block:[`block`,`flow-root`].includes(p.display),left:e.left+n(p,`borderLeftWidth`)+n(p,`paddingLeft`),right:e.right-n(p,`borderRightWidth`)-n(p,`paddingRight`),items:r,loose:s}),l.push(a)}f=a.length===1?a[0]:null,p=f&&t(f)}if(a===!0&&innerWidth>=600){let n=e.getElementsByTagName(`*`);if(n.length>5e3)for(let e of o)e.loose=!0;else for(let e of n){let n=t(e).position;if(n!==`absolute`&&n!==`fixed`)continue;let r=e.getBoundingClientRect(),i=n===`fixed`?null:e.offsetParent;r.width<2||r.height<2||e.closest(`[data-stillmade-host]`)||o.forEach((t,n)=>{l[n].some(t=>t.contains(e)&&!(i&&t.contains(i)))&&(t.loose=!0)})}}let m=[...document.querySelectorAll(`canvas,svg`)].slice(0,100).map(e=>{let n=d(e);return _.push(e),{left:n.left,top:n.top,width:n.width,height:n.height,touchNone:n.width>=300&&n.height>=200&&t(e).touchAction===`none`}});return{canCenter:a===!0,width:innerWidth/u,height:innerHeight/u,frame:innerWidth,own:!!document.querySelector(`[data-stillmade-layout="own"]`),padding:n(r,`paddingLeft`),clipped:[t(s),r].some(e=>/hidden|clip/.test(e.overflowY)),boxes:i,drawn:m,flows:o,kept:g}},C=()=>{if(!D)return;let e=new Set(_);for(let t of v)e.has(t)||D.unobserve(t);for(let t of e)v.has(t)||D.observe(t);v=e},w=()=>{let e=y;s.removeAttribute(`data-stillmade-center`);let t=S(),n=i(t);y=n.layout,g=y===`center`?{depth:n.depth,frame:t.frame}:null,y===`center`&&s.setAttribute(`data-stillmade-center`,String(n.depth)),y===`own`&&d!==1&&(d=1,s.style.zoom=``,f=Date.now()+400),j(y!==`own`),C(),e===`own`!=(y===`own`)&&b()},T=e=>{if(p=null,h||!document.body||s.hasAttribute(`data-stillmade-stage`)||(w(),!c||y===`own`))return;let t=innerWidth,r=u?.height>0?u.height:innerHeight,i=d;if(!e&&l===`auto`&&x(d)<=r+2){s.style.zoom=d===1?``:String(d);return}d=n({width:t,available:r,heightAt:x,mode:l}),s.style.zoom=d===1?``:String(d),f=Date.now()+400,d!==i&&b()},E=(e,t)=>{h||(m||=e,clearTimeout(p),p=setTimeout(()=>{let e=m;m=!1,T(e)},t??(m?120:250)))},D=typeof ResizeObserver==`function`?new ResizeObserver(()=>E(!1,Math.max(0,f-Date.now())+250)):null,O=n=>{let r=n.data;n.source===o&&r&&r.channel===e&&r.session===t&&(r.op===`zoom-mode`&&(r.mode===`auto`||Number.isFinite(r.mode))&&(l=r.mode,E(!0)),r.op===`zoom-space`&&Number.isFinite(r.height)&&r.height>0&&(u={height:Math.min(2e4,r.height)},s.style.setProperty(`--stillmade-space-height`,`${u.height}px`),E(!0)),r.op===`dispose`&&(h=!0,clearTimeout(p),D?.disconnect(),removeEventListener(`resize`,k),j(!1),removeEventListener(`message`,O),s.style.zoom=``,s.removeAttribute(`data-stillmade-center`)))},k=()=>E(!0),A=n=>{if(!c||!(n.ctrlKey||n.metaKey)||n.altKey)return;let r=n.key===`+`||n.key===`=`?`bigger`:n.key===`-`||n.key===`_`?`smaller`:n.key===`0`?`auto`:null;r&&(n.preventDefault(),o.postMessage({channel:e,session:t,op:`zoom-key`,step:r},`*`))},j=e=>{e?addEventListener(`keydown`,A,!0):removeEventListener(`keydown`,A,!0)};addEventListener(`message`,O),addEventListener(`resize`,k),j(y!==`own`);let M=()=>{document.body&&D&&(D.observe(document.body),v.add(document.body)),b(),E(!0)};document.readyState===`loading`?addEventListener(`DOMContentLoaded`,M,{once:!0}):M()}function bU(e,t,n,r,{minted:i=()=>!1,filming:a=!1}={}){let o=parent,s=document,c=s.documentElement,l=new Map,u=[],d=null,f=null,p=0,m=!1,h=null,g=null,_=null,v=n=>o.postMessage({channel:e,session:t,...n},`*`),y=typeof requestAnimationFrame==`function`?e=>requestAnimationFrame(e):e=>setTimeout(e,16),b=typeof cancelAnimationFrame==`function`?e=>cancelAnimationFrame(e):e=>clearTimeout(e),x=(e,t,n,r)=>{e.addEventListener(t,n,r),u.push([e,t,n,r])},S=()=>d&&d.currentCSSZoom>0?d.currentCSSZoom:1,C=()=>{if(!d){d=s.createElement(`div`),d.setAttribute(`data-stillmade-host`,``),d.setAttribute(`data-stillmade-media`,``),d.setAttribute(`data-mode`,`dark`),d.style.cssText=`position:fixed;inset:0;margin:0;padding:0;border:0;background:none;pointer-events:none;overflow:hidden;overflow:clip;z-index:2147483646`+(a?`;display:none`:``),f=d.attachShadow({mode:`closed`});let e=s.createElement(`style`);e.textContent=r+`.sm-player{position:absolute;left:0;top:0;display:block;max-width:none;background:transparent;contain:layout style}.sm-player[hidden],.sm-frame-photo[hidden]{display:none!important}.sm-player:not([data-live]):not([data-stage]){pointer-events:none}.sm-player[data-live],.sm-player[data-stage],.sm-viewer{pointer-events:auto}.sm-player[data-stage]{position:fixed;inset:0;transform:none!important;width:auto!important;height:auto!important;background:transparent!important}.sm-player[data-stage]::backdrop{background:transparent}.sm-frame-photo{position:absolute;left:0;top:0;pointer-events:none}.sm-frame-photo>.sm-expand-btn{transition:opacity var(--sm-out) var(--sm-ease)}`,f.append(e)}return d.isConnected||s.body.append(d),f},w=typeof ResizeObserver==`function`?new ResizeObserver(()=>E()):null,T=()=>{if(p=0,m)return;let e=S(),t=window.innerWidth,n=window.innerHeight;for(let r of[...l.values()]){let{video:i,box:a}=r;if(!i.isConnected){A(r);continue}if(r===h)continue;i.hasAttribute(`controls`)&&i.removeAttribute(`controls`);let o=i.getBoundingClientRect(),s=!h&&!g&&o.width>=1&&o.height>=1&&o.left+o.width>0&&o.top+o.height>0&&o.left<t&&o.top<n,c=s?[o.left,o.top,o.width,o.height].map(t=>Math.round(t/e*100)/100).join(`,`):``;c!==r.key&&(r.key=c,a.hidden=!s,a.hasAttribute(`data-live`)&&!D(a)&&a.removeAttribute(`data-live`),s&&(a.style.transform=`translate(`+o.left/e+`px,`+o.top/e+`px)`,a.style.width=o.width/e+`px`,a.style.height=o.height/e+`px`))}_?.image&&!ne()&&ie()};function E(){!p&&!m&&(p=y(T))}let D=e=>{try{return e.matches(`:hover`)}catch{return!1}},O=()=>c.hasAttribute(`data-stillmade-pick`),k=e=>{if(m||e?.tagName!==`VIDEO`||l.has(e)||!e.hasAttribute(`controls`)||e.hasAttribute(`data-stillmade-player`))return null;let t=C(),r=s.createElement(`div`),i=s.createElement(`div`);r.tabIndex=-1,r.hidden=!0,i.className=`sm-player-ui`,r.append(i),t.append(r);let a={video:e,box:r,key:null,type:``,style:null,focusable:!e.hasAttribute(`tabindex`)};return a.focusable&&(e.tabIndex=0),a.player=n.attachMediaPlayer(e,{root:r,ui:i,keys:e,theater:!0,label:e.getAttribute(`aria-label`)||e.getAttribute(`title`)||`Video`,onStage:e=>N(a,e)}),r.addEventListener(`pointerleave`,()=>r.removeAttribute(`data-live`)),l.set(e,a),w?.observe(e),E(),a};function A(e){l.delete(e.video),w?.unobserve(e.video),e.player.destroy(),e.box.remove(),e.focusable&&e.video.removeAttribute(`tabindex`)}let j=()=>{if(!m){for(let e of s.querySelectorAll(`video[controls]:not([data-stillmade-player])`))k(e);for(let e of s.querySelectorAll(`.sm-stage>img,.sm-gallery img,img[data-stillmade-expand],[data-stillmade-expand] img`))te(e)}},M=(e,t)=>{if(typeof e.showPopover==`function`)try{t?(e.setAttribute(`popover`,`manual`),e.showPopover()):(e.matches(`:popover-open`)&&e.hidePopover(),e.removeAttribute(`popover`))}catch{}},N=(e,t)=>{let{video:n,box:r}=e;if(t){if(h)return;h=e,e.style=n.getAttribute(`style`),n.style.cssText=(e.style?e.style+`;`:``)+`position:fixed!important;inset:0!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;margin:0!important;padding:0!important;border:0!important;border-radius:0!important;object-fit:contain!important;background:#0A0A0A!important;transform:none!important;z-index:2147483645!important`,M(r,!1),M(n,!0),M(r,!0),c.setAttribute(`data-stillmade-stage`,``),ie();for(let t of l.values())t!==e&&(t.box.hidden=!0,t.key=null);v({op:`media-stage`,on:!0});return}h===e&&(h=null,M(n,!1),e.style==null?n.removeAttribute(`style`):n.setAttribute(`style`,e.style),c.removeAttribute(`data-stillmade-stage`),e.key=null,v({op:`media-stage`,on:!1}),E())},P=e=>e.closest(`[data-stillmade-expand]`),F=e=>{if(e?.tagName!==`IMG`||!(e.currentSrc||e.getAttribute(`src`)))return!1;let t=P(e);return t?t.getAttribute(`data-stillmade-expand`)!==`off`:!e.closest(`.sm-choices,.sm-list,button,a,label`)&&!!i(e.currentSrc||e.src)&&(!!e.parentElement?.matches(`.sm-stage`)||!!e.closest(`.sm-gallery:not([data-size="small"])`))},I=e=>{let t=P(e),n=t?.getAttribute(`data-stillmade-expand`)||``,r=e=>e.tagName===`IMG`?[e]:[...e.querySelectorAll(`img`)],i=t&&n&&n!==`on`?[...s.querySelectorAll(`[data-stillmade-expand]`)].filter(e=>e.getAttribute(`data-stillmade-expand`)===n).flatMap(r):t?r(t):e.closest(`.sm-gallery`)?r(e.closest(`.sm-gallery`)):[e];return[...new Set(i)].filter(t=>t===e||F(t)).slice(0,200)},ee=new Set,te=e=>{!m&&e?.tagName===`IMG`&&!e.hasAttribute(`tabindex`)&&F(e)&&(e.tabIndex=0,ee.add(e))},L=e=>{try{return e.matches(`:focus-visible`)}catch{return!0}},R=e=>{if(g||h)return;let t=I(e),r=t.map(e=>({url:e.currentSrc||e.src,name:e.alt||``}));ie(),te(e),c.setAttribute(`data-stillmade-stage`,``),g=n.openMediaViewer(r,{document:s,container:C(),index:Math.max(0,t.indexOf(e)),opener:e,onClose:()=>{g=null,c.removeAttribute(`data-stillmade-stage`),v({op:`media-stage`,on:!1}),E(),s.activeElement===e&&L(e)&&re(e)}}),g?v({op:`media-stage`,on:!0}):c.removeAttribute(`data-stillmade-stage`)};function ne(){let{wrap:e,button:t,image:r}=_;if(!r.isConnected)return!1;let i=r.getBoundingClientRect(),a=S();return i.width<48||i.height<48?!1:(e.style.transform=`translate(`+i.left/a+`px,`+i.top/a+`px)`,e.style.width=i.width/a+`px`,e.style.height=i.height/a+`px`,n.photoSize(t,{width:i.width/a,height:i.height/a}),!0)}let re=(e,t)=>{let r=C();if(!_){let e=s.createElement(`span`),t=s.createElement(`button`);e.className=`sm-frame-photo`,t.type=`button`,t.className=`sm-expand-btn`,t.setAttribute(`aria-label`,`View full screen`),t.title=`View full screen`,t.innerHTML=n.svg(`maximize`),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),_.image&&R(_.image)}),t.addEventListener(`focusout`,e=>{_?.image&&e.relatedTarget!==_.image&&!D(_.image)&&ie()}),r.addEventListener(`focusin`,e=>{_?.image&&e.target!==t&&ie()}),e.append(t),r.append(e),_={wrap:e,button:t,image:null,timer:0}}if(clearTimeout(_.timer),_.image=e,!ne()){ie();return}_.wrap.hidden=!1,_.button.setAttribute(`data-show`,``),t&&t!==`mouse`&&(_.timer=setTimeout(ie,3e3))};function ie(){_&&(clearTimeout(_.timer),_.image=null,_.button.removeAttribute(`data-show`),_.wrap.hidden=!0)}x(window,`pointerover`,e=>{let t=e.target;if(!(m||t===d||O())){if(t?.tagName===`VIDEO`){let e=l.get(t)||k(t);e&&!h&&!g&&(e.key=null,T(),e.box.hidden||e.box.setAttribute(`data-live`,``))}!h&&!g&&F(t)?re(t,e.pointerType):_?.image&&!(e.pointerType&&e.pointerType!==`mouse`)&&ie()}},{capture:!0,passive:!0}),x(window,`focusin`,e=>{let t=e.target;!m&&!h&&!g&&!O()&&F(t)&&L(t)&&re(t)},!0),x(window,`focusout`,e=>{_?.image&&e.target===_.image&&e.relatedTarget!==d&&!D(e.target)&&ie()},!0),x(window,`keydown`,e=>{let t=e.target;m||h||g||O()||e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey||e.key!==`Enter`&&e.key!==` `||!F(t)||(e.preventDefault(),R(t))}),x(window,`pointerout`,e=>{!e.relatedTarget&&_?.image&&(!e.pointerType||e.pointerType===`mouse`)&&ie()},{capture:!0,passive:!0}),x(window,`pointerdown`,e=>{let t=l.get(e.target);t&&(t.type=e.pointerType||``)},!0);let ae=e=>{let t=l.get(e.target);if(!t||O())return;let n=t.type,r=r=>{let i=new MouseEvent(r,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY});n&&Object.defineProperty(i,"pointerType",{value:n}),t.box.dispatchEvent(i)};e.type===`click`&&(t.type=``,r(`pointerdown`)),r(e.type)};x(window,`click`,ae,!0),x(window,`dblclick`,ae,!0);let oe=e=>{e.target?.tagName===`VIDEO`&&k(e.target)&&E()};for(let e of[`loadstart`,`loadedmetadata`,`focusin`])x(window,e,oe,!0);x(s,`load`,e=>te(e.target),!0),x(window,`scroll`,E,{capture:!0,passive:!0}),x(window,`resize`,E),x(window,`message`,n=>{let r=n.data;n.source===o&&r&&r.channel===e&&r.session===t&&(r.op===`media-stage-end`&&(h?h.player.toggleFullscreen():g?.close()),r.op===`dispose`&&se())});function se(){if(!m){g?.close({silent:!0}),g=null,h&&h.player.toggleFullscreen(),m=!0,p&&b(p),p=0,w?.disconnect();for(let e of[...l.values()])A(e);_&&clearTimeout(_.timer),_=null,d?.remove(),c.removeAttribute(`data-stillmade-stage`);for(let e of ee)e.getAttribute(`tabindex`)===`0`&&e.removeAttribute(`tabindex`);ee.clear();for(let[e,t,n,r]of u)e.removeEventListener(t,n,r)}}s.body&&w?.observe(s.body),j(),s.readyState===`loading`&&x(s,`DOMContentLoaded`,j,{once:!0}),x(window,`load`,j,{once:!0})}function xU(){let e={playFilled:`<path d="M7 4.6v14.8c0 .8.9 1.2 1.5.8l11.4-7.4a1 1 0 0 0 0-1.6L8.5 3.8C7.9 3.4 7 3.8 7 4.6Z" fill="currentColor" stroke="none"></path>`,pauseFilled:`<rect x="6" y="4.5" width="4" height="15" rx="1" fill="currentColor" stroke="none"></rect><rect x="14" y="4.5" width="4" height="15" rx="1" fill="currentColor" stroke="none"></rect>`,volume2:`<path d="M11 5 6 9H2v6h4l5 4V5Z" fill="currentColor"></path><path d="M15.5 8.5a5 5 0 0 1 0 7M19 5a10 10 0 0 1 0 14"></path>`,volumeX:`<path d="M11 5 6 9H2v6h4l5 4V5Z" fill="currentColor"></path><path d="m22 9-6 6M16 9l6 6"></path>`,maximize:`<path d="M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M21 16v3a2 2 0 0 1-2 2h-3M3 16v3a2 2 0 0 0 2 2h3"></path>`,minimize:`<path d="M8 3v3a2 2 0 0 1-2 2H3M21 8h-3a2 2 0 0 1-2-2V3M3 16h3a2 2 0 0 1 2 2v3M16 21v-3a2 2 0 0 1 2-2h3"></path>`,x:`<path d="M6 6 18 18M18 6 6 18"></path>`,chevronLeft:`<path d="m15 6-6 6 6 6"></path>`,chevronRight:`<path d="m9 6 6 6-6 6"></path>`,download:`<path d="M12 4v12M7 11l5 5 5-5"></path><path d="M5 20h14"></path>`,edit:`<path d="M12 20h9"></path><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"></path>`,imageOff:`<path d="M2 2l20 20"></path><path d="M10.41 10.41a2 2 0 1 1-2.83-2.83"></path><path d="M13.5 13.5 6 21"></path><path d="m18 12 3 3"></path><path d="M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59"></path><path d="M21 15V5a2 2 0 0 0-2-2H9"></path>`},t=2e3,n=3e3,r=3e3,i=new WeakMap,a=t=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">`+e[t]+`</svg>`,o=e=>{let t=Math.max(0,Math.floor(Number.isFinite(e)?e:0)),n=Math.floor(t/3600),r=Math.floor(t/60)%60,i=String(t%60).padStart(2,`0`);return n?n+`:`+String(r).padStart(2,`0`)+`:`+i:r+`:`+i},s=e=>typeof e==`string`&&e.startsWith(`sm-media://device/`),c=(e,t,n)=>{let r=e.createElement(t);return n&&(r.className=n),r},l=(e,t,n,r=t)=>{e.setAttribute(`aria-label`,t),e.title=r,e.dataset.icon!==n&&(e.dataset.icon=n,e.innerHTML=a(n))},u=(e,t,n,r)=>{let i=c(e,`button`,`sm-media-btn`);return i.type=`button`,t&&(i.dataset.control=t),l(i,n,r),i},d=(e,t)=>{let n=c(e,`span`,t);return n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,`On another device`),n.title=`On another device`,n.innerHTML=a(`imageOff`),n},f=(e,t)=>{t.width&&(t.width<240||t.height<160?e.setAttribute(`data-size`,`small`):e.removeAttribute(`data-size`))},p=e=>(t,n,r,i)=>{t.addEventListener(n,r,i),e.push([t,n,r,i])};function m(e,a={}){if(!e)return null;let s=i.get(e);if(s)return s;let d=e.ownerDocument,f=d.defaultView||window,m=[],h=p(m),g=e=>f.requestAnimationFrame?f.requestAnimationFrame(e):f.setTimeout(e,16),_=e=>f.cancelAnimationFrame?f.cancelAnimationFrame(e):f.clearTimeout(e),v=a.root,y=a.ui,b=!v,x=!y,S=[];b&&(v=c(d,`div`),e.before(v),v.append(e));let C=a.keys||v;x&&(y=c(d,`div`),v.append(y)),v.classList.add(`sm-player`),y.classList.add(`sm-player-ui`);let w=(e,t)=>{v.hasAttribute(e)||(v.setAttribute(e,t),S.push(e))};w(`data-mode`,`dark`),w(`tabindex`,`0`),w(`role`,`group`),w(`aria-label`,a.label||`Video`);let T=e.hasAttribute(`controls`);e.controls=!1,e.removeAttribute(`controls`),e.playsInline=!0,e.setAttribute(`playsinline`,``),e.setAttribute(`data-stillmade-player`,`on`);let E=c(d,`div`,`sm-player-shade`),D=c(d,`div`,`sm-player-bar nodrag nopan`),O=u(d,`play`,`Play`,`playFilled`),k=u(d,`sound`,`Mute`,`volume2`),A=u(d,`fullscreen`,`Full screen`,`maximize`),j=c(d,`div`,`sm-player-rail`),M=c(d,`div`,`sm-player-track`),N=c(d,`div`,`sm-player-buffered`),P=c(d,`div`,`sm-player-played`),F=c(d,`div`,`sm-player-head`),I=c(d,`div`,`sm-player-knob`),ee=c(d,`div`,`sm-player-tip`),te=c(d,`span`,`sm-player-time`),L=c(d,`span`,`sm-player-now`),R=c(d,`span`,`sm-media-of sm-player-total`);M.append(N,P),F.append(I),j.append(M,F,ee),te.append(L,R),j.dataset.control=`timeline`,j.tabIndex=0,j.setAttribute(`role`,`slider`),j.setAttribute(`aria-label`,`Seek`),j.setAttribute(`aria-valuemin`,`0`),te.dataset.control=`time`,te.setAttribute(`aria-hidden`,`true`),ee.setAttribute(`aria-hidden`,`true`),E.setAttribute(`aria-hidden`,`true`);let ne=c(d,`div`,`sm-player-sound`),re=c(d,`div`,`sm-player-volume`),ie=c(d,`div`,`sm-player-volume-rail`),ae=c(d,`div`,`sm-player-volume-track`),oe=c(d,`div`,`sm-player-volume-level`),se=c(d,`div`,`sm-player-volume-head`),ce=c(d,`div`,`sm-player-volume-knob`);ae.append(oe,se),se.append(ce),ie.append(ae),re.append(ie),ne.append(re,k),ne.dataset.control=`volume`,ie.tabIndex=0,ie.setAttribute(`role`,`slider`),ie.setAttribute(`aria-label`,`Volume`),ie.setAttribute(`aria-orientation`,`vertical`),ie.setAttribute(`aria-valuemin`,`0`),ie.setAttribute(`aria-valuemax`,`100`),D.append(O,j,te,ne,A),y.append(E,D);let le=!1,ue=!1,de=0,fe=Date.now(),pe=!1,me=0,he=0,ge=0,_e=!0,ve=``,ye=``,be=``,z=``,xe=!1,Se=!1,Ce=!1,we=!1,Te=null,Ee=!1,De=0,Oe=!1,ke=0,Ae=!1,je=0,Me=0,Ne=-1,Pe=-1,Fe=-1,Ie=0,Le=0,Re=!1,ze=0,Be=0,Ve=()=>Number.isFinite(e.duration)&&e.duration>0?e.duration:0,He=(e,t)=>{t?v.setAttribute(e,``):v.removeAttribute(e)},Ue=()=>{let t=Ve(),n=pe?me*t:e.currentTime||0,r=t?Math.min(1,Math.max(0,n/t)):0;r!==Ne&&(Ne=r,P.style.transform=`scaleX(`+r+`)`,F.style.transform=`translateX(`+r*100+`%)`);let i=Math.floor(n);(i!==Pe||t!==Fe)&&(Pe=i,Fe=t,L.textContent=o(n),R.textContent=` / `+o(t),j.setAttribute(`aria-valuemax`,String(Math.round(t))),j.setAttribute(`aria-valuenow`,String(Math.min(i,Math.round(t)))),j.setAttribute(`aria-valuetext`,o(n)+` of `+o(t)))},We=()=>{he=0,!le&&(Ue(),!e.paused&&!e.ended&&_e&&(he=g(We)))},Ge=()=>{!he&&!le&&(he=g(We))},Ke=()=>{let t=Ve(),n=e.buffered;t&&n&&n.length&&(N.style.transform=`scaleX(`+Math.min(1,n.end(n.length-1)/t)+`)`)},qe=()=>!!f.matchMedia?.(`(hover: none)`)?.matches,Je=e=>e.pointerType?e.pointerType===`mouse`:!qe(),Ye=e=>{try{return e.matches(`:focus-visible`)}catch{return!0}},Xe=()=>!le&&!e.paused&&!e.ended&&!pe&&!Re&&!Ee&&!Oe&&!Te,Ze=e=>{ue!==e&&(ue=e,He(`data-idle`,e))},Qe=()=>{if(de=0,!Xe())return;let e=t-(Date.now()-fe);if(e>10){de=f.setTimeout(Qe,e);return}Ze(!0)},$e=()=>{if(!Xe()){de&&=(f.clearTimeout(de),0),Ze(!1);return}!de&&!ue&&(de=f.setTimeout(Qe,Math.max(10,t-(Date.now()-fe))))},et=()=>{fe=Date.now(),Ze(!1),$e()},tt=()=>{let e=!le&&!(Se||we||pe||Re||Ee||Oe);e!==Ce&&(Ce=e,He(`data-away`,e))},nt=()=>{ke&&=(f.clearTimeout(ke),0),Oe=!1},rt=()=>{Ae||le||(Ae=!0,Oe=!0,ke=f.setTimeout(()=>{ke=0,Oe=!1,tt(),$e()},r),tt(),$e())},it=()=>{Ee=!0,De&&f.clearTimeout(De),De=f.setTimeout(()=>{De=0,Ee=!1,tt(),$e()},n),tt(),et()},at=()=>{if(e.paused||e.ended){let t=e.play();t&&typeof t.catch==`function`&&t.catch(()=>{})}else e.pause()},ot=t=>{let n=Ve();n&&(e.currentTime=Math.min(n,Math.max(0,t)),Ge())},st=t=>ot((e.currentTime||0)+t),ct=t=>{t>0&&e.muted&&(e.muted=!1),e.volume=Math.min(1,Math.max(0,Math.round(((e.volume||0)+t)*10)/10))},lt=()=>{let t=!e.paused&&!e.ended;l(O,t?`Pause`:`Play`,t?`pauseFilled`:`playFilled`),He(`data-playing`,t),et(),Ge()},ut=()=>{let t=e.muted||e.volume===0,n=t?0:Math.min(1,Math.max(0,e.volume)),r=Math.round(n*100);oe.style.transform=`scaleY(`+n+`)`,se.style.transform=`translateY(`+-n*100+`%)`,ie.setAttribute(`aria-valuenow`,String(r)),ie.setAttribute(`aria-valuetext`,t?`Muted`:r+`%`),k.setAttribute(`aria-pressed`,String(!!e.muted)),l(k,`Mute`,t?`volumeX`:`volume2`,e.muted?`Unmute`:`Mute`)},dt=()=>ve===`theater`||d.fullscreenElement===v,ft=()=>{let e=dt();l(A,e?`Exit full screen`:`Full screen`,e?`minimize`:`maximize`)},pt=()=>{if(ve=`theater`,v.setAttribute(`data-stage`,`theater`),typeof v.showPopover==`function`)try{v.setAttribute(`popover`,`manual`),v.showPopover()}catch{v.removeAttribute(`popover`)}ft(),a.onStage?.(!0)},mt=()=>{if(ve===`theater`){if(ve=``,v.hasAttribute(`popover`)){try{v.hidePopover()}catch{}v.removeAttribute(`popover`)}v.removeAttribute(`data-stage`),ft(),a.onStage?.(!1)}},ht=()=>{let e=v.requestFullscreen;if(a.theater||typeof e!=`function`||d.fullscreenEnabled===!1){pt();return}let t;try{t=e.call(v)}catch{pt();return}t&&typeof t.then==`function`?t.then(ft,pt):ft()},gt=()=>{if(ve===`theater`)mt();else if(d.fullscreenElement===v){let e=d.exitFullscreen?.();e&&typeof e.catch==`function`&&e.catch(()=>{})}},_t=()=>{dt()?gt():ht()},B=()=>{let e=j.getBoundingClientRect();je=e.left,Me=e.width},vt=e=>Me>0?Math.min(1,Math.max(0,(e-je)/Me)):0,yt=e=>{let t=Math.min(Math.max(e-je,22),Math.max(22,Me-22)),n=o(Ve()*vt(e));ee.style.transform=`translateX(`+t+`px) translateX(-50%)`,ee.textContent!==n&&(ee.textContent=n)},bt=()=>{let t=Ve();t&&(e.currentTime=me*t),Ue()},xt=()=>{ge||=g(()=>{ge=0,le||bt()})},St=()=>{pe&&(ge&&=(_(ge),0),bt(),pe=!1,j.removeAttribute(`data-drag`),z===`touch`?it():(tt(),$e()))};h(j,`pointerenter`,B),h(j,`pointerdown`,e=>{if(!(e.button>0)){B(),pe=!0,tt(),j.setAttribute(`data-drag`,``);try{j.setPointerCapture?.(e.pointerId)}catch{}me=vt(e.clientX),xt(),yt(e.clientX),et()}}),h(j,`pointermove`,e=>{yt(e.clientX),pe&&(me=vt(e.clientX),xt())}),h(j,`pointerup`,St),h(j,`pointercancel`,St),h(j,`lostpointercapture`,St);let Ct=()=>{let e=ae.getBoundingClientRect();Ie=e.top,Le=e.height},wt=e=>Le>0?Math.min(1,Math.max(0,1-(e-Ie)/Le)):0,Tt=()=>{Be=0,!le&&(e.volume=Math.round(ze*100)/100,e.muted=ze===0)},Et=()=>{Be||=g(Tt)},Dt=()=>{Re&&(Be&&(_(Be),Tt()),Re=!1,re.removeAttribute(`data-drag`),tt(),$e())};h(ie,`pointerdown`,e=>{if(!(e.button>0)){e.stopPropagation(),Ct(),Re=!0,re.setAttribute(`data-drag`,``),tt();try{ie.setPointerCapture?.(e.pointerId)}catch{}ze=wt(e.clientY),Et(),et()}}),h(ie,`pointermove`,e=>{Re&&(ze=wt(e.clientY),Et())}),h(ie,`pointerup`,Dt),h(ie,`pointercancel`,Dt),h(ie,`lostpointercapture`,Dt),h(O,`click`,at),h(k,`click`,()=>{e.muted||e.volume===0?(e.muted=!1,e.volume===0&&(e.volume=1)):e.muted=!0}),h(A,`click`,_t),h(v,`pointerdown`,e=>{z=Je(e)?`mouse`:`touch`,xe=Ce||ue,z===`touch`&&!xe&&it()}),h(v,`click`,e=>{let t=z?z===`touch`:qe(),n=z?xe:Ce||ue;if(z=``,!D.contains(e.target)){if(!t){at(),et();return}n||at(),it()}}),h(v,`dblclick`,e=>{D.contains(e.target)||(e.preventDefault(),_t())}),h(v,`pointerenter`,e=>{Je(e)&&(nt(),Se=!0,tt(),et())}),h(v,`pointermove`,e=>{Je(e)&&(fe=Date.now(),Se||(nt(),Se=!0,tt()),ue&&Ze(!1),de||$e())}),h(v,`pointerleave`,e=>{Je(e)&&(Se=!1,tt())});let Ot=e=>!!e&&(v.contains(e)||C.contains(e)),kt=e=>{let t=Ye(e.target);t&&(we=!0),Te=t&&e.target!==v&&e.target!==C?e.target:null,tt(),et()},At=e=>{Te=null,Ot(e.relatedTarget)||(we=!1,tt()),$e()};for(let e of C===v?[v]:[v,C])h(e,`focusin`,kt),h(e,`focusout`,At);let jt=t=>{if(t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey)return;we||(we=!0,tt());let n=t.key,r=n&&n.length===1?n.toLowerCase():n,i=Ve();if((n===` `||n===`Enter`)&&t.target?.closest?.(`button`))return;let a=!0;n===` `||r===`k`?at():t.target===ie&&/^Arrow(Up|Down|Left|Right)$/.test(n||``)?ct(n===`ArrowUp`||n===`ArrowRight`?.1:-.1):t.target===ie&&(n===`Home`||n===`End`)?(e.volume=+(n===`End`),e.muted=n===`Home`):n===`ArrowRight`||n===`ArrowLeft`?st((n===`ArrowRight`?1:-1)*(t.shiftKey?10:5)):r===`l`||r===`j`?st(r===`l`?10:-10):n===`ArrowUp`||n===`ArrowDown`?ct(n===`ArrowUp`?.1:-.1):r===`m`?e.muted=!e.muted:r===`f`?_t():n===`Home`?ot(0):n===`End`?ot(i):n===`PageUp`||n===`PageDown`?st((n===`PageUp`?1:-1)*i/10):/^[0-9]$/.test(n||``)?ot(i*Number(n)/10):n===`Escape`&&ve===`theater`?(mt(),t.stopPropagation()):a=!1,a&&t.preventDefault(),et()};for(let e of C===v?[v]:[v,C])h(e,`keydown`,jt);h(e,`play`,lt),h(e,`pause`,lt),h(e,`ended`,lt),h(e,`seeked`,Ge),h(e,`durationchange`,Ge),h(e,`loadedmetadata`,Ge),h(e,`progress`,Ke),h(e,`volumechange`,ut),h(e,`emptied`,()=>{Ne=-1,Pe=-1,N.style.transform=`scaleX(0)`,Ge()}),h(d,`fullscreenchange`,ft);let Mt=typeof f.ResizeObserver==`function`?new f.ResizeObserver(e=>{let t=e[e.length-1].contentRect,n=t.width;if(!n)return;let r=n<180?`micro`:n<240?`tiny`:n<300?`compact`:n<400?`narrow`:``;r!==ye&&(ye=r,ye?v.setAttribute(`data-size`,ye):v.removeAttribute(`data-size`));let i=!(t.height>0)||t.height>=200?``:t.height<150?`none`:`short`;i!==be&&(be=i,be?v.setAttribute(`data-volume-room`,be):v.removeAttribute(`data-volume-room`))}):null,Nt=typeof f.IntersectionObserver==`function`?new f.IntersectionObserver(e=>{_e=e[e.length-1].isIntersecting,_e&&(Ge(),rt())}):null;Mt?.observe(v),Nt?.observe(v);let Pt=()=>{if(!le){gt(),le=!0,i.delete(e);for(let[e,t,n,r]of m)e.removeEventListener(t,n,r);Mt?.disconnect(),Nt?.disconnect(),he&&_(he),ge&&_(ge),de&&f.clearTimeout(de),De&&f.clearTimeout(De),ke&&f.clearTimeout(ke),E.remove(),D.remove(),x&&y.remove();for(let e of[`data-away`,`data-idle`,`data-size`,`data-volume-room`,`data-stage`,`data-playing`,...S])v.removeAttribute(e);e.removeAttribute(`data-stillmade-player`),T&&e.setAttribute(`controls`,``),b&&v.replaceWith(e)}};try{Se=v.matches(`:hover`)}catch{}let Ft=d.activeElement;Ot(Ft)&&Ye(Ft)&&(we=!0,Te=Ft!==v&&Ft!==C?Ft:null),tt(),lt(),ut(),ft(),Ue(),Ke();let It={root:v,video:e,destroy:Pt,toggleFullscreen:_t,isFullscreen:dt};return i.set(e,It),It}function h(t,n={}){let r=n.document||document,i=[],o=p(i),l=(Array.isArray(t)?t:[t]).filter(e=>e&&typeof e.url==`string`&&e.url);if(!l.length)return null;let f=n.opener||r.activeElement,h=c(r,`dialog`,`sm-viewer`),g=c(r,`div`,`sm-viewer-stage`),_=c(r,`div`,`sm-viewer-top`),v=c(r,`div`,`sm-viewer-foot`),y=c(r,`span`,`sm-viewer-count`),b=c(r,`span`,`sm-viewer-name`),x=u(r,`close`,`Close`,`x`),S=u(r,`previous`,`Previous`,`chevronLeft`),C=u(r,`next`,`Next`,`chevronRight`);h.setAttribute(`data-mode`,`dark`),h.setAttribute(`data-stillmade-host`,``),h.setAttribute(`aria-label`,n.label||`Full screen view`),y.setAttribute(`aria-live`,`polite`),S.classList.add(`sm-viewer-nav`,`sm-viewer-previous`),C.classList.add(`sm-viewer-nav`,`sm-viewer-next`),_.append(x),v.append(y,b),h.append(g,_,S,C,v);let w=0,T=null,E=0,D=!1,O=t=>{for(let e of[..._.children])e!==x&&e.remove();let i=typeof n.actions==`function`?n.actions(t,w):n.actions;for(let n of Array.isArray(i)?i:[]){if(!n||!n.label)continue;let i=c(r,n.href?`a`:`button`,`sm-media-btn`);if(i.setAttribute(`aria-label`,n.label),i.title=n.label,e[n.icon]?i.innerHTML=a(n.icon):(i.textContent=n.label,i.classList.add(`sm-media-btn-text`)),n.href?(i.href=n.href,i.rel=`noopener noreferrer`,n.download!=null&&n.download!==!1&&i.setAttribute(`download`,n.download===!0?``:String(n.download))):i.type=`button`,typeof n.onClick==`function`){let e=w;i.addEventListener(`click`,r=>n.onClick(t,e,r))}_.insertBefore(i,x)}},k=e=>{let t=l.length;w=((Math.trunc(e)||0)%t+t)%t;let i=l[w],a=++E;T?.destroy(),T=null,g.replaceChildren(),S.hidden=C.hidden=y.hidden=t<2,b.hidden=!i.name,v.hidden=t<2&&!i.name;let o=c(r,`span`,`sm-media-of`);o.textContent=` of `+t,y.replaceChildren(String(w+1),o),b.textContent=i.name||``,O(i);let u=e=>{if(D||a!==E)return;if(!e){g.replaceChildren(d(r,`sm-viewer-off`));return}if(i.kind===`video`){let t=c(r,`div`,`sm-player`),a=c(r,`video`);t.setAttribute(`data-fill`,``),a.preload=`metadata`,a.autoplay=!0,a.src=e,i.poster&&!s(i.poster)&&(a.poster=i.poster),t.append(a),g.replaceChildren(t),T=m(a,{root:t,label:i.name||`Video`}),n.onShow?.(a,i,w);return}let t=c(r,`img`,`sm-viewer-media`);t.alt=i.alt??i.name??``,t.decoding=`async`,t.src=e,g.replaceChildren(t),n.onShow?.(t,i,w)};s(i.url)?typeof n.resolve==`function`?Promise.resolve().then(()=>n.resolve(i.url)).then(e=>u(e||null),()=>u(null)):u(null):u(i.url)},A=e=>{k(w+e),n.onIndexChange?.(w)},j=({silent:e=!1}={})=>{if(!D){D=!0,E++,T?.destroy(),T=null;for(let[e,t,n,r]of i)e.removeEventListener(t,n,r);try{h.open&&h.close()}catch{}h.remove(),f&&f.isConnected&&typeof f.focus==`function`&&f.focus({preventScroll:!0}),e||n.onClose?.()}};o(x,`click`,()=>j()),o(S,`click`,()=>A(-1)),o(C,`click`,()=>A(1)),o(h,`keydown`,e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),j();return}e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey||l.length<2||(e.key===`ArrowRight`||e.key===`ArrowLeft`)&&(e.preventDefault(),A(e.key===`ArrowRight`?1:-1))}),o(h,`cancel`,e=>{e.preventDefault(),j()});let M=!1,N=null;return o(g,`pointerdown`,e=>{M=e.target===g}),o(g,`click`,e=>{M&&e.target===g&&j(),M=!1}),o(g,`touchstart`,e=>{N=e.touches?.length===1&&!e.target?.closest?.(`.sm-player-bar`)?e.touches[0].clientX:null},{passive:!0}),o(g,`touchend`,e=>{if(N==null||l.length<2)return;let t=e.changedTouches[0].clientX-N;N=null,Math.abs(t)>50&&A(t<0?1:-1)},{passive:!0}),(n.container||r.body).append(h),typeof h.showModal==`function`?h.showModal():h.setAttribute(`open`,``),k(n.index||0),x.focus({preventScroll:!0}),{dialog:h,show:k,close:j,update(e,t=w){let n=(Array.isArray(e)?e:[e]).filter(e=>e&&typeof e.url==`string`&&e.url);n.length&&(l=n,k(t))},get index(){return w}}}function g(e,t={}){let i=e.ownerDocument,o=i.defaultView||window,s=e.tagName===`IMG`?e:e.querySelector(`img`),l=e.tagName===`IMG`?e.parentElement:e,u=()=>s&&(s.currentSrc||s.getAttribute(`src`))?[{url:s.currentSrc||s.src,name:s.alt||``}]:[],d=typeof t.items==`function`?t.items():t.items||u();if(!l||!d.length)return null;let p=t.label||`View full screen`,m=c(i,`button`,`sm-expand-btn nodrag nopan`);m.type=`button`,m.setAttribute(`aria-label`,p),m.title=p,m.innerHTML=a(`maximize`);let g=e=>{if(e.preventDefault(),e.stopPropagation(),typeof t.onOpen==`function`){t.onOpen(e);return}h(typeof t.items==`function`?t.items():t.items||u(),{document:i,index:t.index||0,opener:m,actions:t.actions,resolve:t.resolve,onClose:t.onClose})},_=0,v=e=>{e.pointerType&&e.pointerType!==`mouse`&&!m.contains(e.target)&&(m.setAttribute(`data-show`,``),o.clearTimeout(_),_=o.setTimeout(()=>m.removeAttribute(`data-show`),n))},y=typeof o.ResizeObserver==`function`?new o.ResizeObserver(e=>f(m,e[e.length-1].contentRect)):null,b=typeof o.IntersectionObserver==`function`?new o.IntersectionObserver(e=>{let t=e[e.length-1];if(!t.isIntersecting)return;b.disconnect();let n=t.boundingClientRect;n.width<240||n.height<160||(m.setAttribute(`data-show`,``),o.clearTimeout(_),_=o.setTimeout(()=>m.removeAttribute(`data-show`),r))}):null,x=e=>{e.pointerType&&e.pointerType!==`mouse`||(o.clearTimeout(_),m.removeAttribute(`data-show`))};return m.addEventListener(`click`,g),l.addEventListener(`pointerdown`,v),l.addEventListener(`pointerenter`,x),l.classList.add(`sm-expand-host`),l.append(m),y?.observe(s||l),b?.observe(s||l),{button:m,destroy(){m.removeEventListener(`click`,g),l.removeEventListener(`pointerdown`,v),l.removeEventListener(`pointerenter`,x),y?.disconnect(),b?.disconnect(),o.clearTimeout(_),m.remove()}}}function _(e=document){let t=[],n=[];for(let n of e.querySelectorAll(`video[controls]:not([data-stillmade-player])`))t.push(m(n,{label:n.getAttribute(`aria-label`)||void 0}));let r=[...e.querySelectorAll(`[data-stillmade-expand]:not([data-stillmade-expand="off"])`)].filter(e=>{let t=e.tagName===`IMG`?e:e.querySelector(`img`),n=e.tagName===`IMG`?e.parentElement:e;return t&&t.getAttribute(`src`)&&n&&!n.querySelector(`:scope > .sm-expand-btn`)}),i=e=>{let t=e.tagName===`IMG`?e:e.querySelector(`img`);return{url:t.currentSrc||t.src,name:t.alt||``}};for(let e of r){let t=e.getAttribute(`data-stillmade-expand`),a=t&&t!==`on`?r.filter(e=>e.getAttribute(`data-stillmade-expand`)===t):[e],o=g(e,{items:()=>a.map(i),index:a.indexOf(e)});o&&n.push(o)}return{players:t,buttons:n}}return{ICONS:e,svg:a,formatTime:o,isDeviceMediaUrl:s,photoSize:f,attachMediaPlayer:m,openMediaViewer:h,attachPhotoExpand:g,enhance:_}}var{ICONS:SU,formatTime:CU,isDeviceMediaUrl:wU,photoSize:TU,attachMediaPlayer:EU,openMediaViewer:DU,attachPhotoExpand:OU,enhance:kU}=xU(),AU=`/* StillMade media player, photo button and full-screen viewer: option A "Cream blocks" (owner, November 2, 2026). Solid cream
1840
+ `;function iU(e){let t=e=>Number.isFinite(e)&&e>=0&&e<=1;return!e||typeof e!=`object`||Array.isArray(e)||!t(e.x)||!t(e.y)||e.id!==void 0&&(typeof e.id!=`string`||!e.id.length||e.id.length>160)?null:{x:e.x,y:e.y,...e.id===void 0?{}:{id:e.id}}}function aU(e,t,n){if(t=iU(t),!t)return null;let r,i;if(t.id!==void 0){let n=e.getElementById(t.id);if(!n)return null;let a=n.getBoundingClientRect();if(a.width<=0||a.height<=0)return null;r=a.left+a.width*t.x,i=a.top+a.height*t.y;let o=e.elementFromPoint?.(r,i);if(o&&!n.contains(o))return null}else r=t.x*e.documentElement.scrollWidth-n.scrollX,i=t.y*e.documentElement.scrollHeight-n.scrollY;return Number.isFinite(r)&&Number.isFinite(i)&&r>=0&&i>=0&&r<=n.width&&i<=n.height?{x:r,y:i}:null}function oU(e,t,n){let r=null,i=null,a=null,o=!1,s=e=>Math.max(0,Math.min(1,e)),c=[],l=null,u=null,d=null,f=new Map,p=()=>{if(u=null,o||!n)return;!l&&c.length&&(l=document.createElement(`div`),l.style.cssText=`position:fixed;inset:0;pointer-events:none;z-index:2147483647;overflow:hidden`,l.setAttribute(`aria-hidden`,`true`),l.setAttribute(`data-stillmade-host`,``),document.body.append(l));let e=new Set(c.map(e=>e.id));for(let[t,n]of f)e.has(t)||(n.remove(),f.delete(t));for(let e of c){let t=f.get(e.id);t||(t=document.createElement(`div`),t.style.cssText=`position:absolute;left:0;top:0;pointer-events:none;color:var(--fg);white-space:nowrap;font:12px var(--font-body,sans-serif)`,typeof matchMedia==`function`&&!matchMedia(`(prefers-reduced-motion: reduce)`).matches&&(t.style.transition=`transform 100ms linear`),l.append(t),f.set(e.id,t)),t.textContent=`↖ `+e.label;let r=n(document,e.anchor,{width:innerWidth,height:innerHeight,scrollX,scrollY});t.hidden=!r,r&&(t.style.transform=`translate(`+r.x+`px,`+r.y+`px)`)}},m=()=>{u===null&&(u=setTimeout(p,50))},h=()=>{if(i=null,!o&&r){if(r.visible&&a){let e=(document.elementFromPoint?.(a.x,a.y)||a.target)?.closest?.(`[id]`),t=e?.id,n=t&&t.length<=160?e.getBoundingClientRect():null;if(n?.width>0&&n?.height>0)r.anchor={id:t,x:s((a.x-n.left)/n.width),y:s((a.y-n.top)/n.height)};else{let e=document.documentElement;r.anchor={x:s((a.x+scrollX)/Math.max(1,e.scrollWidth)),y:s((a.y+scrollY)/Math.max(1,e.scrollHeight))}}}parent.postMessage({channel:e,session:t,op:`cursor`,cursor:r},`*`),r=null}},g=e=>{a={x:e.clientX,y:e.clientY,target:e.target},r={x:s(e.clientX/Math.max(1,innerWidth)),y:s(e.clientY/Math.max(1,innerHeight)),visible:!0},i===null&&(i=setTimeout(h,50))},_=()=>{a=null,r={x:0,y:0,visible:!1},i===null&&(i=setTimeout(h,0))},v=()=>{a&&g({clientX:a.x,clientY:a.y,target:a.target}),m()},y=n=>{let s=n.data;if(!(o||n.source!==parent||s?.channel!==e||s.session!==t)){if(s.op===`peer-cursors`){c=(Array.isArray(s.peers)?s.peers:[]).slice(0,50).filter(e=>e&&typeof e.id==`string`&&e.id.length<=200&&typeof e.label==`string`&&e.label.length<=120).map(e=>({id:e.id,label:e.label,anchor:e.anchor})),m();return}s.op===`dispose`&&(o=!0,clearTimeout(i),clearTimeout(u),d?.disconnect(),r=null,a=null,c=[],f.clear(),l?.remove(),removeEventListener(`pointermove`,g),removeEventListener(`scroll`,v,!0),removeEventListener(`resize`,v),removeEventListener(`blur`,_),removeEventListener(`message`,y),document.documentElement.removeEventListener(`pointerleave`,_))}};addEventListener(`pointermove`,g,{passive:!0}),addEventListener(`scroll`,v,{passive:!0,capture:!0}),addEventListener(`resize`,v,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,_),addEventListener(`blur`,_),addEventListener(`message`,y),typeof MutationObserver==`function`&&(d=new MutationObserver(e=>{c.length&&e.some(e=>!l?.contains(e.target))&&m()}),d.observe(document.body,{subtree:!0,childList:!0,attributes:!0,characterData:!0}))}function sU(e,t,n){let r=!1,i=0,a=null,o=!1,s=n=>parent.postMessage({channel:e,session:t,...n},`*`),c=e=>{let t=String(e.tagName||`element`).toLowerCase(),n=typeof e.id==`string`?e.id.replace(/[^\w-]/g,``).slice(0,60):``;if(n)return t+`#`+n;let r=typeof e.className==`string`?e.className.split(/\s+/).find(e=>/^[A-Za-z_][\w-]{0,59}$/.test(e)):``;return r?t+`.`+r:t},l=(e,t)=>{let n=document.elementFromPoint(e,t);return n&&n!==document.documentElement&&n!==document.body?n:null},u=()=>{if(i=0,!r||o)return;let e=a?l(a.x,a.y):null;if(!e){s({op:`pick-hover`,hover:null});return}let t=e.getBoundingClientRect(),n=getComputedStyle(e),u=e=>Math.max(0,parseFloat(n[`padding`+e])||0);s({op:`pick-hover`,hover:{rect:{x:t.left,y:t.top,width:t.width,height:t.height},padding:{top:u(`Top`),right:u(`Right`),bottom:u(`Bottom`),left:u(`Left`)},cursor:{x:a.x,y:a.y},selector:c(e)}})},d=()=>{r&&!i&&(i=requestAnimationFrame(u))},f=e=>{a={x:e.clientX,y:e.clientY},d()},p=()=>{a=null,d()},m=e=>{e.preventDefault(),e.stopImmediatePropagation()},h=e=>{m(e);let t=l(e.clientX,e.clientY)||e.target,r=null;try{r=n(t,document.body,{x:e.clientX,y:e.clientY})}catch{}y(),s(r?{op:`pick-result`,target:r}:{op:`pick-cancel`})},g=e=>{e.key===`Escape`&&(m(e),y(),s({op:`pick-cancel`}))},_=[`pointerdown`,`pointerup`,`mousedown`,`mouseup`,`dblclick`,`contextmenu`,`touchstart`,`touchend`],v=()=>{if(!(r||o)){r=!0,document.documentElement.setAttribute(`data-stillmade-pick`,``),addEventListener(`pointermove`,f,{passive:!0,capture:!0}),document.documentElement.addEventListener(`pointerleave`,p),addEventListener(`scroll`,d,{passive:!0,capture:!0});for(let e of _)addEventListener(e,m,!0);addEventListener(`click`,h,!0),addEventListener(`keydown`,g,!0)}},y=()=>{if(r){r=!1,cancelAnimationFrame(i),i=0,a=null,document.documentElement.removeAttribute(`data-stillmade-pick`),removeEventListener(`pointermove`,f,{capture:!0}),document.documentElement.removeEventListener(`pointerleave`,p),removeEventListener(`scroll`,d,{capture:!0});for(let e of _)removeEventListener(e,m,!0);removeEventListener(`click`,h,!0),removeEventListener(`keydown`,g,!0)}};addEventListener(`message`,n=>{let r=n.data;!o&&n.source===parent&&r&&r.channel===e&&r.session===t&&(r.op===`pick-start`?v():r.op===`pick-stop`?y():r.op===`dispose`&&(y(),o=!0))})}Object.freeze({start:`pick-start`,stop:`pick-stop`,hover:`pick-hover`,result:`pick-result`,cancel:`pick-cancel`});var cU=Object.freeze({control:`stillmade:view-pick`,hover:`stillmade:view-pick-hover`,result:`stillmade:view-pick-result`,cancel:`stillmade:view-pick-cancel`});function lU(e,t,n=null){let r=(e,t)=>{let n=String(e??``).replace(/\s+/g,` `).trim();return n.length>t?n.slice(0,t-1)+`…`:n},i=t=>typeof e.getAttribute==`function`&&e.getAttribute(t)||``,a=String(e.tagName||`element`).toLowerCase(),o=r(i(`role`),40).toLowerCase(),s=r(i(`type`),20).toLowerCase(),c=[`input`,`textarea`,`select`].includes(a),l=e.isContentEditable===!0,u=e=>{let t=String(e.tagName||`element`).toLowerCase(),n=t=>typeof e.getAttribute==`function`?String(e.getAttribute(t)||``).trim().toLowerCase():``,r=n(`role`),i=n(`type`),a=[`input`,`textarea`,`select`].includes(t);return r===`button`||t===`button`||t===`summary`||a&&[`button`,`submit`,`reset`,`image`].includes(i)?`button`:r===`link`||t===`a`?`link`:r===`checkbox`||r===`switch`||a&&i===`checkbox`?`checkbox`:r===`radio`||a&&i===`radio`?`choice`:r===`tab`?`tab`:t===`select`||r===`combobox`||r===`listbox`?`menu`:a&&i===`file`?`file-picker`:r===`slider`||a&&i===`range`?`slider`:t===`textarea`||e.isContentEditable===!0||a?`text-field`:t===`img`||t===`svg`||t===`picture`||t===`canvas`||r===`img`?`image`:t===`video`?`video`:t===`audio`?`audio`:/^h[1-6]$/.test(t)||r===`heading`?`heading`:t===`label`?`label`:t===`li`||r===`listitem`||r===`option`||r===`menuitem`?`list-item`:t===`ul`||t===`ol`||r===`list`||r===`menu`?`list`:t===`table`?`table`:[`p`,`span`,`small`,`strong`,`em`,`b`,`i`,`code`,`legend`,`figcaption`,`output`,`time`,`td`,`th`,`dt`,`dd`,`blockquote`,`pre`].includes(t)||r===`status`||!e.children?.length&&String(e.textContent||``).trim()?`text`:`area`},d=u(e),f=typeof e.parentElement?.closest==`function`?e.parentElement.closest(`button,a,[role="button"],[role="link"],[role="tab"],label,li,[role="listitem"],[role="option"],[role="menuitem"],details,fieldset,form,table`):null,p=f&&f!==t&&(typeof t?.contains!=`function`||t.contains(f))?{kind:u(f),name:r(f.getAttribute(`aria-label`)||f.innerText||f.textContent,120)}:null,m=r(e.innerText??e.textContent,240),h=typeof e.labels==`object`&&e.labels?.[0]?r(e.labels[0].textContent,120):``,g=i(`aria-labelledby`)?r(i(`aria-labelledby`).split(/\s+/).map(t=>e.ownerDocument?.getElementById?.(t)?.textContent||``).join(` `),120):``,_=r(i(`aria-label`)||g||h||i(`alt`)||i(`title`)||i(`placeholder`),120)||(d===`image`?``:m.slice(0,120)),v=[];(e.disabled===!0||i(`aria-disabled`)===`true`)&&v.push(`disabled`),(e.checked===!0||i(`aria-checked`)===`true`||i(`aria-pressed`)===`true`)&&v.push(d===`button`?`pressed`:`checked`),(i(`aria-selected`)===`true`||i(`aria-current`))&&v.push(`selected`),(e.open===!0||i(`aria-expanded`)===`true`)&&v.push(`open`),i(`aria-expanded`)===`false`&&v.push(`closed`),(e.required===!0||i(`aria-required`)===`true`)&&v.push(`required`),e.readOnly===!0&&v.push(`read only`);let y=``;a===`select`?y=r(e.selectedOptions?.[0]?.textContent??e.value,120):c&&![`password`,`file`,`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`hidden`].includes(s)?y=r(e.value,120):l&&(y=m.slice(0,120));let b=typeof e.className==`string`?e.className.split(/\s+/).filter(e=>/^[A-Za-z_][\w-]{0,59}$/.test(e)).slice(0,4):[],x={};for(let t of Array.from(e.attributes||[])){if(Object.keys(x).length>=6)break;t.name.startsWith(`data-`)&&t.name.length<=60&&!t.name.startsWith(`data-stillmade`)&&(x[t.name.slice(5)]=r(t.value,80))}let S=(e,t)=>{let n=String(e.tagName||`element`).toLowerCase(),r=typeof e.id==`string`?e.id.replace(/[^\w-]/g,``).slice(0,60):``;if(r)return n+`#`+r;let i=typeof e.className==`string`?e.className.split(/\s+/).filter(e=>/^[A-Za-z_][\w-]{0,59}$/.test(e)).slice(0,t):[];if(i.length&&(n+=`.`+i.join(`.`)),t===1)return n;let a=e.parentElement?Array.from(e.parentElement.children).filter(t=>t.tagName===e.tagName):[];return a.length>1&&(n+=`:nth-of-type(${a.indexOf(e)+1})`),n},C=[],w=e;for(;w&&w!==t&&C.length<6;)C.unshift(S(w,2)),w=w.parentElement;let T=typeof t?.getBoundingClientRect==`function`?t.getBoundingClientRect():{left:0,top:0,width:0,height:0},E=typeof e.getBoundingClientRect==`function`?e.getBoundingClientRect():{left:0,top:0,width:0,height:0},D=(e,t)=>Math.max(0,Math.min(1,t>0?e/t:0)),O={x:D(E.left-T.left,T.width),y:D(E.top-T.top,T.height),width:D(E.width,T.width),height:D(E.height,T.height)},k=O.x+O.width/2,A=O.y+O.height/2,j=`${A<.34?`top`:A>.66?`bottom`:`middle`} ${k<.34?`left`:k>.66?`right`:`center`}`,M=``;if(d!==`heading`&&typeof t?.querySelectorAll==`function`){for(let n of t.querySelectorAll(`h1,h2,h3,h4,h5,h6,[role="heading"]`))if(!n.contains(e)){if(n.compareDocumentPosition(e)&4)M=r(n.textContent,80);else break}}let N=e.parentElement&&e.parentElement!==t?r(e.parentElement.innerText??e.parentElement.textContent,600):``,P=e=>({img:`image`,video:`video`,audio:`audio`,canvas:`canvas`})[String(e?.tagName||``).toLowerCase()]||``,F=e=>{let t=typeof e.getBoundingClientRect==`function`?e.getBoundingClientRect():null;return P(e)===`audio`||!t||t.width>=24&&t.height>=24},I=e=>typeof e?.querySelectorAll==`function`?Array.from(e.querySelectorAll(`img,video,audio,canvas`)).filter(F):[],ee=P(e)?e:null;if(!ee){let t=I(e);t.length===1&&(ee=t[0])}if(!ee){let r=n&&Number.isFinite(n.x)?n:{x:E.left+E.width/2,y:E.top+E.height/2},i=e.parentElement;for(let e=0;i&&i!==t&&e<3;e++,i=i.parentElement){let e=I(i);if(e.length>1)break;if(e.length===1){let t=e[0].getBoundingClientRect();r.x>=t.left&&r.x<=t.right&&r.y>=t.top&&r.y<=t.bottom&&(ee=e[0]);break}}}let te=``;if(!ee&&!m)try{let t=/url\(["']?([^"')]+)["']?\)/.exec((e.ownerDocument?.defaultView||globalThis).getComputedStyle(e).backgroundImage||``);t&&(te=t[1])}catch{}let L=null;if(ee||te){let t=ee,n=t?P(t):`image`,i=String(t?t.currentSrc||t.src||t.getAttribute?.(`src`)||t.querySelector?.(`source`)?.getAttribute(`src`)||``:te),a=/^(https?:|blob:|sm-media:)/i.test(i)&&i.length<=2e3?i:``,o=``;if(/^https?:/i.test(a))try{let e=decodeURIComponent(new URL(a).pathname.split(`/`).pop()||``);/\.[a-z0-9]{2,5}$/i.test(e)&&(o=r(e,80))}catch{}let s=Math.round(t?.naturalWidth||t?.videoWidth||(n===`canvas`?t.width:0)||0),c=Math.round(t?.naturalHeight||t?.videoHeight||(n===`canvas`?t.height:0)||0),l=e=>Number.isFinite(e)&&e>=0?Math.round(e*10)/10:null,u=n===`video`||n===`audio`;L={kind:n,...a?{src:a}:{},...o?{file:o}:{},...s&&c?{natural:{width:s,height:c}}:{},...u&&l(t.duration)!==null?{duration:l(t.duration)}:{},...u?{time:l(t.currentTime)??0,paused:t.paused!==!1}:{},...t&&t!==e?{around:!0}:{},...t&&t!==e&&r(t.getAttribute?.(`alt`)||t.getAttribute?.(`aria-label`)||t.getAttribute?.(`title`),120)?{name:r(t.getAttribute(`alt`)||t.getAttribute(`aria-label`)||t.getAttribute(`title`),120)}:{}}}let R=t=>typeof e.closest==`function`?e.closest(t):null,ne=R(`[data-agent-input-key]`),re=R(`[data-agent-output-key]`),ie=R(`[data-agent-media-asset]`),ae=R(`.react-flow__node[data-id]`),oe=ne?{key:r(ne.getAttribute(`data-agent-input-key`),80),name:r(ne.querySelector(`label,h3,strong,legend`)?.textContent,80)||(e=>{let t=e;for(let e=0;t&&e<5;e++){let e=Array.from(t.children||[]).find(e=>String(e.textContent||``).trim());if(!e||(t=e,!e.children?.length))break}return t&&t!==e?r(t.textContent,80):``})(ne)}:null,se=re?{key:r(re.getAttribute(`data-agent-output-key`),80),...r(re.querySelector(`h3`)?.textContent,80)?{name:r(re.querySelector(`h3`).textContent,80)}:{}}:null,ce=ie?{assetId:r(ie.getAttribute(`data-agent-media-asset`),120),...ie.getAttribute(`data-agent-media-version`)?{versionId:r(ie.getAttribute(`data-agent-media-version`),120)}:{},...ie.getAttribute(`data-agent-media-kind`)?{kind:r(ie.getAttribute(`data-agent-media-kind`),20)}:{},...ie.hasAttribute(`data-agent-media-local`)?{local:!0}:{}}:null,le=r(ae?.getAttribute(`data-id`),120),ue=ae&&typeof ae.className==`string`&&(/(?:^|\s)react-flow__node-([\w-]{1,60})/.exec(ae.className)||[])[1]||``,de=r(R(`[data-stillmade-share]`)?.getAttribute(`data-stillmade-share`),80),fe=R(`li,[role="listitem"],[role="option"],[role="row"],[role="gridcell"]`),pe=fe?.parentElement?Array.from(fe.parentElement.children).filter(e=>e.tagName===fe.tagName&&(e.getAttribute(`role`)||``)===(fe.getAttribute(`role`)||``)):[],me=fe&&fe!==t&&pe.length>1?{index:pe.indexOf(fe)+1,count:pe.length}:null,he=c&&[`range`,`number`].includes(s)&&(i(`min`)||i(`max`))?{...i(`min`)?{min:r(i(`min`),20)}:{},...i(`max`)?{max:r(i(`max`),20)}:{}}:null;return{kind:d,tag:a,...o?{role:o}:{},name:_,text:m,...y?{value:y}:{},state:v,...p?{within:p}:{},selector:S(e,1),path:C.join(` > `).slice(0,300)||`view`,...b.length?{classes:b}:{},...Object.keys(x).length?{data:x}:{},size:{width:Math.round(E.width),height:Math.round(E.height)},region:O,place:j,...M?{heading:M}:{},...N?{around:N}:{},...L?{media:L}:{},...oe?.key?{setting:oe}:{},...se?.key?{output:se}:{},...ce?.assetId?{mediaRef:ce}:{},...le?{nodeId:le,...ue?{nodeType:ue}:{}}:{},...de?{shared:de}:{},...me?{position:me}:{},...he?{bounds:he}:{},...n&&Number.isFinite(n.x)&&Number.isFinite(n.y)?{point:{x:D(n.x-T.left,T.width),y:D(n.y-T.top,T.height)}}:{}}}var uU={button:`Button`,link:`Link`,checkbox:`Checkbox`,choice:`Choice`,tab:`Tab`,menu:`Menu`,"file-picker":`File picker`,slider:`Slider`,"text-field":`Text field`,image:`Image`,video:`Video`,audio:`Audio`,heading:`Heading`,label:`Label`,"list-item":`List item`,list:`List`,table:`Table`,text:`Text`,area:`Area`},dU=(e,t=1e5)=>Number.isFinite(e)&&e>=-t&&e<=t,fU=(e,t)=>typeof e==`string`&&e.length<=t;function pU(e){if(e===null||!e||typeof e!=`object`||!e.rect||!e.padding||!e.cursor)return null;let{rect:t,padding:n,cursor:r}=e;return![`x`,`y`,`width`,`height`].every(e=>dU(t[e]))||t.width<0||t.height<0||![`top`,`right`,`bottom`,`left`].every(e=>dU(n[e],1e4)&&n[e]>=0)||!dU(r.x)||!dU(r.y)?null:{rect:{x:t.x,y:t.y,width:t.width,height:t.height},padding:{top:n.top,right:n.right,bottom:n.bottom,left:n.left},cursor:{x:r.x,y:r.y},selector:fU(e.selector,160)?e.selector:`element`}}function mU(e){if(!e||typeof e!=`object`||Array.isArray(e)||!fU(e.kind,20)||!uU[e.kind]||!fU(e.tag,40)||!fU(e.name,120)||!fU(e.text,240)||!fU(e.selector,160)||!fU(e.path,300))return null;let t=e=>e&&typeof e==`object`&&[`x`,`y`].every(t=>Number.isFinite(e[t])&&e[t]>=0&&e[t]<=1);if(!e.size||!dU(e.size.width)||!dU(e.size.height)||!t(e.region)||!Number.isFinite(e.region.width)||!Number.isFinite(e.region.height))return null;let n={kind:e.kind,tag:e.tag,name:e.name,text:e.text,selector:e.selector,path:e.path,size:{width:Math.round(e.size.width),height:Math.round(e.size.height)},region:{x:e.region.x,y:e.region.y,width:Math.max(0,Math.min(1,e.region.width)),height:Math.max(0,Math.min(1,e.region.height))},place:fU(e.place,20)?e.place:`middle center`,state:Array.isArray(e.state)?e.state.filter(e=>fU(e,20)).slice(0,8):[]};if(fU(e.role,40)&&e.role&&(n.role=e.role),fU(e.value,120)&&e.value&&(n.value=e.value),fU(e.heading,80)&&e.heading&&(n.heading=e.heading),fU(e.around,600)&&e.around&&(n.around=e.around),e.within&&typeof e.within==`object`&&fU(e.within.kind,20)&&uU[e.within.kind]&&fU(e.within.name,120)&&e.within.name&&(n.within={kind:e.within.kind,name:e.within.name}),Array.isArray(e.classes)){let t=e.classes.filter(e=>fU(e,60)).slice(0,4);t.length&&(n.classes=t)}if(e.data&&typeof e.data==`object`&&!Array.isArray(e.data)){let t={};for(let[n,r]of Object.entries(e.data).slice(0,6))fU(n,60)&&fU(r,80)&&(t[n]=r);Object.keys(t).length&&(n.data=t)}if(t(e.point)&&(n.point={x:e.point.x,y:e.point.y}),e.media&&typeof e.media==`object`&&[`image`,`video`,`audio`,`canvas`].includes(e.media.kind)){let t=e.media,r=e=>Number.isFinite(e)&&e>=0&&e<=604800;n.media={kind:t.kind},fU(t.src,2e3)&&/^(https?:|blob:|sm-media:)/i.test(t.src)&&(n.media.src=t.src),fU(t.file,80)&&t.file&&(n.media.file=t.file),fU(t.name,120)&&t.name&&(n.media.name=t.name),t.natural&&dU(t.natural.width)&&dU(t.natural.height)&&t.natural.width>0&&t.natural.height>0&&(n.media.natural={width:Math.round(t.natural.width),height:Math.round(t.natural.height)}),r(t.duration)&&(n.media.duration=t.duration),[`video`,`audio`].includes(t.kind)&&(n.media.time=r(t.time)?t.time:0,n.media.paused=t.paused!==!1),t.around===!0&&(n.media.around=!0)}if(e.position&&Number.isSafeInteger(e.position.index)&&Number.isSafeInteger(e.position.count)&&e.position.index>=1&&e.position.index<=e.position.count&&e.position.count<=1e4&&(n.position={index:e.position.index,count:e.position.count}),e.bounds&&typeof e.bounds==`object`){let t={};fU(e.bounds.min,20)&&(t.min=e.bounds.min),fU(e.bounds.max,20)&&(t.max=e.bounds.max),Object.keys(t).length&&(n.bounds=t)}return fU(e.shared,80)&&/^[\w.:-]{1,80}$/.test(e.shared)&&(n.shared=e.shared),n}function hU(e,t){let n=r=>{let i=r.data;r.source===parent&&i&&i.channel===e&&i.session===t&&(i.op===`theme`&&[`light`,`dark`,`white`].includes(i.mode)&&(document.documentElement.dataset.mode=i.mode),i.op===`dispose`&&removeEventListener(`message`,n))};addEventListener(`message`,n)}function gU(e,t){let n=parent,r=null,i=0,a=!1,o=()=>{if(r=null,a||document.documentElement.hasAttribute(`data-stillmade-stage`))return;let o=Math.ceil(Math.max(document.body.scrollHeight,document.body.getBoundingClientRect().height));o!==i&&(i=o,n.postMessage({channel:e,session:t,op:`content-size`,height:o},`*`))},s=()=>{!a&&r===null&&(r=setTimeout(o,100))},c=new ResizeObserver(s);c.observe(document.body);let l=i=>{i.source===n&&i.data?.channel===e&&i.data?.session===t&&i.data?.op===`dispose`&&(a=!0,clearTimeout(r),c.disconnect(),removeEventListener(`message`,l))};addEventListener(`message`,l),s()}var _U=.8,vU=1.6,yU=.1;function bU({width:e,available:t,heightAt:n,mode:r=`auto`}){let i=[860,520];if(!(e>=600))return 1;let a=e/(i.find(t=>e>=t)||e),o=e/520;if(typeof r==`number`&&Number.isFinite(r))return Math.round(Math.min(Math.max(r,.8),1.6,o)*100)/100;let s=Math.min(1.5,a);if(!(t>0)||s<=1.01||n(1)>t)return 1;let c=Math.floor(s*20)/20;if(n(c)<=t)return c;let l=1,u=s;for(let e=0;e<7;e++){let e=(l+u)/2;n(e)<=t?l=e:u=e}let d=Math.floor(l*20)/20;for(;d>1&&n(d)>t;)d=Math.round((d-.05)*100)/100;return Math.max(1,d)}function xU({canCenter:e=!1,width:t=0,height:n=0,frame:r=t,own:i=!1,padding:a=0,clipped:o=!1,boxes:s=[],drawn:c=[],flows:l=[],kept:u=null}){let d=t*n,f=(e,r)=>{let i=Math.min(e.left+e.width,t)-Math.max(e.left,0),a=Math.min(e.top+e.height,n)-Math.max(e.top,0);return i>0&&a>0&&i*a>=r*d};if(i||a<1||o)return{layout:`own`};if(!(d>0))return{layout:`none`};if(s.some(e=>e.fixed&&f(e,.5)||Math.abs(e.height-n)<=1||e.scrolls&&f(e,.5)||e.touchNone&&f(e,.4))||c.some(e=>f(e,.4)||e.touchNone&&e.width>=300&&e.height>=200))return{layout:`own`};if(!e||r<600)return{layout:`none`};for(let e=1;e<=l.length;e++){let t=l[e-1],n=t.items;if(t.loose||!t.block||!n.length||n.some(e=>e.inline))return{layout:`none`};if(u?.depth===e&&u.frame===r)return{layout:`center`,depth:e};let i=Math.min(...n.map(e=>e.left)),a=Math.max(...n.map(e=>e.right)),o=t.right-t.left;if(Math.abs(i-t.left)>1)return{layout:`none`};if(n.every(e=>Math.abs(e.left-i)<=1&&Math.abs(e.right-a)<=1)&&o-(a-i)>=Math.max(48,o*.1))return{layout:`center`,depth:e};if(n.length!==1)return{layout:`none`}}return{layout:`none`}}function SU(e,t,n,r,i,a){let o=parent,s=document.documentElement,c=typeof CSS<`u`&&CSS.supports?.(`zoom`,`2`)===!0&&`currentCSSZoom`in Element.prototype,l=r===`auto`||typeof r==`number`?r:`auto`,u=null,d=1,f=0,p=null,m=!1,h=!1,g=null,_=[],v=new Set,y=document.querySelector(`[data-stillmade-layout="own"]`)?`own`:`none`,b=()=>o.postMessage({channel:e,session:t,op:`zoom-state`,supported:c&&y!==`own`,zoom:d,auto:l===`auto`},`*`),x=e=>(s.style.zoom=e===1?``:String(e),Math.ceil(document.body.getBoundingClientRect().height)),S=()=>{let e=document.body,t=e=>getComputedStyle(e),n=(e,t)=>parseFloat(e[t])||0,r=t(e),i=[],o=[],l=[],u=c&&s.currentCSSZoom>0?s.currentCSSZoom:1,d=e=>{let t=e.getBoundingClientRect();return{left:t.left/u,top:t.top/u,width:t.width/u,height:t.height/u,right:t.right/u}},f=e,p=r;_=[e];for(let e=0;e<3&&f;e++){let r=[],a=[],s=!1;for(let e of[...f.children].slice(0,200)){if(/^(?:SCRIPT|STYLE|TEMPLATE|LINK|META|NOSCRIPT)$/.test(e.tagName)||e.hasAttribute(`data-stillmade-host`))continue;let n=t(e);if(n.display===`none`||n.display===`contents`)continue;let o=d(e),c=n.position===`fixed`||n.position===`absolute`,l=t=>!/^(?:TEXTAREA|SELECT|INPUT)$/.test(e.tagName)&&/auto|scroll/.test(n[`overflow`+t])&&(t===`Y`?e.scrollHeight>e.clientHeight+1:e.scrollWidth>e.clientWidth+1);i.push({left:o.left,top:o.top,width:o.width,height:o.height,fixed:c,scrolls:l(`Y`)||l(`X`),touchNone:n.touchAction===`none`}),_.push(e),c||/left|right|start|end/.test(n.float)?o.width>=2&&o.height>=2&&(s=!0):o.width>0&&(r.push({left:o.left,right:o.right,inline:n.display.startsWith(`inline`)}),a.push(e))}if(e<2){let e=d(f);o.push({block:[`block`,`flow-root`].includes(p.display),left:e.left+n(p,`borderLeftWidth`)+n(p,`paddingLeft`),right:e.right-n(p,`borderRightWidth`)-n(p,`paddingRight`),items:r,loose:s}),l.push(a)}f=a.length===1?a[0]:null,p=f&&t(f)}if(a===!0&&innerWidth>=600){let n=e.getElementsByTagName(`*`);if(n.length>5e3)for(let e of o)e.loose=!0;else for(let e of n){let n=t(e).position;if(n!==`absolute`&&n!==`fixed`)continue;let r=e.getBoundingClientRect(),i=n===`fixed`?null:e.offsetParent;r.width<2||r.height<2||e.closest(`[data-stillmade-host]`)||o.forEach((t,n)=>{l[n].some(t=>t.contains(e)&&!(i&&t.contains(i)))&&(t.loose=!0)})}}let m=[...document.querySelectorAll(`canvas,svg`)].slice(0,100).map(e=>{let n=d(e);return _.push(e),{left:n.left,top:n.top,width:n.width,height:n.height,touchNone:n.width>=300&&n.height>=200&&t(e).touchAction===`none`}});return{canCenter:a===!0,width:innerWidth/u,height:innerHeight/u,frame:innerWidth,own:!!document.querySelector(`[data-stillmade-layout="own"]`),padding:n(r,`paddingLeft`),clipped:[t(s),r].some(e=>/hidden|clip/.test(e.overflowY)),boxes:i,drawn:m,flows:o,kept:g}},C=()=>{if(!D)return;let e=new Set(_);for(let t of v)e.has(t)||D.unobserve(t);for(let t of e)v.has(t)||D.observe(t);v=e},w=()=>{let e=y;s.removeAttribute(`data-stillmade-center`);let t=S(),n=i(t);y=n.layout,g=y===`center`?{depth:n.depth,frame:t.frame}:null,y===`center`&&s.setAttribute(`data-stillmade-center`,String(n.depth)),y===`own`&&d!==1&&(d=1,s.style.zoom=``,f=Date.now()+400),j(y!==`own`),C(),e===`own`!=(y===`own`)&&b()},T=e=>{if(p=null,h||!document.body||s.hasAttribute(`data-stillmade-stage`)||(w(),!c||y===`own`))return;let t=innerWidth,r=u?.height>0?u.height:innerHeight,i=d;if(!e&&l===`auto`&&x(d)<=r+2){s.style.zoom=d===1?``:String(d);return}d=n({width:t,available:r,heightAt:x,mode:l}),s.style.zoom=d===1?``:String(d),f=Date.now()+400,d!==i&&b()},E=(e,t)=>{h||(m||=e,clearTimeout(p),p=setTimeout(()=>{let e=m;m=!1,T(e)},t??(m?120:250)))},D=typeof ResizeObserver==`function`?new ResizeObserver(()=>E(!1,Math.max(0,f-Date.now())+250)):null,O=n=>{let r=n.data;n.source===o&&r&&r.channel===e&&r.session===t&&(r.op===`zoom-mode`&&(r.mode===`auto`||Number.isFinite(r.mode))&&(l=r.mode,E(!0)),r.op===`zoom-space`&&Number.isFinite(r.height)&&r.height>0&&(u={height:Math.min(2e4,r.height)},s.style.setProperty(`--stillmade-space-height`,`${u.height}px`),E(!0)),r.op===`dispose`&&(h=!0,clearTimeout(p),D?.disconnect(),removeEventListener(`resize`,k),j(!1),removeEventListener(`message`,O),s.style.zoom=``,s.removeAttribute(`data-stillmade-center`)))},k=()=>E(!0),A=n=>{if(!c||!(n.ctrlKey||n.metaKey)||n.altKey)return;let r=n.key===`+`||n.key===`=`?`bigger`:n.key===`-`||n.key===`_`?`smaller`:n.key===`0`?`auto`:null;r&&(n.preventDefault(),o.postMessage({channel:e,session:t,op:`zoom-key`,step:r},`*`))},j=e=>{e?addEventListener(`keydown`,A,!0):removeEventListener(`keydown`,A,!0)};addEventListener(`message`,O),addEventListener(`resize`,k),j(y!==`own`);let M=()=>{document.body&&D&&(D.observe(document.body),v.add(document.body)),b(),E(!0)};document.readyState===`loading`?addEventListener(`DOMContentLoaded`,M,{once:!0}):M()}function CU(e,t,n,r,{minted:i=()=>!1,filming:a=!1}={}){let o=parent,s=document,c=s.documentElement,l=new Map,u=[],d=null,f=null,p=0,m=!1,h=null,g=null,_=null,v=n=>o.postMessage({channel:e,session:t,...n},`*`),y=typeof requestAnimationFrame==`function`?e=>requestAnimationFrame(e):e=>setTimeout(e,16),b=typeof cancelAnimationFrame==`function`?e=>cancelAnimationFrame(e):e=>clearTimeout(e),x=(e,t,n,r)=>{e.addEventListener(t,n,r),u.push([e,t,n,r])},S=()=>d&&d.currentCSSZoom>0?d.currentCSSZoom:1,C=()=>{if(!d){d=s.createElement(`div`),d.setAttribute(`data-stillmade-host`,``),d.setAttribute(`data-stillmade-media`,``),d.setAttribute(`data-mode`,`dark`),d.style.cssText=`position:fixed;inset:0;margin:0;padding:0;border:0;background:none;pointer-events:none;overflow:hidden;overflow:clip;z-index:2147483646`+(a?`;display:none`:``),f=d.attachShadow({mode:`closed`});let e=s.createElement(`style`);e.textContent=r+`.sm-player{position:absolute;left:0;top:0;display:block;max-width:none;background:transparent;contain:layout style}.sm-player[hidden],.sm-frame-photo[hidden]{display:none!important}.sm-player:not([data-live]):not([data-stage]){pointer-events:none}.sm-player[data-live],.sm-player[data-stage],.sm-viewer{pointer-events:auto}.sm-player[data-stage]{position:fixed;inset:0;transform:none!important;width:auto!important;height:auto!important;background:transparent!important}.sm-player[data-stage]::backdrop{background:transparent}.sm-frame-photo{position:absolute;left:0;top:0;pointer-events:none}.sm-frame-photo>.sm-expand-btn{transition:opacity var(--sm-out) var(--sm-ease)}`,f.append(e)}return d.isConnected||s.body.append(d),f},w=typeof ResizeObserver==`function`?new ResizeObserver(()=>E()):null,T=()=>{if(p=0,m)return;let e=S(),t=window.innerWidth,n=window.innerHeight;for(let r of[...l.values()]){let{video:i,box:a}=r;if(!i.isConnected){A(r);continue}if(r===h)continue;i.hasAttribute(`controls`)&&i.removeAttribute(`controls`);let o=i.getBoundingClientRect(),s=!h&&!g&&o.width>=1&&o.height>=1&&o.left+o.width>0&&o.top+o.height>0&&o.left<t&&o.top<n,c=s?[o.left,o.top,o.width,o.height].map(t=>Math.round(t/e*100)/100).join(`,`):``;c!==r.key&&(r.key=c,a.hidden=!s,a.hasAttribute(`data-live`)&&!D(a)&&a.removeAttribute(`data-live`),s&&(a.style.transform=`translate(`+o.left/e+`px,`+o.top/e+`px)`,a.style.width=o.width/e+`px`,a.style.height=o.height/e+`px`))}_?.image&&!ne()&&ie()};function E(){!p&&!m&&(p=y(T))}let D=e=>{try{return e.matches(`:hover`)}catch{return!1}},O=()=>c.hasAttribute(`data-stillmade-pick`),k=e=>{if(m||e?.tagName!==`VIDEO`||l.has(e)||!e.hasAttribute(`controls`)||e.hasAttribute(`data-stillmade-player`))return null;let t=C(),r=s.createElement(`div`),i=s.createElement(`div`);r.tabIndex=-1,r.hidden=!0,i.className=`sm-player-ui`,r.append(i),t.append(r);let a={video:e,box:r,key:null,type:``,style:null,focusable:!e.hasAttribute(`tabindex`)};return a.focusable&&(e.tabIndex=0),a.player=n.attachMediaPlayer(e,{root:r,ui:i,keys:e,theater:!0,label:e.getAttribute(`aria-label`)||e.getAttribute(`title`)||`Video`,onStage:e=>N(a,e)}),r.addEventListener(`pointerleave`,()=>r.removeAttribute(`data-live`)),l.set(e,a),w?.observe(e),E(),a};function A(e){l.delete(e.video),w?.unobserve(e.video),e.player.destroy(),e.box.remove(),e.focusable&&e.video.removeAttribute(`tabindex`)}let j=()=>{if(!m){for(let e of s.querySelectorAll(`video[controls]:not([data-stillmade-player])`))k(e);for(let e of s.querySelectorAll(`.sm-stage>img,.sm-gallery img,img[data-stillmade-expand],[data-stillmade-expand] img`))te(e)}},M=(e,t)=>{if(typeof e.showPopover==`function`)try{t?(e.setAttribute(`popover`,`manual`),e.showPopover()):(e.matches(`:popover-open`)&&e.hidePopover(),e.removeAttribute(`popover`))}catch{}},N=(e,t)=>{let{video:n,box:r}=e;if(t){if(h)return;h=e,e.style=n.getAttribute(`style`),n.style.cssText=(e.style?e.style+`;`:``)+`position:fixed!important;inset:0!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;margin:0!important;padding:0!important;border:0!important;border-radius:0!important;object-fit:contain!important;background:#0A0A0A!important;transform:none!important;z-index:2147483645!important`,M(r,!1),M(n,!0),M(r,!0),c.setAttribute(`data-stillmade-stage`,``),ie();for(let t of l.values())t!==e&&(t.box.hidden=!0,t.key=null);v({op:`media-stage`,on:!0});return}h===e&&(h=null,M(n,!1),e.style==null?n.removeAttribute(`style`):n.setAttribute(`style`,e.style),c.removeAttribute(`data-stillmade-stage`),e.key=null,v({op:`media-stage`,on:!1}),E())},P=e=>e.closest(`[data-stillmade-expand]`),F=e=>{if(e?.tagName!==`IMG`||!(e.currentSrc||e.getAttribute(`src`)))return!1;let t=P(e);return t?t.getAttribute(`data-stillmade-expand`)!==`off`:!e.closest(`.sm-choices,.sm-list,button,a,label`)&&!!i(e.currentSrc||e.src)&&(!!e.parentElement?.matches(`.sm-stage`)||!!e.closest(`.sm-gallery:not([data-size="small"])`))},I=e=>{let t=P(e),n=t?.getAttribute(`data-stillmade-expand`)||``,r=e=>e.tagName===`IMG`?[e]:[...e.querySelectorAll(`img`)],i=t&&n&&n!==`on`?[...s.querySelectorAll(`[data-stillmade-expand]`)].filter(e=>e.getAttribute(`data-stillmade-expand`)===n).flatMap(r):t?r(t):e.closest(`.sm-gallery`)?r(e.closest(`.sm-gallery`)):[e];return[...new Set(i)].filter(t=>t===e||F(t)).slice(0,200)},ee=new Set,te=e=>{!m&&e?.tagName===`IMG`&&!e.hasAttribute(`tabindex`)&&F(e)&&(e.tabIndex=0,ee.add(e))},L=e=>{try{return e.matches(`:focus-visible`)}catch{return!0}},R=e=>{if(g||h)return;let t=I(e),r=t.map(e=>({url:e.currentSrc||e.src,name:e.alt||``}));ie(),te(e),c.setAttribute(`data-stillmade-stage`,``),g=n.openMediaViewer(r,{document:s,container:C(),index:Math.max(0,t.indexOf(e)),opener:e,onClose:()=>{g=null,c.removeAttribute(`data-stillmade-stage`),v({op:`media-stage`,on:!1}),E(),s.activeElement===e&&L(e)&&re(e)}}),g?v({op:`media-stage`,on:!0}):c.removeAttribute(`data-stillmade-stage`)};function ne(){let{wrap:e,button:t,image:r}=_;if(!r.isConnected)return!1;let i=r.getBoundingClientRect(),a=S();return i.width<48||i.height<48?!1:(e.style.transform=`translate(`+i.left/a+`px,`+i.top/a+`px)`,e.style.width=i.width/a+`px`,e.style.height=i.height/a+`px`,n.photoSize(t,{width:i.width/a,height:i.height/a}),!0)}let re=(e,t)=>{let r=C();if(!_){let e=s.createElement(`span`),t=s.createElement(`button`);e.className=`sm-frame-photo`,t.type=`button`,t.className=`sm-expand-btn`,t.setAttribute(`aria-label`,`View full screen`),t.title=`View full screen`,t.innerHTML=n.svg(`maximize`),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),_.image&&R(_.image)}),t.addEventListener(`focusout`,e=>{_?.image&&e.relatedTarget!==_.image&&!D(_.image)&&ie()}),r.addEventListener(`focusin`,e=>{_?.image&&e.target!==t&&ie()}),e.append(t),r.append(e),_={wrap:e,button:t,image:null,timer:0}}if(clearTimeout(_.timer),_.image=e,!ne()){ie();return}_.wrap.hidden=!1,_.button.setAttribute(`data-show`,``),t&&t!==`mouse`&&(_.timer=setTimeout(ie,3e3))};function ie(){_&&(clearTimeout(_.timer),_.image=null,_.button.removeAttribute(`data-show`),_.wrap.hidden=!0)}x(window,`pointerover`,e=>{let t=e.target;if(!(m||t===d||O())){if(t?.tagName===`VIDEO`){let e=l.get(t)||k(t);e&&!h&&!g&&(e.key=null,T(),e.box.hidden||e.box.setAttribute(`data-live`,``))}!h&&!g&&F(t)?re(t,e.pointerType):_?.image&&!(e.pointerType&&e.pointerType!==`mouse`)&&ie()}},{capture:!0,passive:!0}),x(window,`focusin`,e=>{let t=e.target;!m&&!h&&!g&&!O()&&F(t)&&L(t)&&re(t)},!0),x(window,`focusout`,e=>{_?.image&&e.target===_.image&&e.relatedTarget!==d&&!D(e.target)&&ie()},!0),x(window,`keydown`,e=>{let t=e.target;m||h||g||O()||e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey||e.key!==`Enter`&&e.key!==` `||!F(t)||(e.preventDefault(),R(t))}),x(window,`pointerout`,e=>{!e.relatedTarget&&_?.image&&(!e.pointerType||e.pointerType===`mouse`)&&ie()},{capture:!0,passive:!0}),x(window,`pointerdown`,e=>{let t=l.get(e.target);t&&(t.type=e.pointerType||``)},!0);let ae=e=>{let t=l.get(e.target);if(!t||O())return;let n=t.type,r=r=>{let i=new MouseEvent(r,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY});n&&Object.defineProperty(i,"pointerType",{value:n}),t.box.dispatchEvent(i)};e.type===`click`&&(t.type=``,r(`pointerdown`)),r(e.type)};x(window,`click`,ae,!0),x(window,`dblclick`,ae,!0);let oe=e=>{e.target?.tagName===`VIDEO`&&k(e.target)&&E()};for(let e of[`loadstart`,`loadedmetadata`,`focusin`])x(window,e,oe,!0);x(s,`load`,e=>te(e.target),!0),x(window,`scroll`,E,{capture:!0,passive:!0}),x(window,`resize`,E),x(window,`message`,n=>{let r=n.data;n.source===o&&r&&r.channel===e&&r.session===t&&(r.op===`media-stage-end`&&(h?h.player.toggleFullscreen():g?.close()),r.op===`dispose`&&se())});function se(){if(!m){g?.close({silent:!0}),g=null,h&&h.player.toggleFullscreen(),m=!0,p&&b(p),p=0,w?.disconnect();for(let e of[...l.values()])A(e);_&&clearTimeout(_.timer),_=null,d?.remove(),c.removeAttribute(`data-stillmade-stage`);for(let e of ee)e.getAttribute(`tabindex`)===`0`&&e.removeAttribute(`tabindex`);ee.clear();for(let[e,t,n,r]of u)e.removeEventListener(t,n,r)}}s.body&&w?.observe(s.body),j(),s.readyState===`loading`&&x(s,`DOMContentLoaded`,j,{once:!0}),x(window,`load`,j,{once:!0})}function wU(){let e={playFilled:`<path d="M7 4.6v14.8c0 .8.9 1.2 1.5.8l11.4-7.4a1 1 0 0 0 0-1.6L8.5 3.8C7.9 3.4 7 3.8 7 4.6Z" fill="currentColor" stroke="none"></path>`,pauseFilled:`<rect x="6" y="4.5" width="4" height="15" rx="1" fill="currentColor" stroke="none"></rect><rect x="14" y="4.5" width="4" height="15" rx="1" fill="currentColor" stroke="none"></rect>`,volume2:`<path d="M11 5 6 9H2v6h4l5 4V5Z" fill="currentColor"></path><path d="M15.5 8.5a5 5 0 0 1 0 7M19 5a10 10 0 0 1 0 14"></path>`,volumeX:`<path d="M11 5 6 9H2v6h4l5 4V5Z" fill="currentColor"></path><path d="m22 9-6 6M16 9l6 6"></path>`,maximize:`<path d="M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M21 16v3a2 2 0 0 1-2 2h-3M3 16v3a2 2 0 0 0 2 2h3"></path>`,minimize:`<path d="M8 3v3a2 2 0 0 1-2 2H3M21 8h-3a2 2 0 0 1-2-2V3M3 16h3a2 2 0 0 1 2 2v3M16 21v-3a2 2 0 0 1 2-2h3"></path>`,x:`<path d="M6 6 18 18M18 6 6 18"></path>`,chevronLeft:`<path d="m15 6-6 6 6 6"></path>`,chevronRight:`<path d="m9 6 6 6-6 6"></path>`,download:`<path d="M12 4v12M7 11l5 5 5-5"></path><path d="M5 20h14"></path>`,edit:`<path d="M12 20h9"></path><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"></path>`,imageOff:`<path d="M2 2l20 20"></path><path d="M10.41 10.41a2 2 0 1 1-2.83-2.83"></path><path d="M13.5 13.5 6 21"></path><path d="m18 12 3 3"></path><path d="M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59"></path><path d="M21 15V5a2 2 0 0 0-2-2H9"></path>`},t=2e3,n=3e3,r=3e3,i=new WeakMap,a=t=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">`+e[t]+`</svg>`,o=e=>{let t=Math.max(0,Math.floor(Number.isFinite(e)?e:0)),n=Math.floor(t/3600),r=Math.floor(t/60)%60,i=String(t%60).padStart(2,`0`);return n?n+`:`+String(r).padStart(2,`0`)+`:`+i:r+`:`+i},s=e=>typeof e==`string`&&e.startsWith(`sm-media://device/`),c=(e,t,n)=>{let r=e.createElement(t);return n&&(r.className=n),r},l=(e,t,n,r=t)=>{e.setAttribute(`aria-label`,t),e.title=r,e.dataset.icon!==n&&(e.dataset.icon=n,e.innerHTML=a(n))},u=(e,t,n,r)=>{let i=c(e,`button`,`sm-media-btn`);return i.type=`button`,t&&(i.dataset.control=t),l(i,n,r),i},d=(e,t)=>{let n=c(e,`span`,t);return n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,`On another device`),n.title=`On another device`,n.innerHTML=a(`imageOff`),n},f=(e,t)=>{t.width&&(t.width<240||t.height<160?e.setAttribute(`data-size`,`small`):e.removeAttribute(`data-size`))},p=e=>(t,n,r,i)=>{t.addEventListener(n,r,i),e.push([t,n,r,i])};function m(e,a={}){if(!e)return null;let s=i.get(e);if(s)return s;let d=e.ownerDocument,f=d.defaultView||window,m=[],h=p(m),g=e=>f.requestAnimationFrame?f.requestAnimationFrame(e):f.setTimeout(e,16),_=e=>f.cancelAnimationFrame?f.cancelAnimationFrame(e):f.clearTimeout(e),v=a.root,y=a.ui,b=!v,x=!y,S=[];b&&(v=c(d,`div`),e.before(v),v.append(e));let C=a.keys||v;x&&(y=c(d,`div`),v.append(y)),v.classList.add(`sm-player`),y.classList.add(`sm-player-ui`);let w=(e,t)=>{v.hasAttribute(e)||(v.setAttribute(e,t),S.push(e))};w(`data-mode`,`dark`),w(`tabindex`,`0`),w(`role`,`group`),w(`aria-label`,a.label||`Video`);let T=e.hasAttribute(`controls`);e.controls=!1,e.removeAttribute(`controls`),e.playsInline=!0,e.setAttribute(`playsinline`,``),e.setAttribute(`data-stillmade-player`,`on`);let E=c(d,`div`,`sm-player-shade`),D=c(d,`div`,`sm-player-bar nodrag nopan`),O=u(d,`play`,`Play`,`playFilled`),k=u(d,`sound`,`Mute`,`volume2`),A=u(d,`fullscreen`,`Full screen`,`maximize`),j=c(d,`div`,`sm-player-rail`),M=c(d,`div`,`sm-player-track`),N=c(d,`div`,`sm-player-buffered`),P=c(d,`div`,`sm-player-played`),F=c(d,`div`,`sm-player-head`),I=c(d,`div`,`sm-player-knob`),ee=c(d,`div`,`sm-player-tip`),te=c(d,`span`,`sm-player-time`),L=c(d,`span`,`sm-player-now`),R=c(d,`span`,`sm-media-of sm-player-total`);M.append(N,P),F.append(I),j.append(M,F,ee),te.append(L,R),j.dataset.control=`timeline`,j.tabIndex=0,j.setAttribute(`role`,`slider`),j.setAttribute(`aria-label`,`Seek`),j.setAttribute(`aria-valuemin`,`0`),te.dataset.control=`time`,te.setAttribute(`aria-hidden`,`true`),ee.setAttribute(`aria-hidden`,`true`),E.setAttribute(`aria-hidden`,`true`);let ne=c(d,`div`,`sm-player-sound`),re=c(d,`div`,`sm-player-volume`),ie=c(d,`div`,`sm-player-volume-rail`),ae=c(d,`div`,`sm-player-volume-track`),oe=c(d,`div`,`sm-player-volume-level`),se=c(d,`div`,`sm-player-volume-head`),ce=c(d,`div`,`sm-player-volume-knob`);ae.append(oe,se),se.append(ce),ie.append(ae),re.append(ie),ne.append(re,k),ne.dataset.control=`volume`,ie.tabIndex=0,ie.setAttribute(`role`,`slider`),ie.setAttribute(`aria-label`,`Volume`),ie.setAttribute(`aria-orientation`,`vertical`),ie.setAttribute(`aria-valuemin`,`0`),ie.setAttribute(`aria-valuemax`,`100`),D.append(O,j,te,ne,A),y.append(E,D);let le=!1,ue=!1,de=0,fe=Date.now(),pe=!1,me=0,he=0,ge=0,_e=!0,ve=``,ye=``,be=``,z=``,xe=!1,Se=!1,Ce=!1,we=!1,Te=null,Ee=!1,De=0,Oe=!1,ke=0,Ae=!1,je=0,Me=0,Ne=-1,Pe=-1,Fe=-1,Ie=0,Le=0,Re=!1,ze=0,Be=0,Ve=()=>Number.isFinite(e.duration)&&e.duration>0?e.duration:0,He=(e,t)=>{t?v.setAttribute(e,``):v.removeAttribute(e)},Ue=()=>{let t=Ve(),n=pe?me*t:e.currentTime||0,r=t?Math.min(1,Math.max(0,n/t)):0;r!==Ne&&(Ne=r,P.style.transform=`scaleX(`+r+`)`,F.style.transform=`translateX(`+r*100+`%)`);let i=Math.floor(n);(i!==Pe||t!==Fe)&&(Pe=i,Fe=t,L.textContent=o(n),R.textContent=` / `+o(t),j.setAttribute(`aria-valuemax`,String(Math.round(t))),j.setAttribute(`aria-valuenow`,String(Math.min(i,Math.round(t)))),j.setAttribute(`aria-valuetext`,o(n)+` of `+o(t)))},We=()=>{he=0,!le&&(Ue(),!e.paused&&!e.ended&&_e&&(he=g(We)))},Ge=()=>{!he&&!le&&(he=g(We))},Ke=()=>{let t=Ve(),n=e.buffered;t&&n&&n.length&&(N.style.transform=`scaleX(`+Math.min(1,n.end(n.length-1)/t)+`)`)},qe=()=>!!f.matchMedia?.(`(hover: none)`)?.matches,Je=e=>e.pointerType?e.pointerType===`mouse`:!qe(),Ye=e=>{try{return e.matches(`:focus-visible`)}catch{return!0}},Xe=()=>!le&&!e.paused&&!e.ended&&!pe&&!Re&&!Ee&&!Oe&&!Te,Ze=e=>{ue!==e&&(ue=e,He(`data-idle`,e))},Qe=()=>{if(de=0,!Xe())return;let e=t-(Date.now()-fe);if(e>10){de=f.setTimeout(Qe,e);return}Ze(!0)},$e=()=>{if(!Xe()){de&&=(f.clearTimeout(de),0),Ze(!1);return}!de&&!ue&&(de=f.setTimeout(Qe,Math.max(10,t-(Date.now()-fe))))},et=()=>{fe=Date.now(),Ze(!1),$e()},tt=()=>{let e=!le&&!(Se||we||pe||Re||Ee||Oe);e!==Ce&&(Ce=e,He(`data-away`,e))},nt=()=>{ke&&=(f.clearTimeout(ke),0),Oe=!1},rt=()=>{Ae||le||(Ae=!0,Oe=!0,ke=f.setTimeout(()=>{ke=0,Oe=!1,tt(),$e()},r),tt(),$e())},it=()=>{Ee=!0,De&&f.clearTimeout(De),De=f.setTimeout(()=>{De=0,Ee=!1,tt(),$e()},n),tt(),et()},at=()=>{if(e.paused||e.ended){let t=e.play();t&&typeof t.catch==`function`&&t.catch(()=>{})}else e.pause()},ot=t=>{let n=Ve();n&&(e.currentTime=Math.min(n,Math.max(0,t)),Ge())},st=t=>ot((e.currentTime||0)+t),ct=t=>{t>0&&e.muted&&(e.muted=!1),e.volume=Math.min(1,Math.max(0,Math.round(((e.volume||0)+t)*10)/10))},lt=()=>{let t=!e.paused&&!e.ended;l(O,t?`Pause`:`Play`,t?`pauseFilled`:`playFilled`),He(`data-playing`,t),et(),Ge()},ut=()=>{let t=e.muted||e.volume===0,n=t?0:Math.min(1,Math.max(0,e.volume)),r=Math.round(n*100);oe.style.transform=`scaleY(`+n+`)`,se.style.transform=`translateY(`+-n*100+`%)`,ie.setAttribute(`aria-valuenow`,String(r)),ie.setAttribute(`aria-valuetext`,t?`Muted`:r+`%`),k.setAttribute(`aria-pressed`,String(!!e.muted)),l(k,`Mute`,t?`volumeX`:`volume2`,e.muted?`Unmute`:`Mute`)},dt=()=>ve===`theater`||d.fullscreenElement===v,ft=()=>{let e=dt();l(A,e?`Exit full screen`:`Full screen`,e?`minimize`:`maximize`)},pt=()=>{if(ve=`theater`,v.setAttribute(`data-stage`,`theater`),typeof v.showPopover==`function`)try{v.setAttribute(`popover`,`manual`),v.showPopover()}catch{v.removeAttribute(`popover`)}ft(),a.onStage?.(!0)},mt=()=>{if(ve===`theater`){if(ve=``,v.hasAttribute(`popover`)){try{v.hidePopover()}catch{}v.removeAttribute(`popover`)}v.removeAttribute(`data-stage`),ft(),a.onStage?.(!1)}},ht=()=>{let e=v.requestFullscreen;if(a.theater||typeof e!=`function`||d.fullscreenEnabled===!1){pt();return}let t;try{t=e.call(v)}catch{pt();return}t&&typeof t.then==`function`?t.then(ft,pt):ft()},gt=()=>{if(ve===`theater`)mt();else if(d.fullscreenElement===v){let e=d.exitFullscreen?.();e&&typeof e.catch==`function`&&e.catch(()=>{})}},_t=()=>{dt()?gt():ht()},B=()=>{let e=j.getBoundingClientRect();je=e.left,Me=e.width},vt=e=>Me>0?Math.min(1,Math.max(0,(e-je)/Me)):0,yt=e=>{let t=Math.min(Math.max(e-je,22),Math.max(22,Me-22)),n=o(Ve()*vt(e));ee.style.transform=`translateX(`+t+`px) translateX(-50%)`,ee.textContent!==n&&(ee.textContent=n)},bt=()=>{let t=Ve();t&&(e.currentTime=me*t),Ue()},xt=()=>{ge||=g(()=>{ge=0,le||bt()})},St=()=>{pe&&(ge&&=(_(ge),0),bt(),pe=!1,j.removeAttribute(`data-drag`),z===`touch`?it():(tt(),$e()))};h(j,`pointerenter`,B),h(j,`pointerdown`,e=>{if(!(e.button>0)){B(),pe=!0,tt(),j.setAttribute(`data-drag`,``);try{j.setPointerCapture?.(e.pointerId)}catch{}me=vt(e.clientX),xt(),yt(e.clientX),et()}}),h(j,`pointermove`,e=>{yt(e.clientX),pe&&(me=vt(e.clientX),xt())}),h(j,`pointerup`,St),h(j,`pointercancel`,St),h(j,`lostpointercapture`,St);let Ct=()=>{let e=ae.getBoundingClientRect();Ie=e.top,Le=e.height},wt=e=>Le>0?Math.min(1,Math.max(0,1-(e-Ie)/Le)):0,Tt=()=>{Be=0,!le&&(e.volume=Math.round(ze*100)/100,e.muted=ze===0)},Et=()=>{Be||=g(Tt)},Dt=()=>{Re&&(Be&&(_(Be),Tt()),Re=!1,re.removeAttribute(`data-drag`),tt(),$e())};h(ie,`pointerdown`,e=>{if(!(e.button>0)){e.stopPropagation(),Ct(),Re=!0,re.setAttribute(`data-drag`,``),tt();try{ie.setPointerCapture?.(e.pointerId)}catch{}ze=wt(e.clientY),Et(),et()}}),h(ie,`pointermove`,e=>{Re&&(ze=wt(e.clientY),Et())}),h(ie,`pointerup`,Dt),h(ie,`pointercancel`,Dt),h(ie,`lostpointercapture`,Dt),h(O,`click`,at),h(k,`click`,()=>{e.muted||e.volume===0?(e.muted=!1,e.volume===0&&(e.volume=1)):e.muted=!0}),h(A,`click`,_t),h(v,`pointerdown`,e=>{z=Je(e)?`mouse`:`touch`,xe=Ce||ue,z===`touch`&&!xe&&it()}),h(v,`click`,e=>{let t=z?z===`touch`:qe(),n=z?xe:Ce||ue;if(z=``,!D.contains(e.target)){if(!t){at(),et();return}n||at(),it()}}),h(v,`dblclick`,e=>{D.contains(e.target)||(e.preventDefault(),_t())}),h(v,`pointerenter`,e=>{Je(e)&&(nt(),Se=!0,tt(),et())}),h(v,`pointermove`,e=>{Je(e)&&(fe=Date.now(),Se||(nt(),Se=!0,tt()),ue&&Ze(!1),de||$e())}),h(v,`pointerleave`,e=>{Je(e)&&(Se=!1,tt())});let Ot=e=>!!e&&(v.contains(e)||C.contains(e)),kt=e=>{let t=Ye(e.target);t&&(we=!0),Te=t&&e.target!==v&&e.target!==C?e.target:null,tt(),et()},At=e=>{Te=null,Ot(e.relatedTarget)||(we=!1,tt()),$e()};for(let e of C===v?[v]:[v,C])h(e,`focusin`,kt),h(e,`focusout`,At);let jt=t=>{if(t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey)return;we||(we=!0,tt());let n=t.key,r=n&&n.length===1?n.toLowerCase():n,i=Ve();if((n===` `||n===`Enter`)&&t.target?.closest?.(`button`))return;let a=!0;n===` `||r===`k`?at():t.target===ie&&/^Arrow(Up|Down|Left|Right)$/.test(n||``)?ct(n===`ArrowUp`||n===`ArrowRight`?.1:-.1):t.target===ie&&(n===`Home`||n===`End`)?(e.volume=+(n===`End`),e.muted=n===`Home`):n===`ArrowRight`||n===`ArrowLeft`?st((n===`ArrowRight`?1:-1)*(t.shiftKey?10:5)):r===`l`||r===`j`?st(r===`l`?10:-10):n===`ArrowUp`||n===`ArrowDown`?ct(n===`ArrowUp`?.1:-.1):r===`m`?e.muted=!e.muted:r===`f`?_t():n===`Home`?ot(0):n===`End`?ot(i):n===`PageUp`||n===`PageDown`?st((n===`PageUp`?1:-1)*i/10):/^[0-9]$/.test(n||``)?ot(i*Number(n)/10):n===`Escape`&&ve===`theater`?(mt(),t.stopPropagation()):a=!1,a&&t.preventDefault(),et()};for(let e of C===v?[v]:[v,C])h(e,`keydown`,jt);h(e,`play`,lt),h(e,`pause`,lt),h(e,`ended`,lt),h(e,`seeked`,Ge),h(e,`durationchange`,Ge),h(e,`loadedmetadata`,Ge),h(e,`progress`,Ke),h(e,`volumechange`,ut),h(e,`emptied`,()=>{Ne=-1,Pe=-1,N.style.transform=`scaleX(0)`,Ge()}),h(d,`fullscreenchange`,ft);let Mt=typeof f.ResizeObserver==`function`?new f.ResizeObserver(e=>{let t=e[e.length-1].contentRect,n=t.width;if(!n)return;let r=n<180?`micro`:n<240?`tiny`:n<300?`compact`:n<400?`narrow`:``;r!==ye&&(ye=r,ye?v.setAttribute(`data-size`,ye):v.removeAttribute(`data-size`));let i=!(t.height>0)||t.height>=200?``:t.height<150?`none`:`short`;i!==be&&(be=i,be?v.setAttribute(`data-volume-room`,be):v.removeAttribute(`data-volume-room`))}):null,Nt=typeof f.IntersectionObserver==`function`?new f.IntersectionObserver(e=>{_e=e[e.length-1].isIntersecting,_e&&(Ge(),rt())}):null;Mt?.observe(v),Nt?.observe(v);let Pt=()=>{if(!le){gt(),le=!0,i.delete(e);for(let[e,t,n,r]of m)e.removeEventListener(t,n,r);Mt?.disconnect(),Nt?.disconnect(),he&&_(he),ge&&_(ge),de&&f.clearTimeout(de),De&&f.clearTimeout(De),ke&&f.clearTimeout(ke),E.remove(),D.remove(),x&&y.remove();for(let e of[`data-away`,`data-idle`,`data-size`,`data-volume-room`,`data-stage`,`data-playing`,...S])v.removeAttribute(e);e.removeAttribute(`data-stillmade-player`),T&&e.setAttribute(`controls`,``),b&&v.replaceWith(e)}};try{Se=v.matches(`:hover`)}catch{}let Ft=d.activeElement;Ot(Ft)&&Ye(Ft)&&(we=!0,Te=Ft!==v&&Ft!==C?Ft:null),tt(),lt(),ut(),ft(),Ue(),Ke();let It={root:v,video:e,destroy:Pt,toggleFullscreen:_t,isFullscreen:dt};return i.set(e,It),It}function h(t,n={}){let r=n.document||document,i=[],o=p(i),l=(Array.isArray(t)?t:[t]).filter(e=>e&&typeof e.url==`string`&&e.url);if(!l.length)return null;let f=n.opener||r.activeElement,h=c(r,`dialog`,`sm-viewer`),g=c(r,`div`,`sm-viewer-stage`),_=c(r,`div`,`sm-viewer-top`),v=c(r,`div`,`sm-viewer-foot`),y=c(r,`span`,`sm-viewer-count`),b=c(r,`span`,`sm-viewer-name`),x=u(r,`close`,`Close`,`x`),S=u(r,`previous`,`Previous`,`chevronLeft`),C=u(r,`next`,`Next`,`chevronRight`);h.setAttribute(`data-mode`,`dark`),h.setAttribute(`data-stillmade-host`,``),h.setAttribute(`aria-label`,n.label||`Full screen view`),y.setAttribute(`aria-live`,`polite`),S.classList.add(`sm-viewer-nav`,`sm-viewer-previous`),C.classList.add(`sm-viewer-nav`,`sm-viewer-next`),_.append(x),v.append(y,b),h.append(g,_,S,C,v);let w=0,T=null,E=0,D=!1,O=t=>{for(let e of[..._.children])e!==x&&e.remove();let i=typeof n.actions==`function`?n.actions(t,w):n.actions;for(let n of Array.isArray(i)?i:[]){if(!n||!n.label)continue;let i=c(r,n.href?`a`:`button`,`sm-media-btn`);if(i.setAttribute(`aria-label`,n.label),i.title=n.label,e[n.icon]?i.innerHTML=a(n.icon):(i.textContent=n.label,i.classList.add(`sm-media-btn-text`)),n.href?(i.href=n.href,i.rel=`noopener noreferrer`,n.download!=null&&n.download!==!1&&i.setAttribute(`download`,n.download===!0?``:String(n.download))):i.type=`button`,typeof n.onClick==`function`){let e=w;i.addEventListener(`click`,r=>n.onClick(t,e,r))}_.insertBefore(i,x)}},k=e=>{let t=l.length;w=((Math.trunc(e)||0)%t+t)%t;let i=l[w],a=++E;T?.destroy(),T=null,g.replaceChildren(),S.hidden=C.hidden=y.hidden=t<2,b.hidden=!i.name,v.hidden=t<2&&!i.name;let o=c(r,`span`,`sm-media-of`);o.textContent=` of `+t,y.replaceChildren(String(w+1),o),b.textContent=i.name||``,O(i);let u=e=>{if(D||a!==E)return;if(!e){g.replaceChildren(d(r,`sm-viewer-off`));return}if(i.kind===`video`){let t=c(r,`div`,`sm-player`),a=c(r,`video`);t.setAttribute(`data-fill`,``),a.preload=`metadata`,a.autoplay=!0,a.src=e,i.poster&&!s(i.poster)&&(a.poster=i.poster),t.append(a),g.replaceChildren(t),T=m(a,{root:t,label:i.name||`Video`}),n.onShow?.(a,i,w);return}let t=c(r,`img`,`sm-viewer-media`);t.alt=i.alt??i.name??``,t.decoding=`async`,t.src=e,g.replaceChildren(t),n.onShow?.(t,i,w)};s(i.url)?typeof n.resolve==`function`?Promise.resolve().then(()=>n.resolve(i.url)).then(e=>u(e||null),()=>u(null)):u(null):u(i.url)},A=e=>{k(w+e),n.onIndexChange?.(w)},j=({silent:e=!1}={})=>{if(!D){D=!0,E++,T?.destroy(),T=null;for(let[e,t,n,r]of i)e.removeEventListener(t,n,r);try{h.open&&h.close()}catch{}h.remove(),f&&f.isConnected&&typeof f.focus==`function`&&f.focus({preventScroll:!0}),e||n.onClose?.()}};o(x,`click`,()=>j()),o(S,`click`,()=>A(-1)),o(C,`click`,()=>A(1)),o(h,`keydown`,e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),j();return}e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey||l.length<2||(e.key===`ArrowRight`||e.key===`ArrowLeft`)&&(e.preventDefault(),A(e.key===`ArrowRight`?1:-1))}),o(h,`cancel`,e=>{e.preventDefault(),j()});let M=!1,N=null;return o(g,`pointerdown`,e=>{M=e.target===g}),o(g,`click`,e=>{M&&e.target===g&&j(),M=!1}),o(g,`touchstart`,e=>{N=e.touches?.length===1&&!e.target?.closest?.(`.sm-player-bar`)?e.touches[0].clientX:null},{passive:!0}),o(g,`touchend`,e=>{if(N==null||l.length<2)return;let t=e.changedTouches[0].clientX-N;N=null,Math.abs(t)>50&&A(t<0?1:-1)},{passive:!0}),(n.container||r.body).append(h),typeof h.showModal==`function`?h.showModal():h.setAttribute(`open`,``),k(n.index||0),x.focus({preventScroll:!0}),{dialog:h,show:k,close:j,update(e,t=w){let n=(Array.isArray(e)?e:[e]).filter(e=>e&&typeof e.url==`string`&&e.url);n.length&&(l=n,k(t))},get index(){return w}}}function g(e,t={}){let i=e.ownerDocument,o=i.defaultView||window,s=e.tagName===`IMG`?e:e.querySelector(`img`),l=e.tagName===`IMG`?e.parentElement:e,u=()=>s&&(s.currentSrc||s.getAttribute(`src`))?[{url:s.currentSrc||s.src,name:s.alt||``}]:[],d=typeof t.items==`function`?t.items():t.items||u();if(!l||!d.length)return null;let p=t.label||`View full screen`,m=c(i,`button`,`sm-expand-btn nodrag nopan`);m.type=`button`,m.setAttribute(`aria-label`,p),m.title=p,m.innerHTML=a(`maximize`);let g=e=>{if(e.preventDefault(),e.stopPropagation(),typeof t.onOpen==`function`){t.onOpen(e);return}h(typeof t.items==`function`?t.items():t.items||u(),{document:i,index:t.index||0,opener:m,actions:t.actions,resolve:t.resolve,onClose:t.onClose})},_=0,v=e=>{e.pointerType&&e.pointerType!==`mouse`&&!m.contains(e.target)&&(m.setAttribute(`data-show`,``),o.clearTimeout(_),_=o.setTimeout(()=>m.removeAttribute(`data-show`),n))},y=typeof o.ResizeObserver==`function`?new o.ResizeObserver(e=>f(m,e[e.length-1].contentRect)):null,b=typeof o.IntersectionObserver==`function`?new o.IntersectionObserver(e=>{let t=e[e.length-1];if(!t.isIntersecting)return;b.disconnect();let n=t.boundingClientRect;n.width<240||n.height<160||(m.setAttribute(`data-show`,``),o.clearTimeout(_),_=o.setTimeout(()=>m.removeAttribute(`data-show`),r))}):null,x=e=>{e.pointerType&&e.pointerType!==`mouse`||(o.clearTimeout(_),m.removeAttribute(`data-show`))};return m.addEventListener(`click`,g),l.addEventListener(`pointerdown`,v),l.addEventListener(`pointerenter`,x),l.classList.add(`sm-expand-host`),l.append(m),y?.observe(s||l),b?.observe(s||l),{button:m,destroy(){m.removeEventListener(`click`,g),l.removeEventListener(`pointerdown`,v),l.removeEventListener(`pointerenter`,x),y?.disconnect(),b?.disconnect(),o.clearTimeout(_),m.remove()}}}function _(e=document){let t=[],n=[];for(let n of e.querySelectorAll(`video[controls]:not([data-stillmade-player])`))t.push(m(n,{label:n.getAttribute(`aria-label`)||void 0}));let r=[...e.querySelectorAll(`[data-stillmade-expand]:not([data-stillmade-expand="off"])`)].filter(e=>{let t=e.tagName===`IMG`?e:e.querySelector(`img`),n=e.tagName===`IMG`?e.parentElement:e;return t&&t.getAttribute(`src`)&&n&&!n.querySelector(`:scope > .sm-expand-btn`)}),i=e=>{let t=e.tagName===`IMG`?e:e.querySelector(`img`);return{url:t.currentSrc||t.src,name:t.alt||``}};for(let e of r){let t=e.getAttribute(`data-stillmade-expand`),a=t&&t!==`on`?r.filter(e=>e.getAttribute(`data-stillmade-expand`)===t):[e],o=g(e,{items:()=>a.map(i),index:a.indexOf(e)});o&&n.push(o)}return{players:t,buttons:n}}return{ICONS:e,svg:a,formatTime:o,isDeviceMediaUrl:s,photoSize:f,attachMediaPlayer:m,openMediaViewer:h,attachPhotoExpand:g,enhance:_}}var{ICONS:TU,formatTime:EU,isDeviceMediaUrl:DU,photoSize:OU,attachMediaPlayer:kU,openMediaViewer:AU,attachPhotoExpand:jU,enhance:MU}=wU(),NU=`/* StillMade media player, photo button and full-screen viewer: option A "Cream blocks" (owner, November 2, 2026). Solid cream
1841
1841
  rounded squares with ink icons, a thick cream timeline, the time in the thin italic display face. The chrome sits on the
1842
1842
  picture, so it is the same in Light, Dark and White; the letterbox is ink. Rounded squares only, never circles
1843
1843
  (UI_AESTHETIC "Icon preference"). Everything that moves per frame moves by transform; nothing uses backdrop-filter.
@@ -1980,7 +1980,7 @@ label:has(> textarea) {
1980
1980
  @media (prefers-reduced-motion:reduce){
1981
1981
  .sm-player *,.sm-viewer,.sm-viewer *,.sm-expand-btn{transition:none!important;animation:none!important}
1982
1982
  }
1983
- `,jU=`sm.blockZoom.`;function MU(e,t){try{if(!e)return;t===`auto`?localStorage.removeItem(jU+e):localStorage.setItem(jU+e,String(t))}catch{}}function NU(e){if(!e)return 0;let t=e.parentElement;for(;t&&t!==document.body;){let e=getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.clientHeight>0)break;t=t.parentElement}let n=t&&t!==document.body?t.getBoundingClientRect():{top:0},r=t&&t!==document.body?t.clientHeight:innerHeight,i=e.getBoundingClientRect().top-n.top+(t&&t!==document.body?t.scrollTop:scrollY);return Math.max(280,Math.round(r-Math.min(i,r*.5)-24))}function PU(e){if(!e)return 0;let t=e.parentElement;for(;t&&t!==document.body;){let e=getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.clientHeight>0)break;t=t.parentElement}if(!t||t===document.body)return NU(e);let n=t.getBoundingClientRect(),r=t.scrollTop,i=e.getBoundingClientRect(),a=i.top-n.top+r,o=i.bottom-n.top+r,s=o;for(let e of t.children)/fixed|absolute/.test(getComputedStyle(e).position)||(s=Math.max(s,e.getBoundingClientRect().bottom-n.top+r));let c=s-o+(parseFloat(getComputedStyle(t).paddingBottom)||0);return Math.max(280,Math.round(t.clientHeight*.7),Math.floor(t.clientHeight-Math.min(a,t.clientHeight*.5)-c))}var FU=(e,t)=>Math.round(Math.min(hU,Math.max(mU,e+t))*100)/100,IU=(0,v.createContext)(null),LU=null,RU=new Set,zU=()=>LU;function BU(e){return RU.add(e),()=>RU.delete(e)}function VU(e,t,n){let r=globalThis.modernScreenshot;if(delete globalThis.modernScreenshot,!r)return;let i=!1,a=[],o=new WeakSet,s=e=>{if(e?.nodeType!==1||o.has(e))return;let t=e.getBoundingClientRect();t.width*t.height<400||t.height>900||(a.push({x:t.left,y:t.top,width:t.width,height:t.height}),a.length>40&&a.shift())},c=()=>{i||(i=!0,setTimeout(()=>{i=!1,n({channel:e,session:t,op:`view-changed`,rects:a.splice(0)},`*`)},100))},l=e=>e.type===`childList`&&[...e.addedNodes,...e.removedNodes].every(e=>o.has(e))||o.has(e.target);new MutationObserver(e=>{let t=e.filter(e=>!l(e));if(t.length){for(let e of t)if(e.type===`childList`)for(let t of e.addedNodes)s(t.nodeType===1?t:t.parentElement);else e.type===`characterData`&&s(e.target.parentElement);c()}}).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});for(let e of[`input`,`change`,`scroll`])addEventListener(e,c,!0);addEventListener(`message`,async i=>{let a=i.data;if(i.source!==parent||!a||a.channel!==e||a.session!==t||a.op!==`capture-view`||typeof a.id!=`string`)return;let s=Math.max(0,Number(a.top)||0),c=Math.min(4e3,Math.max(1,Number(a.height)||innerHeight)),l=document.createElement(`div`);o.add(l);try{l.style.cssText=`all:initial;position:fixed;left:-99999px;top:0;visibility:hidden`;let i=l.attachShadow({mode:`closed`}),o=document.createElement(`div`);i.append(o),document.documentElement.append(l);let u=await r.createContext(document.body,{scale:2,width:innerWidth,height:c,timeout:4e3,features:{restoreScrollPosition:!0},filter:e=>e!==l&&!(/^(VIDEO|AUDIO)$/.test(e.tagName)&&(e.readyState<2||!e.getClientRects().length)),style:{margin:getComputedStyle(document.body).margin,overflow:`visible`,transform:`translateY(${-s}px)`}});u.sandbox={contentWindow:{document:{createElement:e=>document.createElement(e),createElementNS:(e,t)=>document.createElementNS(e,t),body:o},getComputedStyle:(e,t)=>getComputedStyle(e,t)},remove(){}};let d=await createImageBitmap(await r.domToCanvas(u));n({channel:e,session:t,op:`capture-view-result`,id:a.id,bitmap:d},`*`,[d])}catch(r){n({channel:e,session:t,op:`capture-view-result`,id:a.id,error:String(r?.message||r).slice(0,300)},`*`)}finally{l.remove()}})}Et();function HU(e){return B(Array.isArray(e)&&e.length>0&&e.length<=128&&e.every(e=>typeof e==`string`&&/^[a-f0-9]{64}$/.test(e)),`SCHEMA`,`Provide 1–128 exact source digests`),[...new Set(e)]}async function UU(e){mt(e);let t=e?.stages&&e.packages||[];return B(Array.isArray(t)&&t.length<128,`LIMIT`,`Too many packaged Blocks for execution review`),HU(await Promise.all([e,...t].map(e=>gt(e))))}async function WU(e){let t=await UU(e),n=new Set(t),r=e?.stages?e.packages||[]:[e],i=e=>{B(e&&typeof e.digest==`string`&&/^[a-f0-9]{64}$/.test(e.digest),`SCHEMA`,`Block lineage needs exact source digests`),n.add(e.digest),B(n.size<=128,`LIMIT`,`Block source and ancestry exceed the security review limit`)};for(let e of r){let t=e.manifest?.provenance;t?.remixedFrom!==void 0&&i(t.remixedFrom);let n=t?.remixAncestors??[];B(Array.isArray(n)&&n.length<=64,`SCHEMA`,`Block ancestry must contain at most 64 exact source references`),n.forEach(i);let r=e.portable?.lineage?.parents??[];B(Array.isArray(r)&&r.length<=16,`SCHEMA`,`Portable lineage must contain at most 16 exact source references`),r.forEach(i)}return HU([...n])}var GU=`stillmade.block-security.v1`,KU=new Map;function qU(e,t){let n=e?.revision||0,r=t.revision||0;return{revision:Math.max(n,r),published:t.published||e?.published===!0,revoked:n>r?e.revoked:n===r?t.revoked||e?.revoked===!0:t.revoked}}function JU(){try{let e=JSON.parse(globalThis.localStorage?.getItem(GU)||`{}`);for(let[t,n]of Object.entries(e))/^[a-f0-9]{64}$/.test(t)&&n&&typeof n.revoked==`boolean`&&typeof n.published==`boolean`&&Number.isInteger(n.revision)&&n.revision>=0&&KU.set(t,qU(KU.get(t),n))}catch{}return KU}function YU(e){let t=JU();for(let n of e){let e=t.get(n.digest);(n.revoked||n.published||e)&&t.set(n.digest,qU(e,n))}try{globalThis.localStorage?.setItem(GU,JSON.stringify(Object.fromEntries(t)))}catch{}}var XU=()=>Object.assign(Error(`This exact Block version has been quarantined by StillMade. Use a reviewed replacement.`),{code:`BLOCK_REVOKED`});async function ZU(e,{signal:t}={}){let n=await WU(e),r=JU();if(t?.aborted)throw Object.assign(Error(`Cancelled`),{code:`CANCELLED`});let i=new AbortController,a=()=>i.abort();t?.addEventListener(`abort`,a,{once:!0});let o=setTimeout(a,3e3),s;try{let e=await fetch(`/api/blocks/runtime-policy`,{method:`POST`,credentials:`omit`,cache:`no-store`,headers:{"Content-Type":`application/json`},body:JSON.stringify({digests:n}),signal:i.signal});if(!e.ok)throw Error(`Block security check unavailable`);if(s=await e.json(),!Array.isArray(s.digests)||s.digests.length!==n.length||new Set(s.digests.map(e=>e.digest)).size!==n.length||s.digests.some(e=>!n.includes(e.digest)||typeof e.revoked!=`boolean`||typeof e.published!=`boolean`||!Number.isInteger(e.revision)||e.revision<0))throw Error(`Invalid security response`);YU(s.digests)}catch{if(t?.aborted)throw Object.assign(Error(`Cancelled`),{code:`CANCELLED`});if(n.some(e=>r.get(e)?.revoked))throw XU();if(n.some(e=>r.get(e)?.published))throw Object.assign(Error(`Reconnect to check the safety of this published Block before running it.`),{code:`REVOCATION_UNAVAILABLE`});return{checked:!1}}finally{clearTimeout(o),t?.removeEventListener(`abort`,a)}if(n.some(e=>JU().get(e)?.revoked))throw XU();return{checked:!0}}ut();var QU=(e,t)=>Object.freeze({kind:e,mimeType:t}),$U=Object.freeze({png:QU(`image`,`image/png`),jpg:QU(`image`,`image/jpeg`),jpeg:QU(`image`,`image/jpeg`),webp:QU(`image`,`image/webp`),gif:QU(`image`,`image/gif`),mp4:QU(`video`,`video/mp4`),mov:QU(`video`,`video/quicktime`),webm:QU(`video`,`video/webm`),mp3:QU(`audio`,`audio/mpeg`),wav:QU(`audio`,`audio/wav`),m4a:QU(`audio`,`audio/mp4`),aac:QU(`audio`,`audio/aac`),ogg:QU(`audio`,`audio/ogg`),...Object.fromEntries(Object.entries(it).map(([e,t])=>[e,QU(`file`,t)]))});Object.freeze(Object.fromEntries(Object.entries($U).filter(([,e])=>e.kind!==`file`))),Object.freeze({"text/csv":[`application/vnd.ms-excel`,`text/x-csv`,`application/csv`],"text/markdown":[`text/x-markdown`,`text/plain`],"application/zip":[`application/x-zip-compressed`],"application/json":[`text/json`]}),Object.freeze([`image`,`video`,`audio`]);var eW=Object.freeze({png:`PNG`,jpg:`JPEG`,webp:`WebP`,gif:`GIF`,mp4:`MP4`,mov:`MOV`,webm:`WebM`,mp3:`MP3`,wav:`WAV`,m4a:`M4A`,aac:`AAC`,ogg:`OGG`,pdf:`PDF`,txt:`TXT`,csv:`CSV`,md:`Markdown`,json:`JSON`,zip:`ZIP`}),tW=e=>Object.entries($U).filter(([t,n])=>e.includes(n.kind)&&eW[t]).map(([e])=>eW[e]),nW=e=>e.length>1?`${e.slice(0,-1).join(`, `)}, or ${e.at(-1)}`:e[0],rW=e=>nW([...new Set(tW(e))]);async function iW(e,t,{guard:n,loadBytes:r}={}){let i=typeof t==`string`&&e?.files&&Object.hasOwn(e.files,t)?e.files[t]:null;if(!i||!HH(i))throw Object.assign(Error(`${String(t).slice(0,160)} is not one of this view's code files.`),{code:`VIEW`});if(typeof n!=`string`||!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(n))throw Object.assign(Error(`Invalid interface guard`),{code:`VIEW`});let a=oW.get(i.sha256);if(!a)for(a=(async()=>{let n=await _H(e,t,await r(i.sha256)),a;try{a=new TextDecoder(`utf-8`,{fatal:!0}).decode(n)}catch{throw Object.assign(Error(`Code file ${t} is not UTF-8 text.`),{code:`VIEW`})}return TH(a,t,aW)})(),oW.set(i.sha256,a),a.catch(()=>oW.delete(i.sha256));oW.size>sW;)oW.delete(oW.keys().next().value);return(await a).replaceAll(aW,n)}var aW,oW,sW,cW=o((()=>{vH(),aW=`__sm_code_guard_${globalThis.crypto.randomUUID().replaceAll(`-`,``)}`,oW=new Map,sW=48})),lW=c({loadViewAssets:()=>uW,loadViewCode:()=>dW});async function uW(e,{signal:t}={}){let n={};for(let[r,i]of Object.entries(e?.files||{})){if(HH(i))continue;let a=await _H(e,r,await pW(i.sha256,{signal:t}));n[r]={mediaType:i.mediaType,base64:fW(a)}}return n}function dW(e,t,{guard:n}={}){return iW(e,t,{guard:n,loadBytes:pW})}var fW,pW,mW=o((()=>{vH(),UH(),cW(),fW=e=>{let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)},pW=async(e,{signal:t}={})=>{let n=await fetch(`/__dev/files/`+e,{signal:t});if(!n.ok)throw Error(`A view file is missing from the Block folder.`);return new Uint8Array(await n.arrayBuffer())}}));function hW(e,t,n){return e===void 0?{}:(B(vt(e)&&Object.keys(e).every(e=>t.includes(e)),`CAPABILITY_SETTINGS`,`${n} settings accept only ${t.join(`, `)}`),e)}function gW(e,t,n={}){let r=(e===`video`?DW:EW)[t];return!r||!vt(n)?!1:Object.entries(e===`video`?VW:BW).every(([e,t])=>!HW(n[e])||r[t].includes(n[e]))}function _W(e){return gW(`image`,`nano-banana-2`,e)?IW:UW.find(t=>EW[t]&&gW(`image`,t,e))??`nano-banana-2`}function vW(e,{strict:t=!1}={}){let n=hW(e,PW,`Image`),r=n.model===void 0?_W(n):jW(n.model),i=n.model!==void 0&&r!==n.model,a=EW[r];B(a,`CAPABILITY_SETTINGS`,`Choose an image model from: ${Object.keys(EW).join(`, `)}`);let o=(e,r,o)=>{let s=RW(r,n[e],o);return t&&!i&&zW(n,e)&&B(n[e]===s,`CAPABILITY_SETTINGS`,`${a.label} accepts ${e} ${r.length?r.join(`, `):NW}`),s};return{model:r,aspectRatio:o(`aspectRatio`,a.aspectRatios,a.aspectRatios.includes(`1:1`)?`1:1`:void 0),resolution:o(`resolution`,a.resolutions),quality:o(`quality`,a.qualities,a.qualities.includes(`medium`)?`medium`:void 0)}}function yW(e,{firstFrame:t,lastFrame:n}){let r=e.aspectRatio;if(r===void 0||r==="default"||r===`auto`||DW[`vidu-q3-turbo`].aspectRatios.includes(r))return LW;let i=i=>i.aspectRatios.includes(r)&&(t||!i.requiresFirstFrame)&&(!n||i.lastFrame)&&(e.duration===void 0||i.durations.includes(e.duration));return WW.find(e=>i(DW[e]))??`vidu-q3-turbo`}function bW(e,{strict:t=!1,firstFrame:n=!1,lastFrame:r=!1}={}){let i=hW(e,FW,`Video`),a=i.model===void 0?yW(i,{firstFrame:n,lastFrame:r}):MW(i.model),o=i.model!==void 0&&a!==i.model,s=DW[a];B(s,`CAPABILITY_SETTINGS`,`Choose a video model from: ${Object.keys(DW).join(`, `)}`);let c=(e,n,r)=>{let a=RW(n,i[e],r);return t&&!o&&zW(i,e)&&B(i[e]===a,`CAPABILITY_SETTINGS`,`${s.label} accepts ${e} ${n.length?n.join(`, `):NW}`),a},l=c(`resolution`,s.resolutions,s.resolutions.includes(`720p`)?`720p`:void 0),u=a===`veo-3.1-lite`&&l===`1080p`?[8]:s.durations,d=c(`duration`,u,u.includes(5)?5:void 0);return B(typeof(i.generateAudio??!0)==`boolean`,`CAPABILITY_SETTINGS`,`generateAudio is true or false`),t&&s.requiresFirstFrame&&B(n,`CAPABILITY_SETTINGS`,`${s.label} needs a first-frame image`),{model:a,duration:d,resolution:l,aspectRatio:c(`aspectRatio`,s.aspectRatios,s.aspectRatios.includes(`16:9`)?`16:9`:void 0),generateAudio:i.generateAudio??!0}}var xW,SW,CW,wW,TW,EW,DW,OW,kW,AW,jW,MW,NW,PW,FW,IW,LW,RW,zW,BW,VW,HW,UW,WW,GW=o((()=>{Et(),xW=Object.freeze([`auto`,`21:9`,`16:9`,`3:2`,`4:3`,`1:1`,`4:5`,`3:4`,`2:3`,`9:16`]),SW=Object.freeze([`auto`,`21:9`,`16:9`,`4:3`,`1:1`,`3:4`,`9:16`]),CW=Object.freeze([4,5,6,7,8,9,10,11,12,13,14,15]),wW=(e,{aspectRatios:t,resolutions:n=[],qualities:r=[],references:i=0,seed:a=!1})=>Object.freeze({label:e,aspectRatios:Object.freeze(t),resolutions:Object.freeze(n),qualities:Object.freeze(r),references:i,seed:a}),TW=(e,{aspectRatios:t=[],resolutions:n=[],durations:r,firstFrame:i=!0,lastFrame:a=!1,requiresFirstFrame:o=!1,seed:s=!1,nativeAudio:c=!1})=>Object.freeze({label:e,aspectRatios:Object.freeze(t),resolutions:Object.freeze(n),durations:Object.freeze(r),firstFrame:i,lastFrame:a,requiresFirstFrame:o,seed:s,nativeAudio:c}),EW=Object.freeze({"nano-banana-2":wW(`Nano Banana 2`,{aspectRatios:xW,resolutions:[`1K`,`2K`,`4K`],references:8,seed:!0}),"nano-banana-2-lite":wW(`Nano Banana 2 Lite`,{aspectRatios:xW,resolutions:[`1K`,`2K`,`4K`],references:8,seed:!0}),"nano-banana-pro":wW(`Nano Banana Pro`,{aspectRatios:xW,resolutions:[`1K`,`2K`,`4K`],references:8,seed:!0}),"gpt-image-2":wW(`GPT Image 2`,{aspectRatios:[`auto`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`1K`,`2K`,`4K`],qualities:[`low`,`medium`,`high`],references:8}),"gpt-image-2.5-flare":wW(`GPT Image 2.5 Flare`,{aspectRatios:[`auto`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`1K`,`2K`,`4K`],qualities:[`low`,`medium`,`high`],references:8}),"gpt-image-2.5-sunburst":wW(`GPT Image 2.5 Sunburst`,{aspectRatios:[`auto`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`1K`,`2K`,`4K`],qualities:[`low`,`medium`,`high`],references:8}),"gpt-image-2.6-flare":wW(`GPT Image 2.6 Flare`,{aspectRatios:[`auto`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`1K`,`2K`,`4K`],qualities:[`low`,`medium`,`high`],references:8}),"gpt-image-2.6-sunburst":wW(`GPT Image 2.6 Sunburst`,{aspectRatios:[`auto`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`1K`,`2K`,`4K`],qualities:[`low`,`medium`,`high`],references:8}),"gpt-image-1.5":wW(`GPT-Image 1.5`,{aspectRatios:[`16:9`,`9:16`,`1:1`],qualities:[`low`,`medium`,`high`]}),"kling-image-v3":wW(`Kling Image V3`,{aspectRatios:[`21:9`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`,`3:2`,`2:3`],resolutions:[`1K`,`2K`]}),"seedream-v4.5":wW(`Seedream 4.5`,{aspectRatios:[`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`2K`,`4K`],seed:!0})}),DW=Object.freeze({"seedance-2.0":TW(`Seedance 2.0`,{aspectRatios:SW,resolutions:[`480p`,`720p`,`1080p`,`4k`],durations:CW,lastFrame:!0,seed:!0,nativeAudio:!0}),"seedance-2.0-fast":TW(`Seedance 2.0 Fast`,{aspectRatios:SW,resolutions:[`480p`,`720p`],durations:CW,lastFrame:!0,seed:!0,nativeAudio:!0}),"seedance-2.0-mini":TW(`Seedance 2.0 Mini`,{aspectRatios:SW,resolutions:[`480p`,`720p`],durations:CW,lastFrame:!0,seed:!0,nativeAudio:!0}),"kling-v3-turbo":TW(`Kling 3.0 Turbo`,{aspectRatios:[`16:9`,`9:16`,`1:1`],durations:[5,10]}),"wan-2.6-flash":TW(`Wan 2.6 Flash`,{aspectRatios:[`16:9`,`9:16`,`1:1`],durations:[3,4,5],requiresFirstFrame:!0}),"veo-3.1-lite":TW(`Veo 3.1 Lite`,{aspectRatios:[`16:9`,`9:16`],resolutions:[`720p`,`1080p`],durations:[4,6,8],lastFrame:!0,nativeAudio:!0}),"vidu-q3-turbo":TW(`Vidu Q3 Turbo`,{durations:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],lastFrame:!0,nativeAudio:!0}),"wan-2.7":TW(`Wan 2.7`,{resolutions:[`720p`,`1080p`],durations:[2,3,4,5,6,7,8,9,10,11,12,13,14,15],lastFrame:!0,requiresFirstFrame:!0,seed:!0})}),OW=Object.freeze({"seedream-4.5":`seedream-v4.5`}),kW=Object.freeze({}),AW=(e,t,n)=>{for(let r=0;typeof n==`string`&&!Object.hasOwn(e,n)&&Object.hasOwn(t,n)&&r<8;r++)n=t[n];return n},jW=e=>AW(EW,OW,e),MW=e=>AW(DW,kW,e),NW=`default`,PW=Object.freeze([`model`,`aspectRatio`,`resolution`,`quality`]),FW=Object.freeze([`model`,`duration`,`resolution`,`aspectRatio`,`generateAudio`]),IW=`nano-banana-2`,LW=`vidu-q3-turbo`,Object.freeze({references:8,negativePrompt:2e3,seed:2147483647}),RW=(e,t,n)=>e.length?e.includes(t)?t:n??e[0]:NW,zW=(e,t)=>e!==void 0&&Object.hasOwn(e,t),BW=Object.freeze({aspectRatio:`aspectRatios`,resolution:`resolutions`,quality:`qualities`}),VW=Object.freeze({aspectRatio:`aspectRatios`,resolution:`resolutions`,duration:`durations`}),HW=e=>e!==void 0&&e!=="default",UW=Object.freeze([`gpt-image-2.5-sunburst`,`gpt-image-2.5-flare`,`gpt-image-2.6-flare`,`gpt-image-2.6-sunburst`,`gpt-image-2`,`seedream-v4.5`,`kling-image-v3`,`nano-banana-pro`,`gpt-image-1.5`]),WW=Object.freeze([`wan-2.6-flash`,`veo-3.1-lite`,`seedance-2.0-mini`,`kling-v3-turbo`,`seedance-2.0-fast`,`seedance-2.0`]),Object.freeze({speech:Object.freeze({text:3800,defaultVoice:`asteria`,speed:Object.freeze({min:.25,max:4,default:1})}),music:Object.freeze({min:5,max:240,default:30}),sfx:Object.freeze({min:.5,max:22,default:4})})})),KW=c({APP_AI_BUDGET_USD:()=>TG,BLOCK_BUILD_BUDGET_USD:()=>xG,CHAT_REPLY_BUDGET_USD:()=>SG,CHAT_WEB_SEARCH_USD:()=>CG,CREDIT_VALUE_USD:()=>QW,FLAT:()=>bG,IMAGE:()=>cG,LARGEST_TEXT_CALL:()=>gG,MARKUP:()=>$W,MUSIC:()=>uG,SFX:()=>dG,SPEECH:()=>lG,TEXT_MODELS:()=>fG,TEXT_MODELS_CHECKED:()=>pG,TYPICAL_TEXT_CALL:()=>hG,UNREPORTED_CALL_USD:()=>wG,VIDEO:()=>oG,VIDEO_ALIASES:()=>sG,exactCredits:()=>eG,imageUsd:()=>YW,largestTextCallUsd:()=>vG,milliCredits:()=>nG,musicUsd:()=>OG,sfxUsd:()=>kG,sizedTextCallCredits:()=>JW,speechUsd:()=>ZW,textCallCredits:()=>qW,typicalTextCallUsd:()=>_G,usdCoveredBy:()=>rG,videoModelId:()=>DG,videoUsd:()=>XW,wholeCredits:()=>tG});function qW(e){let t=mG(e,hG.input,hG.output),n=mG(e,gG.input,gG.output);return t===null?null:Math.max(tG(t,`media`),Math.ceil(n/QW-1e-9))}function JW(e,{inputBytes:t=0,maxTokens:n=0}={}){let r=qW(e);if(r===null)return null;if(t<=4e4&&n<=gG.output)return r;let i=mG(e,Math.ceil(t/4),Math.min(n,Math.max(hG.output,Math.ceil(n/3)))),a=mG(e,t+64,n);return Math.max(r,tG(i,`media`),Math.ceil(a/QW-1e-9))}function YW({model:e=`gpt-image-2`,quality:t,resolution:n,references:r}={}){let i=cG[e]||cG[`gpt-image-2`],a=String(n||``).toUpperCase(),o=r===void 0||Number(r)>0;if(i.quality){let e=i.quality[EG(i.quality,String(t||``).toLowerCase(),`low`)];return e[EG(e,a,`1K`)]+(o&&i.referenceUsd||0)}return i.usd*(i.resolution?.[EG(i.resolution,a,`1K`)]??1)}function XW({model:e,seconds:t=6,resolution:n}={}){let r=oG[DG(e)],i=r.resolution||{},a=EG(i,String(n||``).toLowerCase(),Object.hasOwn(i,`720p`)?`720p`:Object.keys(i)[0]);return r.usd*(i[a]??1)*Math.max(1,Math.ceil(Number(t)||6))}function ZW({chars:e,seconds:t,provider:n=`deepgram`}={}){return(lG[n]||lG.elevenlabs).usdPer1kChars*(Number(e)>0?Number(e):Math.max(1,Number(t)||30)*12.5)/1e3}var QW,$W,eG,tG,nG,rG,iG,aG,oG,sG,cG,lG,uG,dG,fG,pG,mG,hG,gG,_G,vG,yG,bG,xG,SG,CG,wG,TG,EG,DG,OG,kG,AG=o((()=>{QW=2399/11e4,$W=Object.freeze({video:3,build:3,media:4.5,other:3,chat:2}),eG=(e,t)=>Math.max(0,Number(e)||0)*$W[t]/QW,tG=(e,t)=>Math.max(1,Math.ceil(eG(e,t)-1e-9)),nG=(e,t=`chat`)=>Math.ceil(eG(e,t)*1e3-1e-6),rG=(e,t)=>Math.max(0,Number(e)||0)*QW/$W[t],iG=`2026-11-05`,aG=`carried`,oG=Object.freeze({"veo-3.1-lite":{usd:.05,resolution:{"720p":1,"1080p":1.6},provider:`Atlas`,checked:iG,source:`Atlas catalog list price $0.05/s; 1080p at $0.08/s, Google's Veo 3.1 Lite step`},"vidu-q3-turbo":{usd:.04,provider:`Atlas`,checked:iG,source:`Atlas catalog list price (we pay $0.034)`},"wan-2.6-flash":{usd:.025,provider:`Atlas`,checked:iG,source:`Atlas catalog list price (we pay $0.018)`},"wan-2.7":{usd:.17,provider:`Higgsfield, then Atlas`,checked:aG,source:`Atlas $0.10/s at 720p (checked); the 1.7x step to the 1080p we generate is carried from the old table`},"kling-v3-turbo":{usd:.112,provider:`Higgsfield, then Atlas`,checked:iG,source:`Atlas catalog list price (we pay $0.095); Higgsfield $0.056/s on promotion`},"seedance-2.0":{usd:.2,resolution:{"480p":1,"720p":1.3,"1080p":3.2,"4k":7.5},provider:`BytePlus Ark`,checked:aG,source:`Ark is priced per token and its price page does not load without an account; carried from the old table (verify against an Ark invoice)`},"seedance-2.0-fast":{usd:.09,resolution:{"480p":1,"720p":1.3},provider:`BytePlus Ark`,checked:aG,source:`carried from the old table (Atlas lists $0.09/s)`},"seedance-2.0-mini":{usd:.09,resolution:{"480p":1,"720p":1.3},provider:`BytePlus Ark`,checked:aG,source:`priced as Fast, carried from the old table (Atlas lists $0.056/s)`}}),sG=Object.freeze({"seedance-2":`seedance-2.0`,"kling-3":`kling-v3-turbo`,"kling-v3-pro":`kling-v3-turbo`,"kling-v3-std":`kling-v3-turbo`,"kling-o3-std":`kling-v3-turbo`}),cG=Object.freeze({"gpt-image-2":{quality:{low:{"1K":.006,"2K":.007,"4K":.012},medium:{"1K":.053,"2K":.056,"4K":.101},high:{"1K":.211,"2K":.222,"4K":.401}},referenceUsd:.02,provider:`OpenAI for square, fal then Atlas for other shapes`,checked:iG,source:`fal gpt-image-2 price table (dearest size in each class); OpenAI direct is $30 per million output tokens`},"gpt-image-2.5-flare":{quality:{low:{"1K":.00588,"2K":.00615,"4K":.01113},medium:{"1K":.01317,"2K":.01434,"4K":.02595},high:{"1K":.05268,"2K":.05529,"4K":.10008}},referenceUsd:.02,provider:`OpenAI for square, fal for other shapes`,checked:`2026-11-06`,source:`fal openai/gpt-image-2.5/flare price table; OpenAI rate card $30 per million output tokens`},"gpt-image-2.5-sunburst":{quality:{low:{"1K":.00588,"2K":.00615,"4K":.01113},medium:{"1K":.01317,"2K":.01434,"4K":.02595},high:{"1K":.05268,"2K":.05529,"4K":.10008}},referenceUsd:.02,provider:`OpenAI for square, fal for other shapes`,checked:`2026-11-06`,source:`fal openai/gpt-image-2.5/sunburst price table; OpenAI rate card $30 per million output tokens`},"gpt-image-2.6-flare":{quality:{low:{"1K":.00588,"2K":.00615,"4K":.01113},medium:{"1K":.01317,"2K":.01434,"4K":.02595},high:{"1K":.05268,"2K":.05529,"4K":.10008}},referenceUsd:.02,provider:`OpenAI for square, fal for other shapes`,checked:`2026-11-07`,source:`OpenAI and fal gpt-image-2.6 token rates ($30 per million output tokens); per-image price taken from 2.5 until published`},"gpt-image-2.6-sunburst":{quality:{low:{"1K":.00588,"2K":.00615,"4K":.01113},medium:{"1K":.01317,"2K":.01434,"4K":.02595},high:{"1K":.05268,"2K":.05529,"4K":.10008}},referenceUsd:.02,provider:`OpenAI for square, fal for other shapes`,checked:`2026-11-07`,source:`OpenAI and fal gpt-image-2.6 token rates ($30 per million output tokens); per-image price taken from 2.5 until published`},"gpt-image-1.5":{quality:{low:{"1K":.013},medium:{"1K":.051},high:{"1K":.2}},provider:`fal`,checked:iG,source:`fal price for a non-square image`},"nano-banana-2":{usd:.08,resolution:{"1K":1,"2K":1.5,"4K":2},provider:`fal`,checked:iG,source:`fal: $0.08 at 1K, 1.5x at 2K, 2x at 4K`},"nano-banana-2-lite":{usd:.048,provider:`fal`,checked:iG,source:`fal: $37.50 per million output tokens, one 1K image (about 1,290 tokens)`},"nano-banana-pro":{usd:.15,resolution:{"1K":1,"2K":1,"4K":2},provider:`fal`,checked:iG,source:`fal: $0.15, 4K at double`},"kling-image-v3":{usd:.028,provider:`fal`,checked:iG,source:`fal: $0.028 per image`},"seedream-v4.5":{usd:.04,provider:`fal`,checked:iG,source:`fal: $0.04 per image`},"flux-step":{usd:.02,provider:`fal`,checked:aG,source:`carried from the old table`},flux:{usd:.04,provider:`fal`,checked:aG,source:`carried from the old table`},ideogram:{usd:.08,provider:`fal`,checked:aG,source:`carried from the old table`},gemini:{usd:.08,resolution:{"1K":1,"2K":1.5,"4K":2},provider:`fal`,checked:iG,source:`served as Nano Banana 2`}}),lG=Object.freeze({deepgram:{usdPer1kChars:.03,checked:iG,source:`Deepgram Aura-2 pay as you go`},openai:{usdPer1kChars:.015,checked:iG,source:`OpenAI tts-1, $15 per million characters`},elevenlabs:{usdPer1kChars:.04,checked:iG,source:`ElevenLabs API, Flash / Turbo`},kokoro:{usdPer1kChars:.02,checked:iG,source:`fal Kokoro`}}),uG=Object.freeze({usdPerSecond:2e-4,checked:iG,source:`fal ACE-Step, per second of audio`}),dG=Object.freeze({usdPerSecond:.002,checked:iG,source:`fal ElevenLabs sound effects v2, per second`}),fG=Object.freeze({"openai/gpt-5-mini":{input:.25,output:2},"google/gemini-2.5-flash":{input:.3,output:2.5},"anthropic/claude-haiku-5.5":{input:.1,output:.5},"anthropic/claude-sonnet-4":{input:3,output:15},"anthropic/claude-sonnet-4.5":{input:3,output:15},"anthropic/claude-sonnet-5.5":{input:2,output:10},"openai/gpt-5.4":{input:2.5,output:15},"google/gemini-2.5-pro":{input:1.25,output:10},"x-ai/grok-4.5":{input:2,output:6},"x-ai/grok-4.20":{input:1.25,output:2.5},"anthropic/claude-opus-4.1":{input:15,output:75},"anthropic/claude-opus-4.5":{input:5,output:25},"anthropic/claude-opus-4.8":{input:5,output:25},"openai/gpt-5.5":{input:5,output:30}}),pG=iG,mG=(e,t,n)=>{let r=fG[e];return r?(t*r.input+n*r.output)/1e6:null},hG=Object.freeze({input:2e3,output:1e3}),gG=Object.freeze({input:1e4,output:4096}),_G=e=>mG(e,hG.input,hG.output),vG=e=>mG(e,gG.input,gG.output),yG=(e,t,n,r,i={})=>Object.freeze({usd:e,tier:t,unit:n,source:r,checked:i.checked||aG,...i}),bG=Object.freeze({"media:analyze":yG(.02,`media`,`call`,`the vision provider caps a call at $0.02 (VISION_MAX_INITIAL_COST)`,{checked:iG}),"media:check":yG(.005,`media`,`call`,`four photos at most, $0.00125 each (MEDIA_CHECK_IMAGE_USD)`,{checked:iG}),"research:search":yG(.008,`media`,`search`,`Tavily basic search`,{checked:iG}),"research:summarize":yG(.01,`media`,`call`,`one Gemini Flash read of fetched pages`,{estimate:!0}),"transcribe:timestamp":yG(.01,`media`,`run`,`fal Whisper word timing`,{estimate:!0}),"transcribe:upload":yG(.01,`media`,`run`,`fal Whisper word timing`,{estimate:!0}),"transcribe:captions":yG(.01,`media`,`run`,`fal Whisper word timing`,{estimate:!0}),"connection:action":yG(.012,`other`,`action`,`a premium Composio tool call at the overage rate`,{checked:iG}),"automation:app-event":yG(.003,`other`,`event`,`Composio, per trigger event`,{checked:iG}),"automation:app-check":yG(3e-4,`other`,`check`,`Composio, per tool call`,{checked:iG}),llm:yG(.01,`other`,`call`,`a Standard model call`,{estimate:!0}),vision:yG(.01,`other`,`image`,`one vision read`,{estimate:!0}),"narrative:compile":yG(.06,`other`,`script`,`about ten Gemini Flash calls`,{estimate:!0}),"narrative:compile-research":yG(.1,`other`,`script`,`the compile plus three Tavily searches and a dossier`,{estimate:!0}),"narrative:learn-voice":yG(.01,`other`,`call`,`one extraction call`,{estimate:!0}),"roughcut:base":yG(.05,`other`,`run`,`segmentation and matching`,{estimate:!0}),"roughcut:per-min":yG(.015,`other`,`footage minute`,`Gemini Flash frame reads`,{estimate:!0}),"finaledit:base":yG(.06,`other`,`run`,`polish decisions`,{estimate:!0}),"finaledit:per-min":yG(.02,`other`,`video minute`,`Gemini Flash scan`,{estimate:!0}),"aomotion:base":yG(.06,`other`,`run`,`motion graphics pass`,{estimate:!0}),"aomotion:per-min":yG(.02,`other`,`video minute`,`motion graphics pass`,{estimate:!0}),"aomotion:base:opus":yG(.12,`other`,`run`,`motion graphics pass on Opus`,{estimate:!0}),"aomotion:per-min:opus":yG(.04,`other`,`video minute`,`motion graphics pass on Opus`,{estimate:!0}),motiongraphic:yG(.015,`other`,`graphic`,`one small call`,{estimate:!0}),"transcript:parse":yG(.005,`other`,`1,000 characters`,`Gemini Flash word timing`,{estimate:!0}),"vibe-edit":yG(.02,`other`,`turn`,`Flash region scan and decision`,{estimate:!0}),"canvas:context-connect":yG(.01,`other`,`run`,`one canvas read`,{estimate:!0}),"anim2:plan":yG(.03,`other`,`video`,`shot planning`,{estimate:!0}),"anim2:vibe":yG(.03,`other`,`turn`,`scene vibe turn`,{estimate:!0}),"anim2:qa":yG(.03,`other`,`frame`,`vision QA`,{estimate:!0}),"anim2:trigger":yG(.01,`other`,`scene`,`one Haiku call`,{estimate:!0}),"gif:plan":yG(.03,`other`,`pass`,`GIF planning`,{estimate:!0}),"canvas:plan":yG(.03,`other`,`pass`,`collage planning`,{estimate:!0}),"canvasChat:build":yG(.03,`other`,`build`,`canvas chat orchestration`,{estimate:!0}),"strip:plan":yG(.05,`other`,`pass`,`strip planning`,{estimate:!0}),"panel:qa":yG(.03,`other`,`pass`,`style-consistency vision pass`,{estimate:!0})}),xG=Object.freeze({standard:.4,balanced:.85,reasoning:.5,premium:1.4}),SG=.06,CG=.008,wG=Object.freeze({build:.1,chat:.005,other:.05}),TG=.25,EG=(e,t,n)=>e&&Object.hasOwn(e,t)?t:n,DG=e=>{let t=String(e||``).toLowerCase();return oG[t]?t:sG[t]||(t.includes(`kling`)?`kling-v3-turbo`:t.includes(`seedance`)?`seedance-2.0`:`wan-2.6-flash`)},OG=e=>uG.usdPerSecond*e,kG=e=>dG.usdPerSecond*e})),jG,MG,NG=o((()=>{AG(),jG=[{value:`openai/gpt-5-mini`,label:`GPT-5 mini`},{value:`google/gemini-2.5-flash`,label:`Gemini 2.5 Flash`},{value:`anthropic/claude-opus-4.8`,label:`Claude Opus 4.8`},{value:`anthropic/claude-opus-4.5`,label:`Claude Opus 4.5`},{value:`anthropic/claude-opus-4.1`,label:`Claude Opus 4.1`},{value:`anthropic/claude-sonnet-4.5`,label:`Claude Sonnet 4.5`},{value:`anthropic/claude-sonnet-4`,label:`Claude Sonnet 4`},{value:`openai/gpt-5.5`,label:`GPT-5.5`},{value:`openai/gpt-5.4`,label:`GPT-5.4`},{value:`google/gemini-2.5-pro`,label:`Gemini 2.5 Pro`},{value:`x-ai/grok-4.20`,label:`Grok 4.20`},{value:`x-ai/grok-4.5`,label:`Grok 4.5`}],MG=Object.freeze(Object.fromEntries([`openai/gpt-5-mini`,`google/gemini-2.5-flash`,`anthropic/claude-sonnet-4`,`anthropic/claude-sonnet-4.5`,`openai/gpt-5.4`,`google/gemini-2.5-pro`,`x-ai/grok-4.5`,`x-ai/grok-4.20`,`anthropic/claude-opus-4.1`,`anthropic/claude-opus-4.5`,`anthropic/claude-opus-4.8`,`openai/gpt-5.5`].map(e=>[e,qW(e)]))),MG[`anthropic/claude-sonnet-4.5`]})),PG=o((()=>{NG()}));function FG(e,t,{references:n=!1,firstFrame:r=!1}={}){let i=e===`audio.speech`,a=e===`audio.transcribe`,o=e===`image.generate`,s=e===`video.generate`,c=e===`web.fetch`||e===`web.research`,l=e===`media.analyze`,u=e===`audio.music`||e===`audio.sfx`,d=i||o||s||u,f=u||c||l,p=e=>(o||s)&&e?.selection?.provider===`stillmade`&&e.selection.payment===`credits`&&Object.hasOwn(o?EW:DW,e.selection.model)&&(!s||r||!DW[e.selection.model].requiresFirstFrame),m=t=>t?.selection?.provider===`stillmade`&&t.selection.payment===`credits`&&(l?t.selection.model===`media-vision`:c?t.selection.model===(e===`web.fetch`?`web-fetch`:`web-research`):i?t.selection.model===`voice-catalog`&&IG(t).length>0:a?t.selection.model===`whisper-large-v3-turbo`:u&&t.selection.model===(e===`audio.music`?`ace-step`:`sound-effects`)),h=s?`atlas`:d||a?`openai`:`openrouter`;return Array.isArray(t?.options)?t.options.filter(e=>p(e)||m(e)||!f&&e?.selection?.provider===h&&[`credits`,`byok`].includes(e.selection.payment)&&typeof e.selection.model==`string`&&e.selection.model.length>0&&(!i||e.selection.model===`tts-1`)&&(!a||e.selection.payment===`byok`&&e.selection.model===`whisper-1`)&&(!o||e.selection.model===`gpt-image-2`&&e.selection.size===`1024x1024`)).filter(e=>!(o&&n)||LG(e)):[]}var IG,LG,RG=o((()=>{Et(),GW(),PG(),IG=e=>Array.isArray(e?.voices)?e.voices.filter(e=>typeof e?.id==`string`&&/^[a-z][a-z0-9_-]{0,63}$/.test(e.id)&&typeof e.label==`string`&&e.label.length<=120):[],LG=e=>e?.selection?.provider===`stillmade`&&EW[e.selection.model]?.references>0}));function zG(e){let t=String(e?.manifest?.name||``).split(` · `);if(t.length>1&&t[0].trim())return t[0].trim();let n=JG(e);return HG[n]||(n?YG(n):`the app`)}function BG(e){let t=String(e?.manifest?.name||``).split(` · `).slice(1).join(` `),n=String(e?.capability?.capabilityId||``).split(`:`).at(-1),r=JG(e).replace(/[-_.]/g,``).toLowerCase(),i=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,` `).trim().split(` `).filter(Boolean);return t.length>1&&t[0].replace(/[-_.]/g,``)===r&&t.shift(),t};for(let e of[i(t),i(n)]){let t=e.slice(0,3),n=t.find(e=>UG.test(e)||WG.has(e)||KG.some(([,t])=>t.has(e)));if(n&&UG.test(n))return`read`;if(e.some(e=>WG.has(e))||t.some(e=>[`create`,`upload`,`share`].includes(e))&&e.some(e=>GG.has(e)))return`post`;let r=n&&KG.find(([,e])=>e.has(n));if(r)return r[0]}return`send`}function VG(e){let t=zG(e),n=BG(e),[r,i]=qG[n];return{app:t,kind:n,verbs:[`${r} ${t}`,`${i} ${t}…`],canPostLater:n===`post`}}var HG,UG,WG,GG,KG,qG,JG,YG,XG,ZG=o((()=>{HG=Object.freeze({googlesheets:`Google Sheets`,googledrive:`Google Drive`,googledocs:`Google Docs`,googlecalendar:`Google Calendar`,gmail:`Gmail`,youtube:`YouTube`,tiktok:`TikTok`,linkedin:`LinkedIn`,hubspot:`HubSpot`,github:`GitHub`,whatsapp:`WhatsApp`,"meta-ads":`Meta Ads`}),UG=/^(fetch|list|get|search|find|read|retrieve|query|download|lookup|look|check|watch|count|export)$/,WG=new Set([`post`,`posts`,`publish`,`tweet`,`reel`,`reels`,`story`,`stories`,`carousel`,`pin`]),GG=new Set([`video`,`videos`,`photo`,`photos`,`image`,`images`,`media`]),KG=[[`send`,new Set([`send`,`reply`,`message`,`notify`,`email`,`forward`,`dm`,`invite`])],[`add`,new Set([`add`,`append`,`insert`,`create`,`new`,`log`,`save`,`record`,`upsert`,`write`,`import`,`book`,`schedule`])],[`update`,new Set([`update`,`edit`,`change`,`modify`,`patch`,`set`,`rename`,`move`,`replace`,`mark`])],[`remove`,new Set([`delete`,`remove`,`archive`,`trash`,`cancel`,`unsubscribe`])],[`upload`,new Set([`upload`])]],qG={post:[`Post to`,`Posting to`],send:[`Send to`,`Sending to`],add:[`Add to`,`Adding to`],update:[`Update in`,`Updating in`],remove:[`Remove from`,`Removing from`],upload:[`Upload to`,`Uploading to`],read:[`Get from`,`Getting from`]},JG=e=>String(e?.capability?.appId||``).replace(/^app:/,``).replace(/^composio:/,``),YG=e=>e.replace(/[-_.]+/g,` `).trim().replace(/\b\w/g,e=>e.toUpperCase()),XG=e=>VG(e).verbs})),QG=c({blockVerbs:()=>$G,creditWords:()=>sK,runButtonLabel:()=>nK,runIsFree:()=>lK,runPrice:()=>tK,runPriceWords:()=>uK,runVerbs:()=>eK});function $G(e){let t=e?.manifest;if(!t)return null;let n=String(t.name||``).trim(),r=n.split(/\s+/)[0].toLowerCase();if(oK.has(r)&&n.includes(` `))return[n,`Working…`];let i=Object.entries(t.outputs||{}).filter(([,e])=>!e?.context),[a,o]=i.find(([,e])=>e?.primary)||i[0]||[],s=a&&!aK.has(iK(a))&&!/action/i.test(String(o?.type||``)),c=o?.label?iK(o.label):iK(s?a:n);return c?[`Make ${c}`,`Making ${c}…`]:null}function eK(e,t){let n=t?.manifest?.action,r=typeof n?.label==`string`?n.label.trim():``;return r?[r,n.running||rK[e]?.[1]||`Working…`]:e===`connection.execute`&&t?XG(t):rK[e]||$G(t)||[`Make the result`,`Making the result…`]}function tK(e,{quality:t,count:n=1}={}){let r=e?.selection;if(!r||e.available===!1)return null;if(r.payment===`byok`)return{byok:!0};if(r.payment!==`credits`)return null;let i=r.provider===`stillmade`&&e.qualityCredits&&Number.isSafeInteger(e.qualityCredits[t])?e.qualityCredits[t]:e.creditsPerCall;return!Number.isSafeInteger(i)||i<0?null:{credits:i*Math.max(1,Math.min(4,Number.isInteger(n)?n:1))}}function nK(e,t,{again:n=!1,free:r=!1,verb:i,connector:a}={}){let o=i||eK(e,a)[0],s=n?`${o} again`:o,c=uK(t,{free:r});return c?`${s} · ${c}`:s}var rK,iK,aK,oK,sK,cK,lK,uK,dK=o((()=>{RG(),ZG(),rK=Object.freeze({"text.generate":[`Write`,`Writing…`],"image.generate":[`Generate image`,`Generating image…`],"video.generate":[`Generate video`,`Generating video…`],"video.render":[`Make video`,`Making video…`],"audio.speech":[`Generate voiceover`,`Generating voiceover…`],"audio.transcribe":[`Transcribe`,`Transcribing…`],"image.describe":[`Describe`,`Describing…`],"audio.music":[`Generate music`,`Generating music…`],"audio.sfx":[`Generate sound`,`Generating sound…`],"web.fetch":[`Read page`,`Reading…`],"web.research":[`Research`,`Researching…`],"media.analyze":[`Analyze`,`Analyzing…`],"timeline.propose":[`Suggest edit`,`Suggesting…`],"workspace.propose":[`Suggest changes`,`Suggesting…`],"connection.execute":[`Send`,`Sending…`]}),iK=e=>String(e||``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase(),aK=new Set([`output`,`outputs`,`result`,`results`,`value`,`data`,`out`]),oK=new Set(`add.analyze.animate.build.check.clean.compose.convert.count.create.cut.describe.design.edit.export.extract.find.generate.get.import.make.merge.mix.narrate.pick.plan.post.publish.read.record.remove.render.research.resize.review.schedule.send.split.summarize.transcribe.translate.trim.write`.split(`.`)),sK=e=>`${e.toLocaleString()} credit${e===1?``:`s`}`,cK=new Set([`final.render`]),lK=e=>e?.runtime===`javascript`&&(e.permissions?.actions||[]).every(e=>cK.has(e)),uK=(e,{free:t=!1}={})=>e?.byok?`your key`:Number.isSafeInteger(e?.credits)&&e.credits>0?sK(e.credits):t||e?.credits===0?sK(0):null}));function fK(e){let t=e?.permissions||{},n=new Set((t.capabilities||[]).filter(e=>wt.includes(e))),r=t.actions||[];if(r.includes(`media.generate`))for(let e of Object.values(gK))n.add(e);return(r.includes(`image.generate`)||r.includes(`image.generate.batch`))&&n.add(`image.generate`),[...n]}function pK(e,t){let n=e===`image`,r=(n?EW:DW)[t];if(!r)return null;let i=n?vW({model:t}):bW({model:t}),a=(n?[[`aspectRatio`,r.aspectRatios],[`resolution`,r.resolutions],[`quality`,r.qualities]]:[[`duration`,r.durations],[`resolution`,r.resolutions],[`aspectRatio`,r.aspectRatios]]).filter(([,e])=>e.length).map(([e,t])=>({key:e,label:_K[e],values:[...t],default:i[e]==="default"?t[0]:i[e]}));return!n&&r.nativeAudio&&a.push({key:`generateAudio`,label:_K.generateAudio,values:[!0,!1],default:!0}),n?{settings:a,references:r.references}:{settings:a,firstFrame:r.firstFrame,lastFrame:r.lastFrame,needsFirstFrame:r.requiresFirstFrame,sound:r.nativeAudio}}function mK(e,t=[]){let n=e===`image.generate`,r=e===`video.generate`,i=[];for(let a of Array.isArray(t)?t:[]){let t=a?.selection?.model;if(typeof t!=`string`||!t||i.some(e=>e.id===t))continue;let o=n||r?a.selection.provider===`stillmade`&&pK(n?`image`:`video`,t):null;if((n||r)&&!o)continue;let s=yK(a.fromCredits),c=e===`audio.speech`?vK(a.voices):[];i.push({id:t,label:typeof a.label==`string`&&a.label?a.label.slice(0,120):t,credits:yK(a.creditsPerCall),...s===null?{}:{fromCredits:s},available:a.available!==!1,...a.available===!1&&typeof a.reason==`string`?{reason:a.reason.slice(0,240)}:{},...o||{settings:[]},...c.length?{voices:c}:{}})}return{operation:e,default:i.find(e=>e.available)?.id??null,models:i}}function hK(e){let t=e===`image.generate`;if(!t&&e!==`video.generate`)return{operation:e,default:null,models:[]};let n=t?EW:DW,r=t?IW:LW;return mK(e,[r,...Object.keys(n).filter(e=>e!==r)].map(e=>({selection:{provider:`stillmade`,model:e},label:n[e].label})))}var gK,_K,vK,yK,bK=o((()=>{Et(),GW(),gK=Object.freeze({image:`image.generate`,video:`video.generate`,speech:`audio.speech`,music:`audio.music`,sfx:`audio.sfx`}),_K=Object.freeze({aspectRatio:`Shape`,resolution:`Size`,quality:`Quality`,duration:`Length (seconds)`,generateAudio:`Sound`}),vK=e=>Array.isArray(e)?e.filter(e=>typeof e?.id==`string`&&/^[a-z][a-z0-9_-]{0,63}$/.test(e.id)&&typeof e.label==`string`).map(e=>({id:e.id,label:e.label.slice(0,120)})):[],yK=e=>Number.isSafeInteger(e)&&e>=0?e:null}));function xK(e=CK){Date.now()-TK<1500||(TK=Date.now(),window.dispatchEvent(new CustomEvent(SK,{detail:{reason:e}})))}var SK,CK,wK,TK,EK,DK,OK=o((()=>{Xt(),SK=`stillmade:sign-up-required`,CK=`This uses credits. Sign up to continue; your project stays saved on this browser.`,wK=()=>!Jt(),TK=0,EK=/\/(?:quotes?|lookup|step-updates|models|prices?|estimates?|options)$/,DK=`Sign up to make this. Everything you set up stays here for when you are in.`})),kK=o((()=>{Et(),Object.freeze({bytes:8192,depth:8,properties:64,enum:64,stringLength:4e3})})),AK,jK=o((()=>{AK=Object.freeze({MIT:`MIT License
1983
+ `,PU=`sm.blockZoom.`;function FU(e,t){try{if(!e)return;t===`auto`?localStorage.removeItem(PU+e):localStorage.setItem(PU+e,String(t))}catch{}}function IU(e){if(!e)return 0;let t=e.parentElement;for(;t&&t!==document.body;){let e=getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.clientHeight>0)break;t=t.parentElement}let n=t&&t!==document.body?t.getBoundingClientRect():{top:0},r=t&&t!==document.body?t.clientHeight:innerHeight,i=e.getBoundingClientRect().top-n.top+(t&&t!==document.body?t.scrollTop:scrollY);return Math.max(280,Math.round(r-Math.min(i,r*.5)-24))}function LU(e){if(!e)return 0;let t=e.parentElement;for(;t&&t!==document.body;){let e=getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.clientHeight>0)break;t=t.parentElement}if(!t||t===document.body)return IU(e);let n=t.getBoundingClientRect(),r=t.scrollTop,i=e.getBoundingClientRect(),a=i.top-n.top+r,o=i.bottom-n.top+r,s=o;for(let e of t.children)/fixed|absolute/.test(getComputedStyle(e).position)||(s=Math.max(s,e.getBoundingClientRect().bottom-n.top+r));let c=s-o+(parseFloat(getComputedStyle(t).paddingBottom)||0);return Math.max(280,Math.round(t.clientHeight*.7),Math.floor(t.clientHeight-Math.min(a,t.clientHeight*.5)-c))}var RU=(e,t)=>Math.round(Math.min(vU,Math.max(_U,e+t))*100)/100,zU=(0,v.createContext)(null),BU=null,VU=new Set,HU=()=>BU;function UU(e){return VU.add(e),()=>VU.delete(e)}function WU(e,t,n){let r=globalThis.modernScreenshot;if(delete globalThis.modernScreenshot,!r)return;let i=!1,a=[],o=new WeakSet,s=e=>{if(e?.nodeType!==1||o.has(e))return;let t=e.getBoundingClientRect();t.width*t.height<400||t.height>900||(a.push({x:t.left,y:t.top,width:t.width,height:t.height}),a.length>40&&a.shift())},c=()=>{i||(i=!0,setTimeout(()=>{i=!1,n({channel:e,session:t,op:`view-changed`,rects:a.splice(0)},`*`)},100))},l=e=>e.type===`childList`&&[...e.addedNodes,...e.removedNodes].every(e=>o.has(e))||o.has(e.target);new MutationObserver(e=>{let t=e.filter(e=>!l(e));if(t.length){for(let e of t)if(e.type===`childList`)for(let t of e.addedNodes)s(t.nodeType===1?t:t.parentElement);else e.type===`characterData`&&s(e.target.parentElement);c()}}).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});for(let e of[`input`,`change`,`scroll`])addEventListener(e,c,!0);addEventListener(`message`,async i=>{let a=i.data;if(i.source!==parent||!a||a.channel!==e||a.session!==t||a.op!==`capture-view`||typeof a.id!=`string`)return;let s=Math.max(0,Number(a.top)||0),c=Math.min(4e3,Math.max(1,Number(a.height)||innerHeight)),l=document.createElement(`div`);o.add(l);try{l.style.cssText=`all:initial;position:fixed;left:-99999px;top:0;visibility:hidden`;let i=l.attachShadow({mode:`closed`}),o=document.createElement(`div`);i.append(o),document.documentElement.append(l);let u=await r.createContext(document.body,{scale:2,width:innerWidth,height:c,timeout:4e3,features:{restoreScrollPosition:!0},filter:e=>e!==l&&!(/^(VIDEO|AUDIO)$/.test(e.tagName)&&(e.readyState<2||!e.getClientRects().length)),style:{margin:getComputedStyle(document.body).margin,overflow:`visible`,transform:`translateY(${-s}px)`}});u.sandbox={contentWindow:{document:{createElement:e=>document.createElement(e),createElementNS:(e,t)=>document.createElementNS(e,t),body:o},getComputedStyle:(e,t)=>getComputedStyle(e,t)},remove(){}};let d=await createImageBitmap(await r.domToCanvas(u));n({channel:e,session:t,op:`capture-view-result`,id:a.id,bitmap:d},`*`,[d])}catch(r){n({channel:e,session:t,op:`capture-view-result`,id:a.id,error:String(r?.message||r).slice(0,300)},`*`)}finally{l.remove()}})}Et();function GU(e){return B(Array.isArray(e)&&e.length>0&&e.length<=128&&e.every(e=>typeof e==`string`&&/^[a-f0-9]{64}$/.test(e)),`SCHEMA`,`Provide 1–128 exact source digests`),[...new Set(e)]}async function KU(e){mt(e);let t=e?.stages&&e.packages||[];return B(Array.isArray(t)&&t.length<128,`LIMIT`,`Too many packaged Blocks for execution review`),GU(await Promise.all([e,...t].map(e=>gt(e))))}async function qU(e){let t=await KU(e),n=new Set(t),r=e?.stages?e.packages||[]:[e],i=e=>{B(e&&typeof e.digest==`string`&&/^[a-f0-9]{64}$/.test(e.digest),`SCHEMA`,`Block lineage needs exact source digests`),n.add(e.digest),B(n.size<=128,`LIMIT`,`Block source and ancestry exceed the security review limit`)};for(let e of r){let t=e.manifest?.provenance;t?.remixedFrom!==void 0&&i(t.remixedFrom);let n=t?.remixAncestors??[];B(Array.isArray(n)&&n.length<=64,`SCHEMA`,`Block ancestry must contain at most 64 exact source references`),n.forEach(i);let r=e.portable?.lineage?.parents??[];B(Array.isArray(r)&&r.length<=16,`SCHEMA`,`Portable lineage must contain at most 16 exact source references`),r.forEach(i)}return GU([...n])}var JU=`stillmade.block-security.v1`,YU=new Map;function XU(e,t){let n=e?.revision||0,r=t.revision||0;return{revision:Math.max(n,r),published:t.published||e?.published===!0,revoked:n>r?e.revoked:n===r?t.revoked||e?.revoked===!0:t.revoked}}function ZU(){try{let e=JSON.parse(globalThis.localStorage?.getItem(JU)||`{}`);for(let[t,n]of Object.entries(e))/^[a-f0-9]{64}$/.test(t)&&n&&typeof n.revoked==`boolean`&&typeof n.published==`boolean`&&Number.isInteger(n.revision)&&n.revision>=0&&YU.set(t,XU(YU.get(t),n))}catch{}return YU}function QU(e){let t=ZU();for(let n of e){let e=t.get(n.digest);(n.revoked||n.published||e)&&t.set(n.digest,XU(e,n))}try{globalThis.localStorage?.setItem(JU,JSON.stringify(Object.fromEntries(t)))}catch{}}var $U=()=>Object.assign(Error(`This exact Block version has been quarantined by StillMade. Use a reviewed replacement.`),{code:`BLOCK_REVOKED`});async function eW(e,{signal:t}={}){let n=await qU(e),r=ZU();if(t?.aborted)throw Object.assign(Error(`Cancelled`),{code:`CANCELLED`});let i=new AbortController,a=()=>i.abort();t?.addEventListener(`abort`,a,{once:!0});let o=setTimeout(a,3e3),s;try{let e=await fetch(`/api/blocks/runtime-policy`,{method:`POST`,credentials:`omit`,cache:`no-store`,headers:{"Content-Type":`application/json`},body:JSON.stringify({digests:n}),signal:i.signal});if(!e.ok)throw Error(`Block security check unavailable`);if(s=await e.json(),!Array.isArray(s.digests)||s.digests.length!==n.length||new Set(s.digests.map(e=>e.digest)).size!==n.length||s.digests.some(e=>!n.includes(e.digest)||typeof e.revoked!=`boolean`||typeof e.published!=`boolean`||!Number.isInteger(e.revision)||e.revision<0))throw Error(`Invalid security response`);QU(s.digests)}catch{if(t?.aborted)throw Object.assign(Error(`Cancelled`),{code:`CANCELLED`});if(n.some(e=>r.get(e)?.revoked))throw $U();if(n.some(e=>r.get(e)?.published))throw Object.assign(Error(`Reconnect to check the safety of this published Block before running it.`),{code:`REVOCATION_UNAVAILABLE`});return{checked:!1}}finally{clearTimeout(o),t?.removeEventListener(`abort`,a)}if(n.some(e=>ZU().get(e)?.revoked))throw $U();return{checked:!0}}ut();var tW=(e,t)=>Object.freeze({kind:e,mimeType:t}),nW=Object.freeze({png:tW(`image`,`image/png`),jpg:tW(`image`,`image/jpeg`),jpeg:tW(`image`,`image/jpeg`),webp:tW(`image`,`image/webp`),gif:tW(`image`,`image/gif`),mp4:tW(`video`,`video/mp4`),mov:tW(`video`,`video/quicktime`),webm:tW(`video`,`video/webm`),mp3:tW(`audio`,`audio/mpeg`),wav:tW(`audio`,`audio/wav`),m4a:tW(`audio`,`audio/mp4`),aac:tW(`audio`,`audio/aac`),ogg:tW(`audio`,`audio/ogg`),...Object.fromEntries(Object.entries(it).map(([e,t])=>[e,tW(`file`,t)]))});Object.freeze(Object.fromEntries(Object.entries(nW).filter(([,e])=>e.kind!==`file`))),Object.freeze({"text/csv":[`application/vnd.ms-excel`,`text/x-csv`,`application/csv`],"text/markdown":[`text/x-markdown`,`text/plain`],"application/zip":[`application/x-zip-compressed`],"application/json":[`text/json`]}),Object.freeze([`image`,`video`,`audio`]);var rW=Object.freeze({png:`PNG`,jpg:`JPEG`,webp:`WebP`,gif:`GIF`,mp4:`MP4`,mov:`MOV`,webm:`WebM`,mp3:`MP3`,wav:`WAV`,m4a:`M4A`,aac:`AAC`,ogg:`OGG`,pdf:`PDF`,txt:`TXT`,csv:`CSV`,md:`Markdown`,json:`JSON`,zip:`ZIP`}),iW=e=>Object.entries(nW).filter(([t,n])=>e.includes(n.kind)&&rW[t]).map(([e])=>rW[e]),aW=e=>e.length>1?`${e.slice(0,-1).join(`, `)}, or ${e.at(-1)}`:e[0],oW=e=>aW([...new Set(iW(e))]);async function sW(e,t,{guard:n,loadBytes:r}={}){let i=typeof t==`string`&&e?.files&&Object.hasOwn(e.files,t)?e.files[t]:null;if(!i||!ZH(i))throw Object.assign(Error(`${String(t).slice(0,160)} is not one of this view's code files.`),{code:`VIEW`});if(typeof n!=`string`||!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(n))throw Object.assign(Error(`Invalid interface guard`),{code:`VIEW`});let a=lW.get(i.sha256);if(!a)for(a=(async()=>{let n=await _H(e,t,await r(i.sha256)),a;try{a=new TextDecoder(`utf-8`,{fatal:!0}).decode(n)}catch{throw Object.assign(Error(`Code file ${t} is not UTF-8 text.`),{code:`VIEW`})}return PH(a,t,cW)})(),lW.set(i.sha256,a),a.catch(()=>lW.delete(i.sha256));lW.size>uW;)lW.delete(lW.keys().next().value);return(await a).replaceAll(cW,n)}var cW,lW,uW,dW=o((()=>{vH(),cW=`__sm_code_guard_${globalThis.crypto.randomUUID().replaceAll(`-`,``)}`,lW=new Map,uW=48})),fW=c({loadViewAssets:()=>pW,loadViewCode:()=>mW});async function pW(e,{signal:t}={}){let n={};for(let[r,i]of Object.entries(e?.files||{})){if(ZH(i))continue;let a=await _H(e,r,await gW(i.sha256,{signal:t}));n[r]={mediaType:i.mediaType,base64:hW(a)}}return n}function mW(e,t,{guard:n}={}){return sW(e,t,{guard:n,loadBytes:gW})}var hW,gW,_W=o((()=>{vH(),QH(),dW(),hW=e=>{let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)},gW=async(e,{signal:t}={})=>{let n=await fetch(`/__dev/files/`+e,{signal:t});if(!n.ok)throw Error(`A view file is missing from the Block folder.`);return new Uint8Array(await n.arrayBuffer())}}));function vW(e,t,n){return e===void 0?{}:(B(vt(e)&&Object.keys(e).every(e=>t.includes(e)),`CAPABILITY_SETTINGS`,`${n} settings accept only ${t.join(`, `)}`),e)}function yW(e,t,n={}){let r=(e===`video`?AW:kW)[t];return!r||!vt(n)?!1:Object.entries(e===`video`?WW:UW).every(([e,t])=>!GW(n[e])||r[t].includes(n[e]))}function bW(e){return yW(`image`,`nano-banana-2`,e)?zW:KW.find(t=>kW[t]&&yW(`image`,t,e))??`nano-banana-2`}function xW(e,{strict:t=!1}={}){let n=vW(e,LW,`Image`),r=n.model===void 0?bW(n):PW(n.model),i=n.model!==void 0&&r!==n.model,a=kW[r];B(a,`CAPABILITY_SETTINGS`,`Choose an image model from: ${Object.keys(kW).join(`, `)}`);let o=(e,r,o)=>{let s=VW(r,n[e],o);return t&&!i&&HW(n,e)&&B(n[e]===s,`CAPABILITY_SETTINGS`,`${a.label} accepts ${e} ${r.length?r.join(`, `):IW}`),s};return{model:r,aspectRatio:o(`aspectRatio`,a.aspectRatios,a.aspectRatios.includes(`1:1`)?`1:1`:void 0),resolution:o(`resolution`,a.resolutions),quality:o(`quality`,a.qualities,a.qualities.includes(`medium`)?`medium`:void 0)}}function SW(e,{firstFrame:t,lastFrame:n}){let r=e.aspectRatio;if(r===void 0||r==="default"||r===`auto`||AW[`vidu-q3-turbo`].aspectRatios.includes(r))return BW;let i=i=>i.aspectRatios.includes(r)&&(t||!i.requiresFirstFrame)&&(!n||i.lastFrame)&&(e.duration===void 0||i.durations.includes(e.duration));return qW.find(e=>i(AW[e]))??`vidu-q3-turbo`}function CW(e,{strict:t=!1,firstFrame:n=!1,lastFrame:r=!1}={}){let i=vW(e,RW,`Video`),a=i.model===void 0?SW(i,{firstFrame:n,lastFrame:r}):FW(i.model),o=i.model!==void 0&&a!==i.model,s=AW[a];B(s,`CAPABILITY_SETTINGS`,`Choose a video model from: ${Object.keys(AW).join(`, `)}`);let c=(e,n,r)=>{let a=VW(n,i[e],r);return t&&!o&&HW(i,e)&&B(i[e]===a,`CAPABILITY_SETTINGS`,`${s.label} accepts ${e} ${n.length?n.join(`, `):IW}`),a},l=c(`resolution`,s.resolutions,s.resolutions.includes(`720p`)?`720p`:void 0),u=a===`veo-3.1-lite`&&l===`1080p`?[8]:s.durations,d=c(`duration`,u,u.includes(5)?5:void 0);return B(typeof(i.generateAudio??!0)==`boolean`,`CAPABILITY_SETTINGS`,`generateAudio is true or false`),t&&s.requiresFirstFrame&&B(n,`CAPABILITY_SETTINGS`,`${s.label} needs a first-frame image`),{model:a,duration:d,resolution:l,aspectRatio:c(`aspectRatio`,s.aspectRatios,s.aspectRatios.includes(`16:9`)?`16:9`:void 0),generateAudio:i.generateAudio??!0}}var wW,TW,EW,DW,OW,kW,AW,jW,MW,NW,PW,FW,IW,LW,RW,zW,BW,VW,HW,UW,WW,GW,KW,qW,JW=o((()=>{Et(),wW=Object.freeze([`auto`,`21:9`,`16:9`,`3:2`,`4:3`,`1:1`,`4:5`,`3:4`,`2:3`,`9:16`]),TW=Object.freeze([`auto`,`21:9`,`16:9`,`4:3`,`1:1`,`3:4`,`9:16`]),EW=Object.freeze([4,5,6,7,8,9,10,11,12,13,14,15]),DW=(e,{aspectRatios:t,resolutions:n=[],qualities:r=[],references:i=0,seed:a=!1})=>Object.freeze({label:e,aspectRatios:Object.freeze(t),resolutions:Object.freeze(n),qualities:Object.freeze(r),references:i,seed:a}),OW=(e,{aspectRatios:t=[],resolutions:n=[],durations:r,firstFrame:i=!0,lastFrame:a=!1,requiresFirstFrame:o=!1,seed:s=!1,nativeAudio:c=!1})=>Object.freeze({label:e,aspectRatios:Object.freeze(t),resolutions:Object.freeze(n),durations:Object.freeze(r),firstFrame:i,lastFrame:a,requiresFirstFrame:o,seed:s,nativeAudio:c}),kW=Object.freeze({"nano-banana-2":DW(`Nano Banana 2`,{aspectRatios:wW,resolutions:[`1K`,`2K`,`4K`],references:8,seed:!0}),"nano-banana-2-lite":DW(`Nano Banana 2 Lite`,{aspectRatios:wW,resolutions:[`1K`,`2K`,`4K`],references:8,seed:!0}),"nano-banana-pro":DW(`Nano Banana Pro`,{aspectRatios:wW,resolutions:[`1K`,`2K`,`4K`],references:8,seed:!0}),"gpt-image-2":DW(`GPT Image 2`,{aspectRatios:[`auto`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`1K`,`2K`,`4K`],qualities:[`low`,`medium`,`high`],references:8}),"gpt-image-2.5-flare":DW(`GPT Image 2.5 Flare`,{aspectRatios:[`auto`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`1K`,`2K`,`4K`],qualities:[`low`,`medium`,`high`],references:8}),"gpt-image-2.5-sunburst":DW(`GPT Image 2.5 Sunburst`,{aspectRatios:[`auto`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`1K`,`2K`,`4K`],qualities:[`low`,`medium`,`high`],references:8}),"gpt-image-2.6-flare":DW(`GPT Image 2.6 Flare`,{aspectRatios:[`auto`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`1K`,`2K`,`4K`],qualities:[`low`,`medium`,`high`],references:8}),"gpt-image-2.6-sunburst":DW(`GPT Image 2.6 Sunburst`,{aspectRatios:[`auto`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`1K`,`2K`,`4K`],qualities:[`low`,`medium`,`high`],references:8}),"gpt-image-1.5":DW(`GPT-Image 1.5`,{aspectRatios:[`16:9`,`9:16`,`1:1`],qualities:[`low`,`medium`,`high`]}),"kling-image-v3":DW(`Kling Image V3`,{aspectRatios:[`21:9`,`16:9`,`9:16`,`1:1`,`4:3`,`3:4`,`3:2`,`2:3`],resolutions:[`1K`,`2K`]}),"seedream-v4.5":DW(`Seedream 4.5`,{aspectRatios:[`16:9`,`9:16`,`1:1`,`4:3`,`3:4`],resolutions:[`2K`,`4K`],seed:!0})}),AW=Object.freeze({"seedance-2.0":OW(`Seedance 2.0`,{aspectRatios:TW,resolutions:[`480p`,`720p`,`1080p`,`4k`],durations:EW,lastFrame:!0,seed:!0,nativeAudio:!0}),"seedance-2.0-fast":OW(`Seedance 2.0 Fast`,{aspectRatios:TW,resolutions:[`480p`,`720p`],durations:EW,lastFrame:!0,seed:!0,nativeAudio:!0}),"seedance-2.0-mini":OW(`Seedance 2.0 Mini`,{aspectRatios:TW,resolutions:[`480p`,`720p`],durations:EW,lastFrame:!0,seed:!0,nativeAudio:!0}),"kling-v3-turbo":OW(`Kling 3.0 Turbo`,{aspectRatios:[`16:9`,`9:16`,`1:1`],durations:[5,10]}),"wan-2.6-flash":OW(`Wan 2.6 Flash`,{aspectRatios:[`16:9`,`9:16`,`1:1`],durations:[3,4,5],requiresFirstFrame:!0}),"veo-3.1-lite":OW(`Veo 3.1 Lite`,{aspectRatios:[`16:9`,`9:16`],resolutions:[`720p`,`1080p`],durations:[4,6,8],lastFrame:!0,nativeAudio:!0}),"vidu-q3-turbo":OW(`Vidu Q3 Turbo`,{durations:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],lastFrame:!0,nativeAudio:!0}),"wan-2.7":OW(`Wan 2.7`,{resolutions:[`720p`,`1080p`],durations:[2,3,4,5,6,7,8,9,10,11,12,13,14,15],lastFrame:!0,requiresFirstFrame:!0,seed:!0})}),jW=Object.freeze({"seedream-4.5":`seedream-v4.5`}),MW=Object.freeze({}),NW=(e,t,n)=>{for(let r=0;typeof n==`string`&&!Object.hasOwn(e,n)&&Object.hasOwn(t,n)&&r<8;r++)n=t[n];return n},PW=e=>NW(kW,jW,e),FW=e=>NW(AW,MW,e),IW=`default`,LW=Object.freeze([`model`,`aspectRatio`,`resolution`,`quality`]),RW=Object.freeze([`model`,`duration`,`resolution`,`aspectRatio`,`generateAudio`]),zW=`nano-banana-2`,BW=`vidu-q3-turbo`,Object.freeze({references:8,negativePrompt:2e3,seed:2147483647}),VW=(e,t,n)=>e.length?e.includes(t)?t:n??e[0]:IW,HW=(e,t)=>e!==void 0&&Object.hasOwn(e,t),UW=Object.freeze({aspectRatio:`aspectRatios`,resolution:`resolutions`,quality:`qualities`}),WW=Object.freeze({aspectRatio:`aspectRatios`,resolution:`resolutions`,duration:`durations`}),GW=e=>e!==void 0&&e!=="default",KW=Object.freeze([`gpt-image-2.5-sunburst`,`gpt-image-2.5-flare`,`gpt-image-2.6-flare`,`gpt-image-2.6-sunburst`,`gpt-image-2`,`seedream-v4.5`,`kling-image-v3`,`nano-banana-pro`,`gpt-image-1.5`]),qW=Object.freeze([`wan-2.6-flash`,`veo-3.1-lite`,`seedance-2.0-mini`,`kling-v3-turbo`,`seedance-2.0-fast`,`seedance-2.0`]),Object.freeze({speech:Object.freeze({text:3800,defaultVoice:`asteria`,speed:Object.freeze({min:.25,max:4,default:1})}),music:Object.freeze({min:5,max:240,default:30}),sfx:Object.freeze({min:.5,max:22,default:4})})})),YW=c({APP_AI_BUDGET_USD:()=>OG,BLOCK_BUILD_BUDGET_USD:()=>wG,CHAT_REPLY_BUDGET_USD:()=>TG,CHAT_WEB_SEARCH_USD:()=>EG,CREDIT_VALUE_USD:()=>tG,FLAT:()=>CG,IMAGE:()=>dG,LARGEST_TEXT_CALL:()=>yG,MARKUP:()=>nG,MUSIC:()=>pG,SFX:()=>mG,SPEECH:()=>fG,TEXT_MODELS:()=>hG,TEXT_MODELS_CHECKED:()=>gG,TYPICAL_TEXT_CALL:()=>vG,UNREPORTED_CALL_USD:()=>DG,VIDEO:()=>lG,VIDEO_ALIASES:()=>uG,exactCredits:()=>rG,imageUsd:()=>QW,largestTextCallUsd:()=>xG,milliCredits:()=>aG,musicUsd:()=>jG,sfxUsd:()=>MG,sizedTextCallCredits:()=>ZW,speechUsd:()=>eG,textCallCredits:()=>XW,typicalTextCallUsd:()=>bG,usdCoveredBy:()=>oG,videoModelId:()=>AG,videoUsd:()=>$W,wholeCredits:()=>iG});function XW(e){let t=_G(e,vG.input,vG.output),n=_G(e,yG.input,yG.output);return t===null?null:Math.max(iG(t,`media`),Math.ceil(n/tG-1e-9))}function ZW(e,{inputBytes:t=0,maxTokens:n=0}={}){let r=XW(e);if(r===null)return null;if(t<=4e4&&n<=yG.output)return r;let i=_G(e,Math.ceil(t/4),Math.min(n,Math.max(vG.output,Math.ceil(n/3)))),a=_G(e,t+64,n);return Math.max(r,iG(i,`media`),Math.ceil(a/tG-1e-9))}function QW({model:e=`gpt-image-2`,quality:t,resolution:n,references:r}={}){let i=dG[e]||dG[`gpt-image-2`],a=String(n||``).toUpperCase(),o=r===void 0||Number(r)>0;if(i.quality){let e=i.quality[kG(i.quality,String(t||``).toLowerCase(),`low`)];return e[kG(e,a,`1K`)]+(o&&i.referenceUsd||0)}return i.usd*(i.resolution?.[kG(i.resolution,a,`1K`)]??1)}function $W({model:e,seconds:t=6,resolution:n}={}){let r=lG[AG(e)],i=r.resolution||{},a=kG(i,String(n||``).toLowerCase(),Object.hasOwn(i,`720p`)?`720p`:Object.keys(i)[0]);return r.usd*(i[a]??1)*Math.max(1,Math.ceil(Number(t)||6))}function eG({chars:e,seconds:t,provider:n=`deepgram`}={}){return(fG[n]||fG.elevenlabs).usdPer1kChars*(Number(e)>0?Number(e):Math.max(1,Number(t)||30)*12.5)/1e3}var tG,nG,rG,iG,aG,oG,sG,cG,lG,uG,dG,fG,pG,mG,hG,gG,_G,vG,yG,bG,xG,SG,CG,wG,TG,EG,DG,OG,kG,AG,jG,MG,NG=o((()=>{tG=2399/11e4,nG=Object.freeze({video:3,build:3,media:4.5,other:3,chat:2}),rG=(e,t)=>Math.max(0,Number(e)||0)*nG[t]/tG,iG=(e,t)=>Math.max(1,Math.ceil(rG(e,t)-1e-9)),aG=(e,t=`chat`)=>Math.ceil(rG(e,t)*1e3-1e-6),oG=(e,t)=>Math.max(0,Number(e)||0)*tG/nG[t],sG=`2026-11-05`,cG=`carried`,lG=Object.freeze({"veo-3.1-lite":{usd:.05,resolution:{"720p":1,"1080p":1.6},provider:`Atlas`,checked:sG,source:`Atlas catalog list price $0.05/s; 1080p at $0.08/s, Google's Veo 3.1 Lite step`},"vidu-q3-turbo":{usd:.04,provider:`Atlas`,checked:sG,source:`Atlas catalog list price (we pay $0.034)`},"wan-2.6-flash":{usd:.025,provider:`Atlas`,checked:sG,source:`Atlas catalog list price (we pay $0.018)`},"wan-2.7":{usd:.17,provider:`Higgsfield, then Atlas`,checked:cG,source:`Atlas $0.10/s at 720p (checked); the 1.7x step to the 1080p we generate is carried from the old table`},"kling-v3-turbo":{usd:.112,provider:`Higgsfield, then Atlas`,checked:sG,source:`Atlas catalog list price (we pay $0.095); Higgsfield $0.056/s on promotion`},"seedance-2.0":{usd:.2,resolution:{"480p":1,"720p":1.3,"1080p":3.2,"4k":7.5},provider:`BytePlus Ark`,checked:cG,source:`Ark is priced per token and its price page does not load without an account; carried from the old table (verify against an Ark invoice)`},"seedance-2.0-fast":{usd:.09,resolution:{"480p":1,"720p":1.3},provider:`BytePlus Ark`,checked:cG,source:`carried from the old table (Atlas lists $0.09/s)`},"seedance-2.0-mini":{usd:.09,resolution:{"480p":1,"720p":1.3},provider:`BytePlus Ark`,checked:cG,source:`priced as Fast, carried from the old table (Atlas lists $0.056/s)`}}),uG=Object.freeze({"seedance-2":`seedance-2.0`,"kling-3":`kling-v3-turbo`,"kling-v3-pro":`kling-v3-turbo`,"kling-v3-std":`kling-v3-turbo`,"kling-o3-std":`kling-v3-turbo`}),dG=Object.freeze({"gpt-image-2":{quality:{low:{"1K":.006,"2K":.007,"4K":.012},medium:{"1K":.053,"2K":.056,"4K":.101},high:{"1K":.211,"2K":.222,"4K":.401}},referenceUsd:.02,provider:`OpenAI for square, fal then Atlas for other shapes`,checked:sG,source:`fal gpt-image-2 price table (dearest size in each class); OpenAI direct is $30 per million output tokens`},"gpt-image-2.5-flare":{quality:{low:{"1K":.00588,"2K":.00615,"4K":.01113},medium:{"1K":.01317,"2K":.01434,"4K":.02595},high:{"1K":.05268,"2K":.05529,"4K":.10008}},referenceUsd:.02,provider:`OpenAI for square, fal for other shapes`,checked:`2026-11-06`,source:`fal openai/gpt-image-2.5/flare price table; OpenAI rate card $30 per million output tokens`},"gpt-image-2.5-sunburst":{quality:{low:{"1K":.00588,"2K":.00615,"4K":.01113},medium:{"1K":.01317,"2K":.01434,"4K":.02595},high:{"1K":.05268,"2K":.05529,"4K":.10008}},referenceUsd:.02,provider:`OpenAI for square, fal for other shapes`,checked:`2026-11-06`,source:`fal openai/gpt-image-2.5/sunburst price table; OpenAI rate card $30 per million output tokens`},"gpt-image-2.6-flare":{quality:{low:{"1K":.00588,"2K":.00615,"4K":.01113},medium:{"1K":.01317,"2K":.01434,"4K":.02595},high:{"1K":.05268,"2K":.05529,"4K":.10008}},referenceUsd:.02,provider:`OpenAI for square, fal for other shapes`,checked:`2026-11-07`,source:`OpenAI and fal gpt-image-2.6 token rates ($30 per million output tokens); per-image price taken from 2.5 until published`},"gpt-image-2.6-sunburst":{quality:{low:{"1K":.00588,"2K":.00615,"4K":.01113},medium:{"1K":.01317,"2K":.01434,"4K":.02595},high:{"1K":.05268,"2K":.05529,"4K":.10008}},referenceUsd:.02,provider:`OpenAI for square, fal for other shapes`,checked:`2026-11-07`,source:`OpenAI and fal gpt-image-2.6 token rates ($30 per million output tokens); per-image price taken from 2.5 until published`},"gpt-image-1.5":{quality:{low:{"1K":.013},medium:{"1K":.051},high:{"1K":.2}},provider:`fal`,checked:sG,source:`fal price for a non-square image`},"nano-banana-2":{usd:.08,resolution:{"1K":1,"2K":1.5,"4K":2},provider:`fal`,checked:sG,source:`fal: $0.08 at 1K, 1.5x at 2K, 2x at 4K`},"nano-banana-2-lite":{usd:.048,provider:`fal`,checked:sG,source:`fal: $37.50 per million output tokens, one 1K image (about 1,290 tokens)`},"nano-banana-pro":{usd:.15,resolution:{"1K":1,"2K":1,"4K":2},provider:`fal`,checked:sG,source:`fal: $0.15, 4K at double`},"kling-image-v3":{usd:.028,provider:`fal`,checked:sG,source:`fal: $0.028 per image`},"seedream-v4.5":{usd:.04,provider:`fal`,checked:sG,source:`fal: $0.04 per image`},"flux-step":{usd:.02,provider:`fal`,checked:cG,source:`carried from the old table`},flux:{usd:.04,provider:`fal`,checked:cG,source:`carried from the old table`},ideogram:{usd:.08,provider:`fal`,checked:cG,source:`carried from the old table`},gemini:{usd:.08,resolution:{"1K":1,"2K":1.5,"4K":2},provider:`fal`,checked:sG,source:`served as Nano Banana 2`}}),fG=Object.freeze({deepgram:{usdPer1kChars:.03,checked:sG,source:`Deepgram Aura-2 pay as you go`},openai:{usdPer1kChars:.015,checked:sG,source:`OpenAI tts-1, $15 per million characters`},elevenlabs:{usdPer1kChars:.04,checked:sG,source:`ElevenLabs API, Flash / Turbo`},kokoro:{usdPer1kChars:.02,checked:sG,source:`fal Kokoro`}}),pG=Object.freeze({usdPerSecond:2e-4,checked:sG,source:`fal ACE-Step, per second of audio`}),mG=Object.freeze({usdPerSecond:.002,checked:sG,source:`fal ElevenLabs sound effects v2, per second`}),hG=Object.freeze({"openai/gpt-5-mini":{input:.25,output:2},"google/gemini-2.5-flash":{input:.3,output:2.5},"anthropic/claude-haiku-5.5":{input:.1,output:.5},"anthropic/claude-sonnet-4":{input:3,output:15},"anthropic/claude-sonnet-4.5":{input:3,output:15},"anthropic/claude-sonnet-5.5":{input:2,output:10},"openai/gpt-5.4":{input:2.5,output:15},"google/gemini-2.5-pro":{input:1.25,output:10},"x-ai/grok-4.5":{input:2,output:6},"x-ai/grok-4.20":{input:1.25,output:2.5},"anthropic/claude-opus-4.1":{input:15,output:75},"anthropic/claude-opus-4.5":{input:5,output:25},"anthropic/claude-opus-4.8":{input:5,output:25},"openai/gpt-5.5":{input:5,output:30}}),gG=sG,_G=(e,t,n)=>{let r=hG[e];return r?(t*r.input+n*r.output)/1e6:null},vG=Object.freeze({input:2e3,output:1e3}),yG=Object.freeze({input:1e4,output:4096}),bG=e=>_G(e,vG.input,vG.output),xG=e=>_G(e,yG.input,yG.output),SG=(e,t,n,r,i={})=>Object.freeze({usd:e,tier:t,unit:n,source:r,checked:i.checked||cG,...i}),CG=Object.freeze({"media:analyze":SG(.02,`media`,`call`,`the vision provider caps a call at $0.02 (VISION_MAX_INITIAL_COST)`,{checked:sG}),"media:check":SG(.005,`media`,`call`,`four photos at most, $0.00125 each (MEDIA_CHECK_IMAGE_USD)`,{checked:sG}),"research:search":SG(.008,`media`,`search`,`Tavily basic search`,{checked:sG}),"research:summarize":SG(.01,`media`,`call`,`one Gemini Flash read of fetched pages`,{estimate:!0}),"transcribe:timestamp":SG(.01,`media`,`run`,`fal Whisper word timing`,{estimate:!0}),"transcribe:upload":SG(.01,`media`,`run`,`fal Whisper word timing`,{estimate:!0}),"transcribe:captions":SG(.01,`media`,`run`,`fal Whisper word timing`,{estimate:!0}),"connection:action":SG(.012,`other`,`action`,`a premium Composio tool call at the overage rate`,{checked:sG}),"automation:app-event":SG(.003,`other`,`event`,`Composio, per trigger event`,{checked:sG}),"automation:app-check":SG(3e-4,`other`,`check`,`Composio, per tool call`,{checked:sG}),llm:SG(.01,`other`,`call`,`a Standard model call`,{estimate:!0}),vision:SG(.01,`other`,`image`,`one vision read`,{estimate:!0}),"narrative:compile":SG(.06,`other`,`script`,`about ten Gemini Flash calls`,{estimate:!0}),"narrative:compile-research":SG(.1,`other`,`script`,`the compile plus three Tavily searches and a dossier`,{estimate:!0}),"narrative:learn-voice":SG(.01,`other`,`call`,`one extraction call`,{estimate:!0}),"roughcut:base":SG(.05,`other`,`run`,`segmentation and matching`,{estimate:!0}),"roughcut:per-min":SG(.015,`other`,`footage minute`,`Gemini Flash frame reads`,{estimate:!0}),"finaledit:base":SG(.06,`other`,`run`,`polish decisions`,{estimate:!0}),"finaledit:per-min":SG(.02,`other`,`video minute`,`Gemini Flash scan`,{estimate:!0}),"aomotion:base":SG(.06,`other`,`run`,`motion graphics pass`,{estimate:!0}),"aomotion:per-min":SG(.02,`other`,`video minute`,`motion graphics pass`,{estimate:!0}),"aomotion:base:opus":SG(.12,`other`,`run`,`motion graphics pass on Opus`,{estimate:!0}),"aomotion:per-min:opus":SG(.04,`other`,`video minute`,`motion graphics pass on Opus`,{estimate:!0}),motiongraphic:SG(.015,`other`,`graphic`,`one small call`,{estimate:!0}),"transcript:parse":SG(.005,`other`,`1,000 characters`,`Gemini Flash word timing`,{estimate:!0}),"vibe-edit":SG(.02,`other`,`turn`,`Flash region scan and decision`,{estimate:!0}),"canvas:context-connect":SG(.01,`other`,`run`,`one canvas read`,{estimate:!0}),"anim2:plan":SG(.03,`other`,`video`,`shot planning`,{estimate:!0}),"anim2:vibe":SG(.03,`other`,`turn`,`scene vibe turn`,{estimate:!0}),"anim2:qa":SG(.03,`other`,`frame`,`vision QA`,{estimate:!0}),"anim2:trigger":SG(.01,`other`,`scene`,`one Haiku call`,{estimate:!0}),"gif:plan":SG(.03,`other`,`pass`,`GIF planning`,{estimate:!0}),"canvas:plan":SG(.03,`other`,`pass`,`collage planning`,{estimate:!0}),"canvasChat:build":SG(.03,`other`,`build`,`canvas chat orchestration`,{estimate:!0}),"strip:plan":SG(.05,`other`,`pass`,`strip planning`,{estimate:!0}),"panel:qa":SG(.03,`other`,`pass`,`style-consistency vision pass`,{estimate:!0})}),wG=Object.freeze({standard:.4,balanced:.85,reasoning:.5,premium:1.4}),TG=.06,EG=.008,DG=Object.freeze({build:.1,chat:.005,other:.05}),OG=.25,kG=(e,t,n)=>e&&Object.hasOwn(e,t)?t:n,AG=e=>{let t=String(e||``).toLowerCase();return lG[t]?t:uG[t]||(t.includes(`kling`)?`kling-v3-turbo`:t.includes(`seedance`)?`seedance-2.0`:`wan-2.6-flash`)},jG=e=>pG.usdPerSecond*e,MG=e=>mG.usdPerSecond*e})),PG,FG,IG=o((()=>{NG(),PG=[{value:`openai/gpt-5-mini`,label:`GPT-5 mini`},{value:`google/gemini-2.5-flash`,label:`Gemini 2.5 Flash`},{value:`anthropic/claude-opus-4.8`,label:`Claude Opus 4.8`},{value:`anthropic/claude-opus-4.5`,label:`Claude Opus 4.5`},{value:`anthropic/claude-opus-4.1`,label:`Claude Opus 4.1`},{value:`anthropic/claude-sonnet-4.5`,label:`Claude Sonnet 4.5`},{value:`anthropic/claude-sonnet-4`,label:`Claude Sonnet 4`},{value:`openai/gpt-5.5`,label:`GPT-5.5`},{value:`openai/gpt-5.4`,label:`GPT-5.4`},{value:`google/gemini-2.5-pro`,label:`Gemini 2.5 Pro`},{value:`x-ai/grok-4.20`,label:`Grok 4.20`},{value:`x-ai/grok-4.5`,label:`Grok 4.5`}],FG=Object.freeze(Object.fromEntries([`openai/gpt-5-mini`,`google/gemini-2.5-flash`,`anthropic/claude-sonnet-4`,`anthropic/claude-sonnet-4.5`,`openai/gpt-5.4`,`google/gemini-2.5-pro`,`x-ai/grok-4.5`,`x-ai/grok-4.20`,`anthropic/claude-opus-4.1`,`anthropic/claude-opus-4.5`,`anthropic/claude-opus-4.8`,`openai/gpt-5.5`].map(e=>[e,XW(e)]))),FG[`anthropic/claude-sonnet-4.5`]})),LG=o((()=>{IG()}));function RG(e,t,{references:n=!1,firstFrame:r=!1}={}){let i=e===`audio.speech`,a=e===`audio.transcribe`,o=e===`image.generate`,s=e===`video.generate`,c=e===`web.fetch`||e===`web.research`,l=e===`media.analyze`,u=e===`audio.music`||e===`audio.sfx`,d=i||o||s||u,f=u||c||l,p=e=>(o||s)&&e?.selection?.provider===`stillmade`&&e.selection.payment===`credits`&&Object.hasOwn(o?kW:AW,e.selection.model)&&(!s||r||!AW[e.selection.model].requiresFirstFrame),m=t=>t?.selection?.provider===`stillmade`&&t.selection.payment===`credits`&&(l?t.selection.model===`media-vision`:c?t.selection.model===(e===`web.fetch`?`web-fetch`:`web-research`):i?t.selection.model===`voice-catalog`&&zG(t).length>0:a?t.selection.model===`whisper-large-v3-turbo`:u&&t.selection.model===(e===`audio.music`?`ace-step`:`sound-effects`)),h=s?`atlas`:d||a?`openai`:`openrouter`;return Array.isArray(t?.options)?t.options.filter(e=>p(e)||m(e)||!f&&e?.selection?.provider===h&&[`credits`,`byok`].includes(e.selection.payment)&&typeof e.selection.model==`string`&&e.selection.model.length>0&&(!i||e.selection.model===`tts-1`)&&(!a||e.selection.payment===`byok`&&e.selection.model===`whisper-1`)&&(!o||e.selection.model===`gpt-image-2`&&e.selection.size===`1024x1024`)).filter(e=>!(o&&n)||BG(e)):[]}var zG,BG,VG=o((()=>{Et(),JW(),LG(),zG=e=>Array.isArray(e?.voices)?e.voices.filter(e=>typeof e?.id==`string`&&/^[a-z][a-z0-9_-]{0,63}$/.test(e.id)&&typeof e.label==`string`&&e.label.length<=120):[],BG=e=>e?.selection?.provider===`stillmade`&&kW[e.selection.model]?.references>0}));function HG(e){let t=String(e?.manifest?.name||``).split(` · `);if(t.length>1&&t[0].trim())return t[0].trim();let n=ZG(e);return GG[n]||(n?QG(n):`the app`)}function UG(e){let t=String(e?.manifest?.name||``).split(` · `).slice(1).join(` `),n=String(e?.capability?.capabilityId||``).split(`:`).at(-1),r=ZG(e).replace(/[-_.]/g,``).toLowerCase(),i=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,` `).trim().split(` `).filter(Boolean);return t.length>1&&t[0].replace(/[-_.]/g,``)===r&&t.shift(),t};for(let e of[i(t),i(n)]){let t=e.slice(0,3),n=t.find(e=>KG.test(e)||qG.has(e)||YG.some(([,t])=>t.has(e)));if(n&&KG.test(n))return`read`;if(e.some(e=>qG.has(e))||t.some(e=>[`create`,`upload`,`share`].includes(e))&&e.some(e=>JG.has(e)))return`post`;let r=n&&YG.find(([,e])=>e.has(n));if(r)return r[0]}return`send`}function WG(e){let t=HG(e),n=UG(e),[r,i]=XG[n];return{app:t,kind:n,verbs:[`${r} ${t}`,`${i} ${t}…`],canPostLater:n===`post`}}var GG,KG,qG,JG,YG,XG,ZG,QG,$G,eK=o((()=>{GG=Object.freeze({googlesheets:`Google Sheets`,googledrive:`Google Drive`,googledocs:`Google Docs`,googlecalendar:`Google Calendar`,gmail:`Gmail`,youtube:`YouTube`,tiktok:`TikTok`,linkedin:`LinkedIn`,hubspot:`HubSpot`,github:`GitHub`,whatsapp:`WhatsApp`,"meta-ads":`Meta Ads`}),KG=/^(fetch|list|get|search|find|read|retrieve|query|download|lookup|look|check|watch|count|export)$/,qG=new Set([`post`,`posts`,`publish`,`tweet`,`reel`,`reels`,`story`,`stories`,`carousel`,`pin`]),JG=new Set([`video`,`videos`,`photo`,`photos`,`image`,`images`,`media`]),YG=[[`send`,new Set([`send`,`reply`,`message`,`notify`,`email`,`forward`,`dm`,`invite`])],[`add`,new Set([`add`,`append`,`insert`,`create`,`new`,`log`,`save`,`record`,`upsert`,`write`,`import`,`book`,`schedule`])],[`update`,new Set([`update`,`edit`,`change`,`modify`,`patch`,`set`,`rename`,`move`,`replace`,`mark`])],[`remove`,new Set([`delete`,`remove`,`archive`,`trash`,`cancel`,`unsubscribe`])],[`upload`,new Set([`upload`])]],XG={post:[`Post to`,`Posting to`],send:[`Send to`,`Sending to`],add:[`Add to`,`Adding to`],update:[`Update in`,`Updating in`],remove:[`Remove from`,`Removing from`],upload:[`Upload to`,`Uploading to`],read:[`Get from`,`Getting from`]},ZG=e=>String(e?.capability?.appId||``).replace(/^app:/,``).replace(/^composio:/,``),QG=e=>e.replace(/[-_.]+/g,` `).trim().replace(/\b\w/g,e=>e.toUpperCase()),$G=e=>WG(e).verbs})),tK=c({blockVerbs:()=>nK,creditWords:()=>uK,runButtonLabel:()=>aK,runIsFree:()=>fK,runPrice:()=>iK,runPriceWords:()=>pK,runVerbs:()=>rK});function nK(e){let t=e?.manifest;if(!t)return null;let n=String(t.name||``).trim(),r=n.split(/\s+/)[0].toLowerCase();if(lK.has(r)&&n.includes(` `))return[n,`Working…`];let i=Object.entries(t.outputs||{}).filter(([,e])=>!e?.context),[a,o]=i.find(([,e])=>e?.primary)||i[0]||[],s=a&&!cK.has(sK(a))&&!/action/i.test(String(o?.type||``)),c=o?.label?sK(o.label):sK(s?a:n);return c?[`Make ${c}`,`Making ${c}…`]:null}function rK(e,t){let n=t?.manifest?.action,r=typeof n?.label==`string`?n.label.trim():``;return r?[r,n.running||oK[e]?.[1]||`Working…`]:e===`connection.execute`&&t?$G(t):oK[e]||nK(t)||[`Make the result`,`Making the result…`]}function iK(e,{quality:t,count:n=1}={}){let r=e?.selection;if(!r||e.available===!1)return null;if(r.payment===`byok`)return{byok:!0};if(r.payment!==`credits`)return null;let i=r.provider===`stillmade`&&e.qualityCredits&&Number.isSafeInteger(e.qualityCredits[t])?e.qualityCredits[t]:e.creditsPerCall;return!Number.isSafeInteger(i)||i<0?null:{credits:i*Math.max(1,Math.min(4,Number.isInteger(n)?n:1))}}function aK(e,t,{again:n=!1,free:r=!1,verb:i,connector:a}={}){let o=i||rK(e,a)[0],s=n?`${o} again`:o,c=pK(t,{free:r});return c?`${s} · ${c}`:s}var oK,sK,cK,lK,uK,dK,fK,pK,mK=o((()=>{VG(),eK(),oK=Object.freeze({"text.generate":[`Write`,`Writing…`],"image.generate":[`Generate image`,`Generating image…`],"video.generate":[`Generate video`,`Generating video…`],"video.render":[`Make video`,`Making video…`],"audio.speech":[`Generate voiceover`,`Generating voiceover…`],"audio.transcribe":[`Transcribe`,`Transcribing…`],"image.describe":[`Describe`,`Describing…`],"audio.music":[`Generate music`,`Generating music…`],"audio.sfx":[`Generate sound`,`Generating sound…`],"web.fetch":[`Read page`,`Reading…`],"web.research":[`Research`,`Researching…`],"media.analyze":[`Analyze`,`Analyzing…`],"timeline.propose":[`Suggest edit`,`Suggesting…`],"workspace.propose":[`Suggest changes`,`Suggesting…`],"connection.execute":[`Send`,`Sending…`]}),sK=e=>String(e||``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase(),cK=new Set([`output`,`outputs`,`result`,`results`,`value`,`data`,`out`]),lK=new Set(`add.analyze.animate.build.check.clean.compose.convert.count.create.cut.describe.design.edit.export.extract.find.generate.get.import.make.merge.mix.narrate.pick.plan.post.publish.read.record.remove.render.research.resize.review.schedule.send.split.summarize.transcribe.translate.trim.write`.split(`.`)),uK=e=>`${e.toLocaleString()} credit${e===1?``:`s`}`,dK=new Set([`final.render`]),fK=e=>e?.runtime===`javascript`&&(e.permissions?.actions||[]).every(e=>dK.has(e)),pK=(e,{free:t=!1}={})=>e?.byok?`your key`:Number.isSafeInteger(e?.credits)&&e.credits>0?uK(e.credits):t||e?.credits===0?uK(0):null}));function hK(e){let t=e?.permissions||{},n=new Set((t.capabilities||[]).filter(e=>wt.includes(e))),r=t.actions||[];if(r.includes(`media.generate`))for(let e of Object.values(yK))n.add(e);return(r.includes(`image.generate`)||r.includes(`image.generate.batch`))&&n.add(`image.generate`),[...n]}function gK(e,t){let n=e===`image`,r=(n?kW:AW)[t];if(!r)return null;let i=n?xW({model:t}):CW({model:t}),a=(n?[[`aspectRatio`,r.aspectRatios],[`resolution`,r.resolutions],[`quality`,r.qualities]]:[[`duration`,r.durations],[`resolution`,r.resolutions],[`aspectRatio`,r.aspectRatios]]).filter(([,e])=>e.length).map(([e,t])=>({key:e,label:bK[e],values:[...t],default:i[e]==="default"?t[0]:i[e]}));return!n&&r.nativeAudio&&a.push({key:`generateAudio`,label:bK.generateAudio,values:[!0,!1],default:!0}),n?{settings:a,references:r.references}:{settings:a,firstFrame:r.firstFrame,lastFrame:r.lastFrame,needsFirstFrame:r.requiresFirstFrame,sound:r.nativeAudio}}function _K(e,t=[]){let n=e===`image.generate`,r=e===`video.generate`,i=[];for(let a of Array.isArray(t)?t:[]){let t=a?.selection?.model;if(typeof t!=`string`||!t||i.some(e=>e.id===t))continue;let o=n||r?a.selection.provider===`stillmade`&&gK(n?`image`:`video`,t):null;if((n||r)&&!o)continue;let s=SK(a.fromCredits),c=e===`audio.speech`?xK(a.voices):[];i.push({id:t,label:typeof a.label==`string`&&a.label?a.label.slice(0,120):t,credits:SK(a.creditsPerCall),...s===null?{}:{fromCredits:s},available:a.available!==!1,...a.available===!1&&typeof a.reason==`string`?{reason:a.reason.slice(0,240)}:{},...o||{settings:[]},...c.length?{voices:c}:{}})}return{operation:e,default:i.find(e=>e.available)?.id??null,models:i}}function vK(e){let t=e===`image.generate`;if(!t&&e!==`video.generate`)return{operation:e,default:null,models:[]};let n=t?kW:AW,r=t?zW:BW;return _K(e,[r,...Object.keys(n).filter(e=>e!==r)].map(e=>({selection:{provider:`stillmade`,model:e},label:n[e].label})))}var yK,bK,xK,SK,CK=o((()=>{Et(),JW(),yK=Object.freeze({image:`image.generate`,video:`video.generate`,speech:`audio.speech`,music:`audio.music`,sfx:`audio.sfx`}),bK=Object.freeze({aspectRatio:`Shape`,resolution:`Size`,quality:`Quality`,duration:`Length (seconds)`,generateAudio:`Sound`}),xK=e=>Array.isArray(e)?e.filter(e=>typeof e?.id==`string`&&/^[a-z][a-z0-9_-]{0,63}$/.test(e.id)&&typeof e.label==`string`).map(e=>({id:e.id,label:e.label.slice(0,120)})):[],SK=e=>Number.isSafeInteger(e)&&e>=0?e:null}));function wK(e=EK){Date.now()-OK<1500||(OK=Date.now(),window.dispatchEvent(new CustomEvent(TK,{detail:{reason:e}})))}var TK,EK,DK,OK,kK,AK,jK=o((()=>{Xt(),TK=`stillmade:sign-up-required`,EK=`This uses credits. Sign up to continue; your project stays saved on this browser.`,DK=()=>!Jt(),OK=0,kK=/\/(?:quotes?|lookup|step-updates|models|prices?|estimates?|options)$/,AK=`Sign up to make this. Everything you set up stays here for when you are in.`})),MK=o((()=>{Et(),Object.freeze({bytes:8192,depth:8,properties:64,enum:64,stringLength:4e3})})),NK,PK=o((()=>{NK=Object.freeze({MIT:`MIT License
1984
1984
 
1985
1985
  Copyright (c) <year> <copyright holders>
1986
1986
 
@@ -2099,7 +2099,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
2099
2099
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2100
2100
  See the License for the specific language governing permissions and
2101
2101
  limitations under the License.
2102
- `})})),MK=o((()=>{jK(),Object.freeze({notice:AK.MIT.replace(`<year> <copyright holders>`,`2026 StillMade SDK contributors`)})})),NK,PK=o((()=>{NK=[`to`,`recipient`,`recipients`,`recipient_email`,`subject`,`body`,`message_body`,`text_body`,`html_body`,`thread_id`,`threadId`],[...NK]})),FK=o((()=>{PK()})),IK=o((()=>{Et(),MK(),FK(),Object.freeze(`email.firstname.first_name.lastname.last_name.name.full_name.phone.mobilephone.phone_number.company.website.jobtitle.job_title.city.state.zip.country.address.lifecyclestage.hs_lead_status.message.notes.description.subject.body.to.recipient_email.title.status.amount.tags`.split(`.`))})),LK=o((()=>{Et(),kK(),IK(),GW(),Object.freeze({prompt:32e3,contextBytes:24e3,system:8e3,output:32768,maxTokens:4096,fixtures:3,includes:8,includeLength:256,packageBytes:262144,metadataBytes:8192}),Object.freeze({system:32e3,prompt:64e3,maxTokens:24e3,output:131072}),Object.freeze({text:3800,duration:1400,bytes:67108864,sampleRate:24e3,channels:1}),Object.freeze({images:4,question:2e3,range:12}),Object.freeze({images:10,question:8e3,instructions:8e3,maxTokens:4e3}),Object.freeze([`check`]),Object.freeze({turns:20,turn:8e3,total:24e3}),Object.freeze({url:2048,instruction:4e3,topic:500,sources:12,answer:32768}),Object.freeze({images:4}),Object.freeze({bytes:134217728,duration:1800,music:Object.freeze({min:5,max:240,default:30}),sfx:Object.freeze({min:.5,max:22,default:4})}),Object.freeze({prompt:32e3,bytes:268435456,duration:60,width:3840,height:3840,pixels:8294400}),Object.freeze({prompt:32e3,bytes:12e6,width:1024,height:1024,maxSide:8192,maxPixels:4e7,maxBytes:67108864}),Object.freeze({bytes:16777216,nodes:408192})})),RK=o((()=>{Et(),LK()})),zK=o((()=>{Et(),LK()}));function BK({signal:e,service:t=`capability`}={}){let n=t===`connections`?`/api/connections`:`/api/block-capabilities`,r=ir(),i=UK(r),a=new AbortController,o=!1,s=()=>!o&&!!i&&UK(ir())===i,c=()=>{s()||a.abort()},l=()=>a.abort();e?.addEventListener(`abort`,l,{once:!0});let u=setInterval(c,250);return globalThis.window?.addEventListener(`storage`,c),globalThis.window?.addEventListener(`focus`,c),(e?.aborted||!i)&&a.abort(),{signal:a.signal,assertCurrent(){if(c(),a.signal.aborted)throw i?VK():HK()},async request(e,{body:t,method:r=t===void 0?`GET`:`POST`,settleAfterCancel:o=!1,operation:s,claimedResult:c=!1}={}){!i&&r!==`GET`&&!EK.test(e)&&wK()&&xK(DK),this.assertCurrent();let l=new AbortController,u=()=>l.abort(),d=setTimeout(u,[`audio.transcribe`,`audio.music`,`audio.sfx`,`web.research`,`media.analyze`,`image.generate`,`video.generate`].includes(s)&&r===`POST`&&(/^\/(reviews|runs)$/.test(e)||/^\/runs\/[^/]+\/poll$/.test(e))?s===`video.generate`?305e3:165e3:65e3);o||a.signal.addEventListener(`abort`,u,{once:!0});try{B(!c||e===`/claimed-results/verify`,`SEGMENT_RECEIPT`,`Choose the claimed result verification endpoint`);let i=await fetch((c?`/api/public-tools`:n)+e,{method:r,headers:ir(),credentials:`same-origin`,cache:`no-store`,...t===void 0?{}:{body:JSON.stringify(t)},signal:l.signal}),a=await i.json().catch(()=>({}));if(o||this.assertCurrent(),!i.ok)throw Object.assign(Error(a.error||(i.status===401?`Sign in to use your StillMade capabilities.`:`Generation is unavailable. Check your account and server setup.`)),{code:a.code,status:i.status});return r===`POST`&&(e===`/runs`||/^\/runs\//.test(e)&&[`completed`,`failed`,`cancelled`].includes(a.state))&&globalThis.window?.dispatchEvent(new Event(`aivw-credits-refresh`)),a}finally{clearTimeout(d),a.signal.removeEventListener(`abort`,u)}},async cancel(e){let t=new AbortController,i=setTimeout(()=>t.abort(),65e3);try{await fetch(n+e,{method:`POST`,headers:r,credentials:`same-origin`,cache:`no-store`,body:`{}`,signal:t.signal}),globalThis.window?.dispatchEvent(new Event(`aivw-credits-refresh`))}finally{clearTimeout(i)}},dispose(){o||(o=!0,a.abort(),clearInterval(u),e?.removeEventListener(`abort`,l),globalThis.window?.removeEventListener(`storage`,c),globalThis.window?.removeEventListener(`focus`,c))}}}var VK,HK,UK,WK=o((()=>{RK(),OK(),Et(),zK(),LK(),GW(),kK(),VK=()=>Object.assign(new DOMException(`Preview cancelled. Reopen it to confirm the current account and model.`,`AbortError`),{codeName:`CAPABILITY_CANCELLED`}),HK=()=>Object.assign(new DOMException(`Sign in to preview this.`,`AbortError`),{codeName:`CAPABILITY_SIGNED_OUT`}),UK=e=>{let t=e.Authorization||``;if(!t)return null;try{let e=JSON.parse(atob(t.slice(7).split(`.`)[1].replaceAll(`-`,`+`).replaceAll(`_`,`/`)));if(typeof e.sub==`string`&&e.sub)return e.sub}catch{}return t}})),GK,KK=o((()=>{NG(),Object.fromEntries(jG.map(e=>[e.value,e.label])),GK=[{slug:`standard`,label:`Standard`,blurb:`Fast everyday — free on a plan`,model:`google/gemini-2.5-flash`},{slug:`balanced`,label:`Balanced`,blurb:`Stronger & quick`,model:`anthropic/claude-sonnet-4.5`},{slug:`reasoning`,label:`Reasoning`,blurb:`Deepest, most careful`,model:`google/gemini-2.5-pro`},{slug:`premium`,label:`Premium`,blurb:`Best writing`,model:`anthropic/claude-opus-4.8`}],Object.fromEntries(GK.map(e=>[e.slug,e]))})),qK,JK,YK,XK,ZK,QK,$K=o((()=>{KK(),AG(),{wholeCredits:qK,exactCredits:JK,FLAT:YK}=KW,XK=e=>qK(YK[e].usd,YK[e].tier),ZK=e=>qK(e,`other`),QK=Object.freeze({LLM_CHAT_MESSAGE:ZK(.01),LLM_BIBLE_GENERATION:ZK(.05),LLM_CANVAS_GENERATION:ZK(.03),LLM_VOICEOVER_SHOT_ANALYSIS:ZK(.01),LLM_MOOD_MAP_GENERATION:ZK(.01),LLM_MUSIC_PROMPT_GENERATION:ZK(.01),LLM_AUTO_EDIT_ANALYSIS:ZK(.01),LLM_GENERIC:ZK(.01),"project:assistant":Math.ceil(JK(SG,`chat`)-1e-9),"chat:web-search":JK(CG,`chat`),"narrative:compile":XK(`narrative:compile`),"narrative:compile-research":XK(`narrative:compile-research`),"narrative:learn-voice":XK(`narrative:learn-voice`),VISION_EXTERNAL_VIDEO_ANALYSIS:ZK(.02),VISION_AUTO_ANALYZE_PER_IMAGE:XK(`vision`),...Object.fromEntries(Object.keys(cG).map(e=>[`IMAGE_${e}`,qK(YW({model:e}),`media`)])),...Object.fromEntries(Object.keys(oG).map(e=>[`VIDEO_${e}`,JK(XW({model:e,seconds:1}),`video`)])),VOICEOVER_PER_MINUTE:qK(ZW({seconds:60}),`media`),"transcribe:timestamp":XK(`transcribe:timestamp`),"transcribe:upload":XK(`transcribe:upload`),"transcribe:captions":XK(`transcribe:captions`),MUSIC_PER_MINUTE:qK(OG(60),`media`),SFX_PER_GENERATION:qK(kG(4),`media`),ROUGHCUT_BASE:XK(`roughcut:base`),ROUGHCUT_PER_MINUTE:XK(`roughcut:per-min`),FINALEDIT_BASE:XK(`finaledit:base`),FINALEDIT_PER_MINUTE:XK(`finaledit:per-min`),AOMOTION_BASE:XK(`aomotion:base`),AOMOTION_PER_MINUTE:XK(`aomotion:per-min`),AOMOTION_BASE_OPUS:XK(`aomotion:base:opus`),AOMOTION_PER_MINUTE_OPUS:XK(`aomotion:per-min:opus`),MOTIONGRAPHIC:XK(`motiongraphic`),"transcript:parse":XK(`transcript:parse`),VIBE_EDIT:XK(`vibe-edit`),RESEARCH_SEARCH:XK(`research:search`),RESEARCH_SUMMARIZE:XK(`research:summarize`),MEDIA_ANALYZE:XK(`media:analyze`),MEDIA_CHECK:XK(`media:check`),CONNECTION_ACTION:XK(`connection:action`),"automation:app-events":1,"automation:app-checks":1,CONTEXT_CONNECT:XK(`canvas:context-connect`),"anim2:plan":XK(`anim2:plan`),"anim2:vibe":XK(`anim2:vibe`),"anim2:qa":XK(`anim2:qa`),"anim2:trigger":XK(`anim2:trigger`),"gif:plan":XK(`gif:plan`),"canvas:plan":XK(`canvas:plan`),"canvasChat:build":XK(`canvasChat:build`),"strip:plan":XK(`strip:plan`),"panel:qa":XK(`panel:qa`),IMAGE_MOTION_EFFECT:0}),QK.RESEARCH_SEARCH+QK.RESEARCH_SUMMARIZE,QK.RESEARCH_SUMMARIZE,QK.CONTEXT_CONNECT,QK[`project:assistant`],QK[`chat:web-search`],Object.freeze(Object.fromEntries(Object.entries(xG).map(([e,t])=>[e,qK(t,`build`)]))),JK(5e-4,`other`),Object.freeze({providerUsd:`0.000300`,readCredits:1,writeCredits:2}),Math.floor(QW/(YK[`automation:app-event`].usd*$W.other)),Math.floor(QW/(YK[`automation:app-check`].usd*$W.other))})),eq=o((()=>{$K()}));function tq(e){let t=iq.get(e);if(!t){let n=BK();t=n.request(rq(e)).finally(()=>n.dispose()),t.catch(()=>{iq.get(e)===t&&iq.delete(e)}),iq.set(e,t)}return t}var nq,rq,iq,aq=o((()=>{WK(),RG(),dK(),eq(),nq=new Set([`image.generate`,`video.generate`,`audio.speech`,`audio.transcribe`,`audio.music`,`audio.sfx`,`web.fetch`,`web.research`,`media.analyze`]),rq=e=>nq.has(e)?`/options?operation=${e}`:`/options`,iq=new Map})),oq=c({blockModelList:()=>sq});async function sq(e,t,n){if(typeof t!=`string`||!fK(e).includes(t))throw Error(`This Block does not declare ${typeof t==`string`?t.slice(0,60):`that operation`}. Declare it in permissions.capabilities, or the media.generate action for image, video, speech, music and sound effects, to list its models.`);if(typeof n==`function`)return n(t);let r;try{r=await tq(t)}catch(e){if(wK())return hK(t);throw e}return mK(t,FG(t,r,{firstFrame:!0}))}var cq=o((()=>{bK(),OK(),aq(),RG()}));k(),ar(),UH(),Et(),Ei();var lq=`stillmade.block.view.v1`,uq=5e3,dq=()=>globalThis.crypto.randomUUID(),fq=`*{box-sizing:border-box}html{container:stillmade-view/inline-size;overflow-wrap:anywhere}body{min-width:0;margin:0;padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));overflow-x:hidden;background:var(--bg);color:var(--fg);font:16px/1.5 var(--font-body)}h1,h2{font:200 italic clamp(26px,8cqi,32px)/1.1 var(--font-display);letter-spacing:var(--tr-display)}button,input,textarea,select,summary{font:inherit;color:inherit;max-width:100%}button:where(:not(.sm-add,.sm-tile-tools>*)),input,textarea,select{min-height:44px;border:1px solid var(--border-tok);border-radius:var(--r-3);padding:10px 14px;background:transparent}:where(details:not(.sm-hint))>summary{display:flex;align-items:center;min-height:44px;cursor:pointer}.sm-hint>summary{max-width:none}button:where(:not(.sm-add,.sm-tile-tools>*)){min-width:44px;cursor:pointer;border-radius:var(--r-pill);background:var(--fg);color:var(--bg)}button:disabled{opacity:.5;cursor:default}textarea{display:block;width:100%;min-height:120px}input[type=checkbox],input[type=radio]{width:20px;height:20px;min-height:0;padding:0;margin:0 8px 0 0;vertical-align:middle;accent-color:var(--fg)}input[type=range]{width:100%;min-height:32px;padding:0;border:0;accent-color:var(--fg)}img,video,canvas{max-width:100%}:focus-visible{outline:2px solid var(--signal);outline-offset:3px}@container stillmade-view (max-width:360px){body{padding:12px}button,input,textarea,select{font-size:16px}}`,pq=`*{box-sizing:border-box}html{overflow-wrap:anywhere}body{min-width:0;margin:0;padding:16px;overflow-x:hidden;background:var(--bg);color:var(--fg);font:16px/1.5 var(--font-body)}body:has(> [data-stillmade-layout="own"]){padding:0}`,mq=`:where(html[data-stillmade-center="1"])>:where(body)>:where(:not([data-stillmade-host])),:where(html[data-stillmade-center="2"])>:where(body)>:where(:not([data-stillmade-host]))>:where(*){margin-inline:auto}`,hq=`html[data-stillmade-pick],html[data-stillmade-pick] *{cursor:crosshair!important}html[data-stillmade-pick] [data-stillmade-media]{display:none!important}`,gq=Object.freeze({image:`image/png,image/jpeg,image/webp,image/gif`,video:`video/*`,audio:`audio/*,video/*`,asset:`image/png,image/jpeg,image/webp,image/gif,audio/*,video/*`,file:Object.entries($U).filter(([,e])=>e.kind===`file`).map(([e])=>`.${e}`).join(`,`)}),_q=e=>e.filter(e=>typeof e==`string`&&/^[A-Za-z][A-Za-z0-9_-]{0,99}$/.test(e)),vq=`html[data-stillmade-price]:not([data-stillmade-running]) button[data-stillmade-action="run"]::after{content:" · " var(--stillmade-price)!important;white-space:nowrap}html[data-stillmade-price] button[data-stillmade-action="run"]:is(.sm-primary,.sm-quiet){flex-wrap:wrap;row-gap:0}html[data-stillmade-price] button[data-stillmade-action="run"]:is(.sm-primary,.sm-quiet)::after{margin-inline-start:calc(.28em - var(--s-2,8px))}`,yq=e=>`html[data-stillmade-readonly] [data-stillmade-add]${_q(e).map(e=>`,[data-stillmade-add="${e}"]`).join(``)}{display:none!important}html[data-stillmade-readonly] [data-stillmade-remove],html[data-stillmade-readonly] [data-stillmade-move]${_q(e).map(e=>`,[data-stillmade-remove="${e}"],[data-stillmade-move="${e}"]`).join(``)}{display:none!important}html[data-stillmade-readonly] [data-stillmade-action="run"]{display:none!important}`;function bq(e,t){let n=typeof t==`string`&&vt(e?.inputs)&&Object.hasOwn(e.inputs,t)?e.inputs[t]:null;if(!vt(n))throw Error(`${JSON.stringify(String(t))} is not an input of this Block.`);let r=String(n.type||``),i=r.replace(/\[\]$/,``);if(!Object.hasOwn(gq,i))throw Error(`${JSON.stringify(t)} is a ${r} input. Only image, video, audio, asset and file inputs take added files.`);return{name:t,port:n,type:i,multiple:r.endsWith(`[]`),accept:gq[i]}}function xq(e,t){let n=Array.isArray(e)?e:[],r=e=>Number.isInteger(e)&&e>=0&&e<n.length;if(t?.op===`remove`&&r(t.index))return n.filter((e,n)=>n!==t.index);if(t?.op===`move`&&r(t.from)&&r(t.to)){let e=[...n],[r]=e.splice(t.from,1);return e.splice(t.to,0,r),e}throw Error(n.length?`Choose a file from 0 to ${n.length-1}.`:`This input has no files.`)}function Sq({accept:e,multiple:t},n=globalThis.document){let r,i=new Promise(i=>{let a=n.createElement(`input`);a.type=`file`,a.accept=e,a.multiple=!!t,a.hidden=!0;let o=!1;r=e=>{o||(o=!0,a.remove(),i(e))},a.addEventListener(`change`,()=>r(Array.from(a.files||[])),{once:!0}),a.addEventListener(`cancel`,()=>r([]),{once:!0}),n.body.append(a),a.click()});return i.cancel=()=>r([]),i}var Cq=e=>JSON.stringify(e).replace(/</g,`\\u003c`).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`);function wq(e){if(mt(e),new TextEncoder().encode(JSON.stringify(e)).length>OH.messageBytes)throw Error(`Preview data exceeds 4 MiB`);return structuredClone(e)}var Tq=e=>vt(e)&&[`image`,`video`,`audio`].includes(e.kind)&&[`assetId`,`versionId`,`url`].every(t=>typeof e[t]==`string`&&e[t])?ht([e.kind,e.assetId,e.versionId,e.url]):``;function Eq(e){let t=(0,v.useRef)({has:!1,original:null,signature:null,value:null});if(t.current.has&&Object.is(t.current.original,e))return t.current.value;let n=e===void 0?`undefined`:ht(e);return t.current.signature===n?t.current.original=e:t.current={has:!0,original:e,signature:n,value:e},t.current.value}function Dq(e,t=[]){return Array.isArray(e)?(e.forEach(e=>Dq(e,t)),t):vt(e)?Tq(e)?(t.push(e),t):(Object.values(e).forEach(e=>Dq(e,t)),t):t}var Oq=e=>Array.isArray(e)?e.length>0&&e.every(Oq):!!Tq(e);function kq(e,t,n){if(!vt(e)||!Object.values(e).length||!Object.values(e).every(Oq))throw Error(`Only complete saved media references can be chosen as outputs.`);let r=new Set(Dq(t).map(Tq));for(let t of Dq(e))if(!r.has(Tq(t))&&!n?.authorizesMedia(t))throw Error(`Choose media supplied by this workspace or recorded in this session.`);return wq(e)}function Aq(e){let t=wq(e);if(!vt(t)||!_t(t,`image`))throw Error(`Choose a valid image supplied by this workspace.`);if(t.role!==void 0&&(typeof t.role!=`string`||!/^[a-z][a-z0-9_]{0,79}$/.test(t.role)))throw Error(`This image has an invalid semantic role.`);if(!Array.isArray(t.data)&&!([`assetId`,`versionId`,`url`].every(e=>typeof t[e]==`string`&&t[e].length>0)&&t.assetId.length<=512&&t.versionId.length<=512&&t.url.length<=32768))throw Error(`Keep the complete image reference supplied by this workspace.`);return t}function jq(e,t=OH.imagePreviewEdge){let n=()=>Error(`The host returned an invalid image preview.`),r=wq(e),i=vt(r)&&Object.keys(r).length===3&&[`url`,`width`,`height`].every(e=>Object.hasOwn(r,e))&&[`width`,`height`].every(e=>Number.isInteger(r[e])&&r[e]>0&&r[e]<=t),a=typeof r?.url==`string`&&/^data:image\/(png|jpeg);base64,[A-Za-z0-9+/]+={0,2}$/.exec(r.url)?.[1];if(!i||!a)throw n();let o=r.url.slice(a===`png`?22:23);if(o.length%4!=0)throw n();if(a===`png`){let e=atob(o.slice(0,44)),t=t=>e.charCodeAt(t),i=e=>t(e)*16777216+t(e+1)*65536+t(e+2)*256+t(e+3);if(e.length<33||![137,80,78,71,13,10,26,10].every((e,n)=>t(n)===e)||i(8)!==13||e.slice(12,16)!==`IHDR`||i(16)!==r.width||i(20)!==r.height)throw n();return r}let s=atob(o.slice(0,4096)),c=e=>s.charCodeAt(e),l=e=>c(e)*256+c(e+1);if(c(0)!==255||c(1)!==216)throw n();for(let e=2;e+9<s.length;){if(c(e)!==255)throw n();let t=c(e+1),i=l(e+2);if(t>=192&&t<=207&&![196,200,204].includes(t)){if(l(e+5)!==r.height||l(e+7)!==r.width)throw n();return r}if(i<2)throw n();e+=2+i}throw n()}var Mq=()=>`__sm_guard_${globalThis.crypto.randomUUID().replaceAll(`-`,``)}`;function Nq(e,t,n=`light`,r=`package`,i=!1,a=[],o=null,s=!1,c=!1,{assets:l={},filming:u=null,inputTypes:d=null,frameGuard:f=null}={}){SH(e);let p=VH(e),m=r===`package`?e.appearance??`host`:r;m!==`original`&&!p&&ZH(e,{appearance:`host`});let h=(m===`original`?e.css??``:e.themedCss??e.css??``)+`
2103
- `+(p?``:$H),g=globalThis.crypto.randomUUID().replaceAll(`-`,``),_=`__sm_view_${g}`,v=f||Mq(),y=`__sm_media_${globalThis.crypto.randomUUID().replaceAll(`-`,``)}`,b=`(()=>{"use strict";${p?`const codeNonce=document.currentScript.nonce;`:``}document.currentScript.remove();const session=${Cq(t)},channel=${Cq(lq)},send=parent.postMessage.bind(parent);let input={},ready=false,inputRevision=0,editRevision=0,sequence=0,pending=null,pendingAdopt=null,adoptSequence=0,pendingImage=null,imageSequence=0,pendingDesktop=null,desktopSequence=0,pendingAdd=null,addSequence=0,pendingChange=null,changeSequence=0,voiceSequence=0,pendingAllow=null,allowSequence=0,pendingDownload=null,downloadSequence=0;const pendingVoice=new Map(),voiceURLs=new Map(),pendingModels=new Map(),issued=new Map();let modelSequence=0;const addTypes=${Cq(vt(d)?d:null)},addLocked=new Set(${Cq(a.filter(e=>typeof e==`string`))});const addPortProblem=port=>{if(typeof port!=="string"||!port)return "Name the input to add files to, as in StillMade.addFiles('listingPhotos').";if(!addTypes)return "";if(!Object.hasOwn(addTypes,port))return JSON.stringify(port)+" is not an input of this Block. Name a declared image, video, audio, asset or file input.";if(!/^(image|video|audio|asset|file)(\\[\\])?$/.test(addTypes[port]))return JSON.stringify(port)+" is a "+addTypes[port]+" input. Only image, video, audio, asset and file inputs take added files.";return ""};const filesPortProblem=(port,call)=>{if(typeof port!=="string"||!port)return "Name the list input, as in StillMade."+call+"('listingPhotos', 0).";const problem=addPortProblem(port);if(problem)return problem;if(addTypes&&!addTypes[port].endsWith("[]"))return JSON.stringify(port)+" holds one file. StillMade."+call+" changes a list input; StillMade.addFiles replaces a single file.";return ""};const idle=()=>Promise.resolve().then(()=>{if(!pending)document.documentElement?.removeAttribute("data-stillmade-running")});const mediaURLs=new Set();const mintedImages=new Set();Object.defineProperty(globalThis,${Cq(y)},{configurable:true,value:url=>mintedImages.has(url)});const clearMedia=()=>{for(const url of mediaURLs){URL.revokeObjectURL(url);issued.delete(url)}mediaURLs.clear()};const issue=(url,value)=>{if(typeof url!=="string"||!value)return;issued.delete(url);issued.set(url,value);if(issued.size>96)issued.delete(issued.keys().next().value)};const listeners=new Set();let calls=0,started=0;const now=performance.now.bind(performance),resetTask=setTimeout.bind(globalThis);let gestureId=0,gestureAt=-Infinity;for(const type of ["pointerdown","keydown"])addEventListener(type,event=>{if(event.isTrusted){gestureId++;gestureAt=now();}},true);${p?`for(const meta of document.querySelectorAll("meta[http-equiv]"))meta.remove();const frameRuntime=(${WH.toString()})(channel,session,send,${Cq({guardName:v,taskMs:FH.taskMs,assets:l})});const codeAPI=(${GH.toString()})(channel,session,send,codeNonce);`:`const codeAPI=null;Object.defineProperty(globalThis,${Cq(_)},{configurable:true,value:()=>{if(calls===0){started=now();resetTask(()=>{calls=0},0)}if(++calls>10000||now()-started>50)throw Error("Interface is doing too much work. Move processing into the Block runtime.")}});addEventListener("message",event=>{if(event.isTrusted&&event.source===parent)calls=0},true);`}let controlEffects=0;let assisted=false,trackedCalls=new Set(),trackedFailure=null,controlOffset=0;const track=promise=>{if(assisted){trackedCalls.add(promise);promise.then(()=>trackedCalls.delete(promise),error=>{trackedFailure=error;trackedCalls.delete(promise)})}return promise};const controlSnapshot=(offset=controlOffset,automatic=true)=>{try{let snapshot;try{snapshot=dynamicUI.inspectControls({offset})}catch(error){if(!automatic||error.message!=="Choose a current control page"||!Number.isSafeInteger(offset)||offset<0)throw error;snapshot=dynamicUI.inspectControls({offset:0});}controlOffset=snapshot.offset;send({channel,session,op:"view-controls",snapshot},"*")}catch(error){send({channel,session,op:"view-controls-error",error:String(error.message).slice(0,1000)},"*")}};const dynamicUI=(${pr.toString()})(document,error=>send({channel,session,op:"interface-error",error},"*"),()=>Promise.resolve().then(controlSnapshot),{frame:${p?`true`:`false`}});const sharedLifecycle={};const sharedAPI=(${fr.toString()})(channel,session,${Cq(ur)},sharedLifecycle);const textControls=${i?`(()=>{${tr};return StillMadeTextFrame.installTextFrame(document,sharedAPI,error=>send({channel,session,op:"interface-error",error},"*"),channel,session,{token:${Cq(o)},send});})()`:`null`};const sharedControls=(${er.toString()})(document,sharedAPI,error=>send({channel,session,op:"interface-error",error},"*"),textControls,${Cq(a)});const {documentTools,sharedDocuments}=(${nr})(sharedAPI,status=>send({channel,session,op:"document-store-status",status},"*"));const previews=(${jt.toString()})((kind,value,options)=>{if(kind==="media"){if(mediaURLs.size>=${p?FH.mediaPreviews:2})throw Error("Release a previous media preview before opening another");if(!["image","video","audio"].includes(value.kind))throw Error("Choose a picture, audio or video reference");}return new Promise((resolve,reject)=>{const id=String(++imageSequence);pendingImage={id,resolve,reject,media:kind==="media",value};send({channel,session,op:kind==="media"?"preview-media":"preview-image",id,value,...(options?.edge?{edge:options.edge}:{})},"*")})});const connectionAPI=(${kt.toString()})(${Cq(lq)},${Cq(t)},${c},send),workAPI=(${D.toString()})(${Cq(lq)},${Cq(t)},${s},send);const liveBridge=(${At.toString()})(${Cq(lq)},${Cq(t)},send,(operation,args)=>api.desktop(operation,args));const editFiles=(call,port,edit)=>{if(!ready)return Promise.reject(Error("Preview is loading"));const problem=filesPortProblem(port,call);if(problem)return Promise.reject(Object.assign(Error(problem),{code:"FILES_PORT"}));const files=Array.isArray(input[port])?input[port]:[],places=edit.op==="move"?[edit.from,edit.to]:[edit.index];if(!places.every(place=>Number.isInteger(place)&&place>=0&&place<files.length))return Promise.reject(Object.assign(Error(files.length?"Choose a file from 0 to "+(files.length-1)+" in StillMade."+call+".":JSON.stringify(port)+" has no files yet."),{code:"FILES_INDEX"}));if(addLocked.has(port))return Promise.reject(Error("This input comes from an earlier Step, so its files cannot be changed here."));if(assisted)return Promise.reject(Error("Only a person changes files. Chat cannot remove or move them."));if(!sharedAPI.getShared().canEdit)return Promise.reject(Error("You can view this project but not change its files."));if(!gestureId||now()-gestureAt>5000||navigator.userActivation&&!navigator.userActivation.isActive)return Promise.reject(Error("Remove or move files from a click or key press in this screen."));if(pendingChange)return Promise.reject(Error("Files are already being changed."));if(edit.op==="move"&&edit.from===edit.to)return Promise.resolve({files:files.length});return new Promise((resolve,reject)=>{const id=String(++changeSequence);pendingChange={id,resolve,reject};send({channel,session,op:"change-files",id,port,edit,item:files[edit.op==="move"?edit.from:edit.index],gesture:{id:gestureId,age:now()-gestureAt}},"*")})};const api=Object.freeze({...connectionAPI,...workAPI,live:liveBridge.live,${p?`asset:frameRuntime.asset,assetBytes:frameRuntime.assetBytes,loadCode:codeAPI.load,`:``}connectedApp(...args){controlEffects++;return track(connectionAPI.connectedApp(...args))},sharedWork(...args){controlEffects++;return track(workAPI.sharedWork(...args))},previewSharedWorkMedia(...args){controlEffects++;return track(workAPI.previewSharedWorkMedia(...args))},schemaFields:(${mr.toString()})(${JSON.stringify(a)}),...sharedAPI,...documentTools,updateShared(...args){sharedControls.ownSharing();return sharedAPI.updateShared(...args)},connectDocument(...args){sharedControls.ownSharing();return sharedDocuments.connectDocument(...args)},bindShared:sharedControls.bindShared,setSharedDefaults:sharedControls.setSharedDefaults,scheduleSharedEdit:sharedControls.scheduleSharedEdit,render:dynamicUI.render,onAction:dynamicUI.onAction,releaseMedia(url){if(mediaURLs.delete(url)){URL.revokeObjectURL(url);issued.delete(url)}},previewMedia(value){if(!ready)return Promise.reject(Error("Preview is loading"));return track(previews.request("media",value))},desktop(operation,args={}){controlEffects++;if(!ready)return Promise.reject(Error("Preview is loading"));if(pendingDesktop)return Promise.reject(Error("A desktop request is already pending"));if(typeof operation!=="string"||JSON.stringify(args).length>131072)return Promise.reject(Error("Invalid desktop request"));return track(new Promise((resolve,reject)=>{const id=String(++desktopSequence);pendingDesktop={id,resolve,reject};send({channel,session,op:"desktop",id,operation,args},"*")}))},get input(){return structuredClone(input)},onInput(fn){if(typeof fn!=="function")throw Error("Expected a function");listeners.add(fn);if(ready)fn(structuredClone(input));return()=>listeners.delete(fn)},useOutput(values){controlEffects++;if(!ready)return Promise.reject(Error("Preview is loading"));if(pendingAdopt)return Promise.reject(Error("An output choice is already pending"));let serialized;try{serialized=JSON.stringify(values);if(!values||Array.isArray(values)||typeof values!=="object"||serialized.length>4194304)throw Error("Expected bounded output values")}catch(error){return Promise.reject(error)}return track(new Promise((resolve,reject)=>{const id=String(++adoptSequence);pendingAdopt={id,resolve,reject};send({channel,session,op:"use-output",id,outputs:values},"*")}))},addFiles(port){if(!ready)return Promise.reject(Error("Preview is loading"));const problem=addPortProblem(port);if(problem)return Promise.reject(Object.assign(Error(problem),{code:"ADD_FILES_PORT"}));if(addLocked.has(port))return Promise.reject(Error("This input comes from an earlier Step, so files cannot be added to it here."));if(assisted)return Promise.reject(Error("Only a person adds files. Chat cannot open a file picker."));if(!sharedAPI.getShared().canEdit)return Promise.reject(Error("You can view this project but not add files to it."));if(!gestureId||now()-gestureAt>5000||navigator.userActivation&&!navigator.userActivation.isActive)return Promise.reject(Error("Add files from a click or key press in this screen."));if(pendingAdd)return Promise.reject(Error("Files are already being added."));return new Promise((resolve,reject)=>{const id=String(++addSequence);pendingAdd={id,resolve,reject};send({channel,session,op:"add-files",id,port,gesture:{id:gestureId,age:now()-gestureAt}},"*")})},removeFile(port,index){return editFiles("removeFile",port,{op:"remove",index})},moveFile(port,from,to){return editFiles("moveFile",port,{op:"move",from,to})},previewImage(value,options){if(!ready)return Promise.reject(Error("Preview is loading"));return track(previews.request("image",value,options))},allowSpending(request){if(!ready)return Promise.reject(Error("Preview is loading"));const credits=request?.credits,label=request?.label;if(!Number.isSafeInteger(credits)||credits<1||credits>${OH.allowanceCredits})return Promise.reject(Error("Name the total in whole credits, from 1 to ${OH.allowanceCredits}, as in StillMade.allowSpending({credits: 24, label: 'Build the panels'})."));if(typeof label!=="string"||!label.trim()||label.length>120)return Promise.reject(Error("Say what the credits are for, in up to 120 characters."));if(assisted)return Promise.reject(Error("Only a person approves spending. Chat cannot."));if(!gestureId||now()-gestureAt>5000||navigator.userActivation&&!navigator.userActivation.isActive)return Promise.reject(Error("Ask from a click or key press in this screen."));if(pendingAllow)return Promise.reject(Error("A spending approval is already open."));return new Promise((resolve,reject)=>{const id=String(++allowSequence);pendingAllow={id,resolve,reject};send({channel,session,op:"allow-spending",id,credits,label:label.trim(),gesture:{id:gestureId,age:now()-gestureAt}},"*")})},models(operation){if(!ready)return Promise.reject(Error("Preview is loading"));if(typeof operation!=="string"||!/^[a-z]+(\\.[a-z]+)+$/.test(operation))return Promise.reject(Error("Name an operation, as in StillMade.models('image.generate')."));if(pendingModels.size>=8)return Promise.reject(Error("Wait for the model lists already loading."));return new Promise((resolve,reject)=>{const id=String(++modelSequence);pendingModels.set(id,{resolve,reject});send({channel,session,op:"models",id,operation},"*")})},nextRun(plan){if(plan===null||plan===undefined){send({channel,session,op:"next-run",plan:null},"*");return}let text="";try{text=JSON.stringify(plan)}catch{}if(!text||typeof plan!=="object"||Array.isArray(plan)||text.length>262144||!Object.keys(plan).every(key=>key==="items"||key==="hosted")||plan.items!==undefined&&!Array.isArray(plan.items)||plan.hosted!==undefined&&!Array.isArray(plan.hosted))throw TypeError("Describe the next run as {items} (the media.generate items it asks for) and {hosted} (the hosted operations it calls), or null, as in StillMade.nextRun({items:[{operation:'image',settings:{aspectRatio:'1:1'}}]}).");send({channel,session,op:"next-run",plan:JSON.parse(text)},"*")},download(media){if(!ready)return Promise.reject(Error("Preview is loading"));if(!media||typeof media!=="object"||!["image","video","audio"].includes(media.kind)||!["assetId","versionId","url"].every(key=>typeof media[key]==="string"&&media[key]))return Promise.reject(Error("Pass a picture, clip or sound StillMade gave this screen, as in StillMade.download(StillMade.getShared().made[0])."));if(assisted)return Promise.reject(Error("Only a person downloads. Chat cannot."));if(!gestureId||now()-gestureAt>5000||navigator.userActivation&&!navigator.userActivation.isActive)return Promise.reject(Error("Download from a click or key press in this screen."));if(pendingDownload)return Promise.reject(Error("A download is already starting."));return new Promise((resolve,reject)=>{const id=String(++downloadSequence);pendingDownload={id,resolve,reject};send({channel,session,op:"download",id,value:{kind:media.kind,assetId:media.assetId,versionId:media.versionId,url:media.url},gesture:{id:gestureId,age:now()-gestureAt}},"*")})},previewVoice(voice){if(!ready)return Promise.reject(Error("Preview is loading"));if(typeof voice!=="string"||!/^[a-z0-9_-]{1,64}$/.test(voice))return Promise.reject(Error("Name a StillMade voice, as in StillMade.previewVoice('asteria')."));if(voiceURLs.has(voice))return Promise.resolve({url:voiceURLs.get(voice)});if(pendingVoice.size>=4)return Promise.reject(Error("Wait for the voice samples already loading."));return new Promise((resolve,reject)=>{const id=String(++voiceSequence);pendingVoice.set(id,{voice,resolve,reject});send({channel,session,op:"preview-voice",id,voice},"*")})},run(values){controlEffects++;if(!ready)return Promise.reject(Error("Preview is loading"));if(pending)return Promise.reject(Error("A run is already in progress"));try{dynamicUI.assertCommitted();sharedControls.assertNoComposition();}catch(error){return Promise.reject(error);}let serialized;try{serialized=JSON.stringify(values);if(!values||Array.isArray(values)||typeof values!=="object"||serialized.length>4194304)throw Error("Expected bounded input values")}catch(error){return Promise.reject(error)}return track(new Promise((resolve,reject)=>{const id=String(++sequence),requested=JSON.parse(serialized),sourceRevision=inputRevision,localRevision=editRevision,call={id,resolve:value=>{idle();resolve(value)},reject:error=>{idle();reject(error)},sent:false};pending=call;document.documentElement?.setAttribute("data-stillmade-running","");Promise.resolve().then(()=>dynamicUI.flushAll()).then(()=>sharedControls.flushAll()).then(()=>sharedDocuments.flushAll()).then(()=>sharedLifecycle.flushSharedWrites()).then(()=>{dynamicUI.assertCommitted();sharedControls.assertNoComposition();if(pending!==call||!ready)throw Error("Preview was closed before its edits were saved.");if(inputRevision!==sourceRevision||editRevision!==localRevision)throw Error("The input changed while edits were saving. Review it before running again.");const savedText=textControls?.getValues?.()||{};for(const [key,value] of Object.entries(savedText)){const captured=typeof requested[key]==="string"?requested[key]:typeof requested[key]?.text==="string"?requested[key].text:null;if(captured!==null&&captured!==value)throw Error("The input changed while shared text was saving. Review it before running again.");}if(!sharedAPI.getShared().canEdit)throw Error("Shared editing is unavailable or read only.");call.sent=true;send({channel,session,op:"run",id,input:requested,...(gestureId?{gesture:{id:gestureId,age:now()-gestureAt}}:{})},"*");}).catch(error=>{if(pending===call){pending=null;call.reject(error);}});}))}});Object.defineProperty(globalThis,"StillMade",{value:api,writable:false,configurable:false});sharedAPI.onShared(shared=>document.documentElement?.toggleAttribute("data-stillmade-readonly",!shared.canEdit));if(addTypes)for(const node of document.querySelectorAll("[data-stillmade-add],[data-stillmade-remove],[data-stillmade-move]")){const tool=node.hasAttribute("data-stillmade-add")?"":node.hasAttribute("data-stillmade-remove")?"removeFile":"moveFile",problem=tool?filesPortProblem(node.getAttribute(tool==="removeFile"?"data-stillmade-remove":"data-stillmade-move"),tool):addPortProblem(node.getAttribute("data-stillmade-add"));if(problem){send({channel,session,op:"interface-error",error:problem},"*");break;}}addEventListener("click",event=>{const node=event.isTrusted&&event.target&&typeof event.target.closest==="function"?event.target.closest("[data-stillmade-add]"):null;if(!node||node.disabled||node.getAttribute("aria-disabled")==="true")return;event.preventDefault();if(pendingAdd)return;node.setAttribute("aria-busy","true");api.addFiles(node.getAttribute("data-stillmade-add")).catch(error=>{if(error.code==="ADD_FILES_PORT")send({channel,session,op:"interface-error",error:String(error.message).slice(0,1000)},"*")}).finally(()=>node.removeAttribute("aria-busy"))});const shownMedia=node=>{const stage=node.closest(".sm-stage")||document.querySelector(".sm-stage")||document.body;let best=null,most=-1;for(const element of stage.querySelectorAll("img,video,audio")){const value=issued.get(element.currentSrc||element.getAttribute("src")||"");if(!value)continue;const rect=element.getBoundingClientRect(),size=rect.width*rect.height;if(!element.getClientRects().length||size<=most)continue;most=size;best=value}return best};addEventListener("click",event=>{const node=event.isTrusted&&!event.defaultPrevented&&event.target&&typeof event.target.closest==="function"?event.target.closest('[data-stillmade-action="download"]'):null;if(!node||node.disabled||node.getAttribute("aria-disabled")==="true"||pendingDownload)return;const media=shownMedia(node);if(!media)return;event.preventDefault();node.setAttribute("aria-busy","true");api.download(media).catch(()=>{}).finally(()=>node.removeAttribute("aria-busy"))});addEventListener("click",event=>{const node=event.isTrusted&&event.target&&typeof event.target.closest==="function"?event.target.closest("[data-stillmade-remove],[data-stillmade-move]"):null;if(!node||node.disabled||node.getAttribute("aria-disabled")==="true")return;event.preventDefault();if(pendingChange)return;const remove=node.hasAttribute("data-stillmade-remove"),place=name=>{const text=node.getAttribute(name);return text!==null&&/^[0-9]{1,6}$/.test(text)?Number(text):NaN},port=node.getAttribute(remove?"data-stillmade-remove":"data-stillmade-move");node.setAttribute("aria-busy","true");(remove?api.removeFile(port,place("data-index")):api.moveFile(port,place("data-index"),place("data-to"))).catch(error=>{if(error.code==="FILES_PORT")send({channel,session,op:"interface-error",error:String(error.message).slice(0,1000)},"*")}).finally(()=>node.removeAttribute("aria-busy"))});addEventListener("message",event=>{if(event.source!==parent||!event.data||event.data.channel!==channel||event.data.session!==session)return;const data=event.data;if(liveBridge.receive(data))return;if(data.op==="inspect-view-controls"){controlSnapshot(data.offset,false);return;}if(data.op==="locate-view-control"&&typeof data.id==="string"){let rect=null;try{rect=dynamicUI.locateControl(data.control)}catch{}send({channel,session,op:"view-control-rect",id:data.id,rect},"*");return;}if(data.op==="dispatch-named-text"&&typeof data.id==="string"){Promise.resolve().then(()=>textControls.dispatchNative(data.control,data.id)).then(()=>send({channel,session,op:"named-text-result",token:${Cq(o)},id:data.id},"*"),error=>send({channel,session,op:"named-text-result",token:${Cq(o)},id:data.id,error:String(error.message).slice(0,1000)},"*")).finally(()=>send({channel,session,op:"named-text-controls",token:${Cq(o)},snapshot:textControls.inspectNative()},"*"));return;}if(data.op==="inspect-named-text"){if(textControls)send({channel,session,op:"named-text-controls",token:${Cq(o)},snapshot:textControls.inspectNative()},"*");return;}if(data.op==="dispatch-view-control"&&typeof data.id==="string"){if(assisted){send({channel,session,op:"view-control-result",id:data.id,error:"A declared control is already running"},"*");return;}assisted=true;trackedFailure=null;const controlDocumentSeal=sharedDocuments.captureControlSettlement(),controlSharedSeal=sharedLifecycle.captureControlState(),controlInputRevision=inputRevision,controlEffectRevision=controlEffects;const personalControlUnchanged=()=>controlDocumentSeal&&inputRevision===controlInputRevision&&controlEffects===controlEffectRevision&&JSON.stringify(sharedLifecycle.captureControlState())===JSON.stringify(controlSharedSeal)&&!controlSharedSeal.closed&&controlSharedSeal.ready&&!controlSharedSeal.pending&&!controlSharedSeal.queued&&!controlSharedSeal.failed&&sharedDocuments.unchangedControlSettlement(controlDocumentSeal);dynamicUI.dispatchControl(data.control,async()=>{for(let round=0;round<16;round++){await Promise.allSettled(Array.from(trackedCalls));await dynamicUI.flushAll();await sharedControls.flushAll();if(personalControlUnchanged())await sharedDocuments.settleControl(controlDocumentSeal);else await sharedDocuments.flushAll();await sharedLifecycle.flushSharedWrites();await new Promise(resolve=>setTimeout(resolve,0));if(trackedFailure)throw trackedFailure;if(!trackedCalls.size){if(controlDocumentSeal&&!personalControlUnchanged())await sharedDocuments.flushAll();dynamicUI.assertCommitted();sharedControls.assertNoComposition();return;}}throw Error("Declared action did not settle");}).then(()=>send({channel,session,op:"view-control-result",id:data.id},"*"),error=>send({channel,session,op:"view-control-result",id:data.id,error:String(error?.message||"Declared action failed").slice(0,1000)},"*")).finally(()=>{assisted=false;controlSnapshot()});return;}if(data.op==="flush-shared"&&typeof data.id==="string"){Promise.resolve().then(()=>dynamicUI.flushAll()).then(()=>sharedControls.flushAll()).then(()=>sharedDocuments.flushAll()).then(()=>sharedLifecycle.flushSharedWrites()).then(()=>dynamicUI.flushAll()).then(()=>sharedControls.assertNoComposition()).then(()=>send({channel,session,op:"flush-shared-result",id:data.id},"*"),error=>send({channel,session,op:"flush-shared-result",id:data.id,error:String(error?.message||"Pending edits could not be confirmed").slice(0,1000)},"*"));return;}if(data.op==="desktop-result"&&pendingDesktop&&data.id===pendingDesktop.id){const call=pendingDesktop;pendingDesktop=null;data.error?call.reject(Error(data.error)):call.resolve(data.result)}else if(data.op==="add-files-result"&&pendingAdd&&data.id===pendingAdd.id){const call=pendingAdd;pendingAdd=null;data.error?call.reject(Error(data.error)):call.resolve({added:Number.isInteger(data.added)&&data.added>=0?data.added:0})}else if(data.op==="change-files-result"&&pendingChange&&data.id===pendingChange.id){const call=pendingChange;pendingChange=null;data.error?call.reject(Error(data.error)):call.resolve({files:Number.isInteger(data.files)&&data.files>=0?data.files:0})}else if(data.op==="use-output-result"&&pendingAdopt&&data.id===pendingAdopt.id){const call=pendingAdopt;pendingAdopt=null;data.error?call.reject(Error(data.error)):call.resolve(data.outputs)}else if(data.op==="input"){inputRevision+=1;if(pending&&!pending.sent){pending.reject(Error("Preview input changed before its edits were saved."));pending=null;}clearMedia();previews.reset();if(pendingImage)pendingImage.reject(Error("Preview input changed"));pendingImage=null;if(pendingAdopt)pendingAdopt.reject(Error("Preview input changed"));pendingAdopt=null;input=data.input;ready=true;try{sharedControls.useInputDefaults(input)}catch{}for(const fn of listeners)try{fn(structuredClone(input))}catch(error){send({channel,session,op:"interface-error",error:String(error?.message||"The Block interface could not display its input").slice(0,1000)},"*")}}else if(data.op==="result"&&pending?.sent&&data.id===pending.id){const call=pending;pending=null;data.error?call.reject(Error(data.error)):call.resolve(data.outputs)}else if(data.op==="preview-media-result"&&pendingImage?.media&&data.id===pendingImage.id){const call=pendingImage;pendingImage=null;if(data.error)call.reject(Error(data.error));else{try{const url=URL.createObjectURL(data.preview.blob);mediaURLs.add(url);issue(url,call.value);call.resolve({kind:data.preview.kind,url,mimeType:data.preview.blob.type,bytes:data.preview.blob.size,blob:data.preview.blob})}catch(error){call.reject(error)}}}else if(data.op==="code-result"&&codeAPI&&codeAPI.result(data)){}else if(data.op==="download-result"&&pendingDownload&&data.id===pendingDownload.id){const call=pendingDownload;pendingDownload=null;data.error?call.reject(Error(data.error)):call.resolve()}else if(data.op==="run-price"&&document.documentElement){const root=document.documentElement,words=typeof data.words==="string"&&/^(?:[0-9][0-9,.\u00a0\u202f ]{0,20} credits?|your key)$/.test(data.words)?data.words:null;if(words){root.style.setProperty("--stillmade-price",JSON.stringify(words));root.setAttribute("data-stillmade-price","")}else{root.removeAttribute("data-stillmade-price");root.style.removeProperty("--stillmade-price")}}else if(data.op==="allow-spending-result"&&pendingAllow&&data.id===pendingAllow.id){const call=pendingAllow;pendingAllow=null;data.error?call.reject(Error(data.error)):call.resolve({allowed:data.allowed===true,credits:Number.isSafeInteger(data.credits)?data.credits:0})}else if(data.op==="models-result"&&pendingModels.has(data.id)){const call=pendingModels.get(data.id);pendingModels.delete(data.id);data.error?call.reject(Error(data.error)):call.resolve(data.value)}else if(data.op==="preview-voice-result"&&pendingVoice.has(data.id)){const call=pendingVoice.get(data.id);pendingVoice.delete(data.id);if(data.error)call.reject(Error(data.error));else{try{const url=voiceURLs.get(call.voice)||URL.createObjectURL(data.blob);voiceURLs.set(call.voice,url);call.resolve({url})}catch(error){call.reject(error)}}}else if(data.op==="preview-image-result"&&pendingImage&&data.id===pendingImage.id){const call=pendingImage;pendingImage=null;if(data.error){call.reject(Error(data.error));}else{const url=data.preview?.url;if(typeof url==="string"){mintedImages.delete(url);mintedImages.add(url);if(mintedImages.size>64)mintedImages.delete(mintedImages.values().next().value);issue(url,call.value)}call.resolve(data.preview)}}else if(data.op==="dispose"){liveBridge.dispose();clearMedia();for(const url of voiceURLs.values())URL.revokeObjectURL(url);voiceURLs.clear();for(const call of pendingVoice.values())call.reject(Error("Block was closed"));pendingVoice.clear();previews.reset("Preview was reset");dynamicUI.dispose();sharedControls.dispose();textControls?.dispose();sharedDocuments.dispose();if(pendingDesktop)pendingDesktop.reject(Error("Block was closed"));pendingDesktop=null;if(pendingAllow)pendingAllow.reject(Error("Block was closed"));pendingAllow=null;if(pendingDownload)pendingDownload.reject(Error("Block was closed"));pendingDownload=null;if(pendingAdd)pendingAdd.reject(Error("Block was closed"));pendingAdd=null;if(pendingChange)pendingChange.reject(Error("Block was closed"));pendingChange=null;if(pendingAdopt)pendingAdopt.reject(Error("Preview was reset"));pendingAdopt=null;if(pendingImage)pendingImage.reject(Error("Preview was reset"));pendingImage=null;if(pending)pending.reject(Error("Preview was reset"));pending=null;listeners.clear();ready=false}});addEventListener("input",()=>{editRevision+=1;},true);addEventListener("change",()=>{editRevision+=1;},true);addEventListener("compositionstart",()=>{editRevision+=1;},true);addEventListener("keydown",event=>{if(event.key==="Escape"&&!document.documentElement.hasAttribute("data-stillmade-stage"))send({channel,session,op:"escape"},"*")},true);addEventListener("click",event=>{if(event.target.closest?.("a,area"))event.preventDefault()},true);send({channel,session,op:"ready"},"*");})();`,x=`for(const node of document.querySelectorAll("[data-stillmade-share]")){if(!node.id||document.getElementById(node.id)!==node)throw Error("Each shared control needs a unique ID");const bind=()=>StillMade.bindShared(node.getAttribute("data-stillmade-share"),node.id);if(node.tagName==="FIELDSET"&&!node.querySelector('input[type="radio"]')){const wait=new MutationObserver(()=>{if(!node.querySelector('input[type="radio"]'))return;wait.disconnect();try{bind()}catch{}});wait.observe(node,{childList:true,subtree:true});continue}bind()}`,S=p?`document.currentScript.remove();${x}\n${DH(e.javascript||``,v)}`.replace(/<\/script/gi,`<\\/script`):`document.currentScript.remove();((${_})=>{"use strict";delete globalThis[${Cq(_)}];${x}\n${CH(e.javascript||``,_)}\n})(globalThis[${Cq(_)}]);`.replace(/<\/script/gi,`<\\/script`);return`<!doctype html><html data-mode="${[`dark`,`white`].includes(n)?n:`light`}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-${g}'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:;${p?` font-src data: blob:;`:``} connect-src 'none'; frame-src 'none'; worker-src ${p?`blob:`:`'none'`}; object-src 'none'; base-uri 'none'; form-action 'none';"><meta name="referrer" content="no-referrer"><style>${QH.replace(/@font-face\s*\{[^}]*\}/g,``)}${p?pq:fq}${eU}${p?``:mq}${(h||``).replace(/<\/style/gi,`<\\/style`)}@media(pointer:coarse){input,textarea,select{font-size:16px!important}}${hq}${yq(a)}${vq}</style></head><body>${e.html}${u?`<script nonce="${g}">document.currentScript.remove();${u.replace(/<\/script/gi,`<\\/script`)}<\/script>`:``}<script nonce="${g}">${b.replace(/<\/script/gi,`<\\/script`)}<\/script><script nonce="${g}">document.currentScript.remove();${u?`(${VU.toString()})(${Cq(lq)},${Cq(t)},parent.postMessage.bind(parent));`:``}(${fU.toString()})(${Cq(lq)},${Cq(t)});(${pU.toString()})(${Cq(lq)},${Cq(t)});(${yU.toString()})(${Cq(lq)},${Cq(t)},(${_U.toString()}),"auto",(${vU.toString()}),${!p});(${bU.toString()})(${Cq(lq)},${Cq(t)},(${xU.toString().replace(/<\/script/gi,`<\\/script`)})(),${Cq(AU)},{minted:(()=>{const read=globalThis[${Cq(y)}];delete globalThis[${Cq(y)}];return typeof read==="function"?read:()=>false;})(),filming:${u?`true`:`false`}});(${rU.toString()})(${Cq(lq)},${Cq(t)},((validateCursorAnchor)=>(${nU.toString()}))(${tU.toString()}));(${iU.toString()})(${Cq(lq)},${Cq(t)},(${oU.toString()}));<\/script><script nonce="${g}">${S}<\/script></body></html>`}function Pq({activity:e,declaresFolders:t,session:n}){let[r,i]=(0,v.useState)(!1),a=e?.folders||[],o=e?.entries||[];if(!t&&!o.length)return null;let s=r=>{r.currentTarget.open&&t&&!e&&n.current?.call(`folder.shared`).catch(()=>{})},c=async e=>{i(!0);try{await n.current?.call(`folder.forget`,{folder:e.id})}catch{}finally{i(!1)}};return(0,V.jsxs)(`details`,{className:`bs-block-activity`,onToggle:s,children:[(0,V.jsx)(`summary`,{children:`What this Block did`}),a.length>0&&(0,V.jsx)(`ul`,{className:`bs-block-activity-folders`,children:a.map(e=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{children:`${e.write?`Reads and changes`:`Reads`} files in ${e.name}`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,disabled:r,onClick:()=>c(e),children:`Stop sharing`})]},e.id))}),o.length?(0,V.jsx)(`ul`,{children:o.map(e=>(0,V.jsxs)(`li`,{children:[e.text,e.count>1?` (${e.count} times)`:``]},`${e.at}:${e.text}`))}):(0,V.jsx)(`p`,{children:`Nothing yet.`})]})}function Fq({view:e,input:t={},sharedView:n=null,presenceKey:r=null,peers:i=[],actorId:a=null,onSharedChange:o,sharedText:s=null,sharedWork:c=null,connectedApp:l=null,onRun:u,onUseOutput:d,onAddFiles:f,onChangeFiles:p,onPreviewImage:m,onPreviewMedia:h,onPreviewVoice:g,onModels:_,onAllowSpending:y,onRunPrice:b,onRunPriced:S,onDownload:D,runPriceKey:O=null,onError:k,policyContent:A,policyParent:j,currentAppViewPolicy:M=null,title:N=`Block preview`,height:P=480,fitContent:F=!1,resetKey:I=0,theme:ee,appearance:te=`package`,lockedInputKeys:L=[],agentContext:R=null,screenRunRef:ne=null,onGoalSpending:re}){let ie=Eq(e),ae=Eq(A),oe=Eq(j),se=ae?.manifest?.runtime===`module`&&ae.manifest.permissions?.actions||[],ce=[`comfyui`,`capability`].includes(ae?.manifest?.runtime)||!!ae?.manifest?.desktopTools?.length||ae?.manifest?.runtime===`module`&&(!!ae?.manifest?.permissions?.capabilities?.length||se.length>0),le=ae?.capability?.operation===`image.generate`||se.includes(`media.generate`)?9e5:36e4,ue=(0,v.useRef)(null),de=(0,v.useRef)({onSharedChange:o,onRun:u,onUseOutput:d,onAddFiles:f,onChangeFiles:p,onPreviewImage:m,onPreviewMedia:h,onPreviewVoice:g,onModels:_,onAllowSpending:y,onRunPrice:b,onRunPriced:S,onDownload:D,onError:k}),fe=(0,v.useRef)(t),[pe,me]=(0,v.useState)(``),[he,ge]=(0,v.useState)(!1),[_e,ve]=(0,v.useState)(0),ye=(0,v.useRef)(null),be=(0,v.useRef)(null),[z,xe]=(0,v.useState)(null),[Se,Ce]=(0,v.useState)(null),[we,Te]=(0,v.useState)(null),Ee=ae?.manifest?.id||null,[De,Oe]=(0,v.useState)(`auto`),[ke,Ae]=(0,v.useState)(null),je=(0,v.useRef)(De);je.current=De;let Me=e=>{Oe(e),MU(Ee,e)},Ne=(0,v.useRef)(1);Ne.current=De===`auto`?ke?.zoom||1:De;let Pe=(0,v.useRef)(Me);Pe.current=Me;let Fe=(0,v.useContext)(IU),Ie=(0,v.useRef)(Fe);Ie.current=Fe;let[Le,Re]=(0,v.useState)(null),[ze,Be]=(0,v.useState)(null),[Ve,He]=(0,v.useState)(()=>globalThis.document?.documentElement?.dataset.mode||`light`),Ue=(0,v.useRef)(`light`);Ue.current=[`dark`,`white`].includes(ee||Ve)?ee||Ve:`light`;let We=(0,v.useRef)(l);We.current=l;let Ge=(0,v.useRef)(c);Ge.current=c;let Ke=(0,v.useRef)(s);Ke.current=s;let qe=(0,v.useRef)(!1),[Je,Ye]=(0,v.useState)(()=>({enabled:!!s,projectId:s?.projectId??null,placementId:s?.placementId??null})),Xe=()=>{let e={enabled:!!Ke.current,projectId:Ke.current?.projectId??null,placementId:Ke.current?.placementId??null};Ye(t=>t.enabled===e.enabled&&t.projectId===e.projectId&&t.placementId===e.placementId?t:e)};(0,v.useEffect)(()=>{qe.current||Xe()},[!!s,s?.projectId,s?.placementId]);let Ze=Je.enabled,Qe=Je.projectId,$e=Je.placementId,et=!!ze?.count&&!!(ze.dirty||ze.pending||ze.error),tt=!!pe&&et&&pe===ze.error;(0,v.useEffect)(()=>{let e=globalThis.document.documentElement,t=new MutationObserver(()=>He(e.dataset.mode||`light`));return t.observe(e,{attributes:!0,attributeFilter:[`data-mode`]}),()=>t.disconnect()},[]);let nt=(0,v.useMemo)(()=>{try{let e=wq(t);return{value:e,signature:ht(e)}}catch(e){return{error:e.message}}},[t]);de.current={onSharedChange:o,onRun:u,onUseOutput:d,onAddFiles:f,onChangeFiles:p,onPreviewImage:m,onPreviewMedia:h,onPreviewVoice:g,onModels:_,onAllowSpending:y,onRunPrice:b,onRunPriced:S,onDownload:D,onGoalSpending:re,onError:k},fe.current=nt;let[rt,it]=(0,v.useState)(null),at=M?rt?.handle===M&&rt.allowed:!ae||rt?.content===ae&&rt.parent===oe&&rt.allowed;(0,v.useEffect)(()=>{if(!ae&&!M)return;let e=!0,t=new AbortController;return it(null),(M?T(M,{signal:t.signal}):Promise.all([ae,...oe?[oe]:[]].map(e=>ZU(e,{signal:t.signal})))).then(()=>{e&&it({handle:M,content:ae,parent:oe,allowed:!0})},t=>{t?.code===`BLOCK_REVOKED`&&ae&&xi(ae,`${a||`anonymous`}:${r||`preview`}`).catch(()=>{}),e&&(it({handle:M,content:ae,parent:oe,allowed:!1,error:t.message}),de.current.onError?.(t))}),()=>{e=!1,t.abort()}},[ae,oe,M,_e]);let ot=VH(ie)&&ie.files?ie.files:null,[st,ct]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!ot||!at){ct(null);return}let e=!0,t=new AbortController;return ct(null),Promise.resolve().then(()=>(SH(ie),Ti(()=>Promise.resolve().then(()=>(mW(),lW)),void 0))).then(({loadViewAssets:e})=>e(ot,{signal:t.signal})).then(t=>{e&&ct({files:ot,assets:t})},t=>{e&&ct({files:ot,error:String(t?.message||`The interface files could not be loaded.`)})}),()=>{e=!1,t.abort()}},[ie,ot,at]);let lt=ot?st?.files===ot?st:{loading:!0}:null,ut=JSON.stringify([...new Set(L.filter(e=>typeof e==`string`))].sort()),dt=vt(ae?.manifest?.inputs)?ht(Object.fromEntries(Object.entries(ae.manifest.inputs).map(([e,t])=>[e,String(t?.type||``)]))):``,ft=[ie,lt,I,te,_e,a,r,ce,le,F,Ze,Qe,$e,ut,dt,!!ae?.manifest?.sharedWork,ae?.capability?.operation],pt=(0,v.useRef)(null);if(!pt.current||ft.some((e,t)=>!Object.is(e,pt.current.inputs[t]))){let e;try{if(lt?.loading)throw Object.assign(Error(`Loading the interface files.`),{loading:!0});if(lt?.error)throw Error(lt.error);let t=dq(),n=dq(),r=zU(),i=Mq();e={session:t,nativeTextToken:n,codeGuard:i,filming:!!r,html:Nq(ie,t,Ue.current,te,Ze,JSON.parse(ut),n,!!ae?.manifest?.sharedWork,ae?.capability?.operation===`connection.execute`,{assets:lt?.assets||{},filming:r,inputTypes:dt?JSON.parse(dt):null,frameGuard:i}),locked:JSON.parse(ut)}}catch(t){e=t.loading?{loading:!0}:{error:t.message}}pt.current={inputs:ft,document:e}}let mt=pt.current.document,_t=mt?.session;(0,v.useEffect)(()=>{let e=ue.current?.contentWindow;e&&_t&&e.postMessage({channel:lq,session:_t,op:`zoom-mode`,mode:De},`*`)},[De,_t]);let B=/\bdata-stillmade-layout\s*=\s*["']?own\b/.test(typeof ie?.html==`string`?ie.html:``);(0,v.useEffect)(()=>{if(!F||!_t)return;let e=null,t=()=>{e=null;let t=ue.current?.contentWindow,n=NU(ue.current);t&&t.postMessage({channel:lq,session:_t,op:`zoom-space`,height:n},`*`),B&&ue.current&&Te(Math.min(3e4,PU(ue.current)))},n=()=>{clearTimeout(e),e=setTimeout(t,200)},r=null;if(B&&ue.current&&typeof ResizeObserver==`function`){r=new ResizeObserver(n);for(let e=ue.current.parentElement;e&&e!==mt.body;e=e.parentElement)r.observe(e)}let i=B&&!he?[300,1e3,2500].map(e=>setTimeout(t,e)):[];return addEventListener(`resize`,n),()=>{clearTimeout(e),i.forEach(clearTimeout),r?.disconnect(),removeEventListener(`resize`,n)}},[F,_t,B,he]);let yt=(0,v.useMemo)(()=>({state:{},outputs:{},memory:null,canEdit:!0,localOnly:!0}),[mt.session]),bt=(0,v.useRef)(n);bt.current=n??yt;let xt=(0,v.useRef)(n==null);xt.current=n==null;let St=(0,v.useRef)({session:null,count:0}),Ct=(0,v.useRef)(null),wt=(0,v.useRef)(null),Tt=(0,v.useRef)(null),Et=(0,v.useRef)(null),Dt=(0,v.useRef)(null),kt=(0,v.useRef)(null),At=(0,v.useRef)(null);kt.current={key:r,peers:i,actorId:a};let jt=(0,v.useRef)(null),Nt=(0,v.useRef)(null),Pt=(0,v.useRef)(O),Ft=(0,v.useRef)(null);Pt.current=O,Ft.current={input:nt.signature,error:nt.error,view:ie,policyContent:ae,policyParent:oe,resetKey:I,appearance:te,policyReady:at};let It=(0,v.useRef)(null);It.current=ht([R?.projectId,R?.placementId,R?.sourceDigest,a].map(e=>e??null));let[Lt,Rt]=(0,v.useState)(null),zt=ht([Mt(),a,It.current,mt.session,nt.signature,at].map(e=>e??null));(0,v.useEffect)(()=>{let e=!0;if(Rt(null),!R?.projectId||!R?.placementId||!R?.sourceDigest||nt.error||!at||a!==Mt())return()=>{e=!1};let t=zt;return gt(nt.value).then(n=>{e&&Rt({basis:t,value:{version:1,actorId:a,projectId:R.projectId,placementId:R.placementId,sourceDigest:R.sourceDigest,inputDigest:n}})},()=>{e&&Rt(null)}),()=>{e=!1}},[zt]),Lt?.basis===zt&&Lt.value;let[Bt,Vt]=(0,v.useState)(null),Ht=(0,v.useRef)(null),Ut=(0,v.useRef)(null),Wt=(0,v.useRef)(null),[Gt,Kt]=(0,v.useState)(null),[qt,Jt]=(0,v.useState)(!1),[Yt,Xt]=(0,v.useState)(!1),[Zt,Qt]=(0,v.useState)(null);Zt&&Zt.actor===a&&Zt.runtimeActor===Mt()&&Zt.identity===It.current&&Zt.session===mt.session&&Object.keys(Zt.authority).every(e=>Zt.authority[e]===Ft.current[e])&&Zt.evidence,(0,v.useEffect)(()=>{if(!ne)return;let e={async find(e,t){for(let n=0,r=0;r<25;r++){if(!Ut.current)return null;Wt.current?.offset!==n&&await Ut.current.request(`inspect-view-controls`,{offset:n},t);let r=Wt.current;if(!r)return null;let i=e(r.controls||[]);if(i)return i;if(n+=r.controls.length,!r.controls.length||n>=r.total)return null}return null},press(e,t){if(!Ut.current)throw Error(`The declared interface is closed.`);return Ut.current.request(`dispatch-view-control`,{control:{id:e.id,revision:Wt.current?.revision,identity:e.identity}},t)}};return ne.current=e,()=>{ne.current===e&&(ne.current=null)}},[ne]),{...R},ae?.manifest?.id,ae?.manifest?.version,mt.session,nt.signature,bt.current?.canEdit,{...R},mt.session,nt.signature,bt.current?.canEdit,(0,v.useEffect)(()=>{if(Vt(null),Kt(null),Xt(!1),Jt(!1),Qt(null),me(``),Te(null),Re(null),Be(null),mt.error||mt.loading||!at)return;let e=!0,t=!1,n=!1,i=null,o=null,s=null,c=0,l=0,u=[],d=[],f=[],p=[],m=0,h=0,g=new Set,_=-1/0,v=-1/0,y=e=>{e.isTrusted&&(_=Date.now())};globalThis.document.addEventListener(`pointerdown`,y,!0),globalThis.document.addEventListener(`keydown`,y,!0);let b,x=0,S=null,T=[],D=null,O=0,k=!1,A=0,j=new Set,M=null,N=null,P=null,I=null,ee=null,te=[],L=[],ne=e=>{e!==ee&&(ee=e,Oe({op:`run-price`,words:e}),de.current.onRunPriced?.(e))},re=()=>{if(clearTimeout(N),N=null,!e||!t)return;let n=de.current.onRunPrice,r=M;if(!r||typeof n!=`function`||bt.current?.canEdit===!1){P=null,I?.abort(),I=null,ne(null);return}let i=ht([r,Pt.current]);if(i===P)return;let a=Date.now();if(te=te.filter(e=>a-e<6e4),te.length>=20){P=null,I?.abort(),I=null,ne(null);return}te.push(a),P=i,I?.abort();let o=new AbortController;I=o,Promise.resolve().then(()=>n(structuredClone(r),{signal:o.signal})).then(e=>Ti(async()=>{let{runPriceWords:e}=await Promise.resolve().then(()=>(dK(),QG));return{runPriceWords:e}},void 0).then(({runPriceWords:t})=>t(e))).then(t=>{e&&I===o&&ne(t)},()=>{e&&I===o&&(P=null,ne(null))}).finally(()=>{I===o&&(I=null)})};Nt.current=()=>{N||re()};let oe=0,se=null,pe=0,he=0,_e=null,ve=0,z=VH(ie),Se=null,we=()=>{Se&&globalThis.document.fullscreenElement!==Se&&(Se=null,Oe({op:`media-stage-end`}))};globalThis.document.addEventListener(`fullscreenchange`,we);let Ee=()=>{let t;return t=Rz(ae,{onStatus:n=>{e&&b===t&&xe(n)},onLive:(n,r)=>{e&&b===t?ue.current?.contentWindow?.postMessage({channel:lq,session:mt.session,op:`live`,...n},`*`,r):n.bitmap?.close?.()},onActivity:n=>{e&&b===t&&Ce(n)},storageScope:`${a||`anonymous`}:${r||`preview`}`}),t};b=Ee(),ye.current=b,xe(null),Ce(null);let De=()=>{if(!e||!bt.current?.canEdit)return;let t=b;b=Ee(),ye.current=b,S=null,xe(null),Promise.resolve(t.close()).catch(()=>{})};be.current=De;let Oe=t=>{e&&ue.current?.contentWindow?.postMessage({channel:lq,session:mt.session,...t},`*`)},ke=null,Me=0,Fe=(e,t)=>{let n=wt.current,r=ue.current,i=n?.parentElement;if(!n||!r||!i)return;let a=Math.max(0,t?.x??0),o=Math.max(0,t?.y??0),s=Math.min(r.clientWidth,(t?.x??0)+(t?.width??0)),c=Math.min(r.clientHeight,(t?.y??0)+(t?.height??0));if(!t||s<=a||c<=o){n.hidden=!0,delete n.dataset.control;return}let l=r.getBoundingClientRect(),u=i.getBoundingClientRect();n.style.transform=`translate(${l.left+r.clientLeft-u.left-i.clientLeft+a}px,${l.top+r.clientTop-u.top-i.clientTop+o}px)`,n.style.width=`${s-a}px`,n.style.height=`${c-o}px`,n.dataset.control=e,n.hidden=!1};Fe(null,null),Tt.current=n=>{!e||!t||typeof n!=`string`||ke&&Date.now()-ke.at<1e3||(ke={id:`locate-`+ ++Me,control:n,at:Date.now()},Oe({op:`locate-view-control`,id:ke.id,control:n}))};let Le=new Map,ze=new Set,Ve=0,He=!1,Je=(e,t)=>new Promise(n=>{let r=`film-`+ ++Ve,i=setTimeout(()=>{Le.delete(r),n(null)},6e3);Le.set(r,e=>{clearTimeout(i),Le.delete(r),n(e)}),Oe({op:e,id:r,...t})}),Ye=mt.filming&&ue.current?BU({element:ue.current,placementId:R?.placementId||null,capture:e=>Je(`capture-view`,e),locate:e=>Je(`locate-view-control`,{control:e}),get drawn(){return He},onChange:e=>(ze.add(e),()=>ze.delete(e))}):null,et=null,tt=null,nt=0,rt=!1,it=a,ot=Ft.current,st=It.current,ct=(t,n)=>{if(!e||rt||t?.signal?.aborted||Mt()!==it||It.current!==st||tt&&fe.current.signature!==tt.inputIdentity||et&&fe.current.signature!==et.inputIdentity&&fe.current.signature!==n||Object.keys(ot).filter(e=>e!==`input`).some(e=>ot[e]!==Ft.current[e]))throw rt=!0,Xt(!1),Error(`The declared interface source, account or task changed. Reload the preview before further assisted edits.`)},lt=e=>{if(!et)return;let t=et;et=null,clearTimeout(t.timer),t.context?.signal?.removeEventListener(`abort`,t.abort),Jt(!1),t.reject(e)};Ut.current={request:(e,n,r={})=>new Promise((a,o)=>{try{if(ct(r),!t||et)throw Error(`The declared interface is loading or busy.`);if(e===`dispatch-view-control`&&!r.taskFence)throw Error(`The declared interface requires its active project task.`);let s=String(++nt),c=()=>{rt=!0,Xt(!1),i?.abort(),lt(Error(`Declared action stopped; reload the preview before more assisted edits.`))},l=setTimeout(c,le);et={id:s,op:e,inputIdentity:fe.current.signature,offset:n.offset,context:r,resolve:a,reject:o,timer:l,abort:c},r.signal?.addEventListener(`abort`,c,{once:!0}),e===`dispatch-view-control`&&Jt(!0),Oe({op:e,id:s,...n})}catch(e){o(e)}})},Ht.current={request:(e,n)=>new Promise((r,i)=>{try{if(ct(n),!t||et||tt||!n.taskFence||n.signal?.aborted)throw Error(`The original text requires its idle current task.`);let a=String(++nt),o=()=>{rt=!0,Xt(!1),tt?.id===a&&(tt=null,Jt(!1),i(Error(`Original text stopped; retain its pending request.`)))},s=setTimeout(o,le);tt={id:a,field:e.field,inputIdentity:fe.current.signature,context:n,resolve:r,reject:i,timer:s,abort:o},n.signal?.addEventListener(`abort`,o,{once:!0}),Jt(!0),Oe({op:`dispatch-named-text`,id:a,control:e})}catch(e){i(e)}})};let ut=()=>{if(rt)throw Error(`This previous assisted interface is no longer writable. Reload it to recover.`);return et?.op===`dispatch-view-control`?(ct(et.context),et.context):null},dt=!1,ft=0,pt=[],gt=0,_t=!1,yt=0,St=[],Lt=0,Rt=0,zt=[],Bt=null,Gt=!1,qt={projectId:Qe,placementId:$e,actorId:a},Yt=()=>e&&Ke.current?.projectId===qt.projectId&&Ke.current?.placementId===qt.placementId,Zt=e=>({message:String(e?.message||`Shared text failed.`).slice(0,1e3),...typeof e?.code==`string`&&/^[A-Z][A-Z0-9_]{0,79}$/.test(e.code)?{code:e.code}:{}}),$t=Ke.current?.projectId&&a?rr({projectId:Ke.current.projectId,actorId:a,headers:ir,onChange:e=>{if(Yt()){if(e.kind===`revoked`){Gt=!0,Oe({op:`shared-view`,value:{...bt.current,canEdit:!1}});return}[`text`,`document`,`resync`].includes(e.kind)&&(e.scope&&e.scope!==`canvas`||Bt===null&&(Bt=setTimeout(()=>{Bt=null,t&&Yt()&&!Gt&&Oe({op:`text-refresh`})},100)))}}}):null,en=Ge.current?.projectId&&a?rr({projectId:Ge.current.projectId,actorId:a,headers:ir,onChange:e=>{t&&[`document`,`resync`,`revoked`,`connection-access`].includes(e.kind)&&(gt++,Oe({op:`shared-work-refresh`}))}}):null,tn=()=>{t&&Oe({op:`theme`,mode:Ue.current})};At.current=tn;let nn=`[]`,rn=()=>{if(!t)return;let{key:e,peers:n,actorId:r}=kt.current,i=!xt.current&&e&&localStorage.getItem(`stillmade:show-shared-cursors`)!==`false`?n.filter(t=>t.user_id!==r&&t.selection?.cursor?.visible&&t.selection.cursor.surface===e).slice(0,50).flatMap(e=>{let t=tU(e.selection.cursor.anchor);return t?[{id:String(e.session_id).slice(0,200),label:String(e.label||`Teammate`).slice(0,120),anchor:t}]:[]}):[],a=JSON.stringify(i);a!==nn&&(nn=a,Oe({op:`peer-cursors`,peers:i}))};Dt.current=rn,window.addEventListener(`stillmade:cursor-preferences`,rn),window.addEventListener(`storage`,rn);let an=null,on=()=>{let e=ue.current;if(!e)return null;let t=e.getBoundingClientRect();return{x:t.left+e.clientLeft,y:t.top+e.clientTop,right:t.right,bottom:t.bottom}},sn=()=>{an&&(an.bounds=on())},cn=()=>{an&&(an=null,window.removeEventListener(`scroll`,sn,{capture:!0}),window.removeEventListener(`resize`,sn))},ln=n=>{let r=n.detail;e&&r?.root?.contains?.(ue.current)&&(r.action===`start`&&t&&!an?(an={bounds:on()},window.addEventListener(`scroll`,sn,{passive:!0,capture:!0}),window.addEventListener(`resize`,sn),Oe({op:`pick-start`})):r.action===`stop`&&an&&(cn(),Oe({op:`pick-stop`})))};window.addEventListener(aU.control,ln);let un=e=>{me(e),de.current.onError?.(Object.assign(Error(e),{shown:!0}))},dn=()=>{e&&(clearInterval(se),_e?.disconnect(),Promise.resolve(b?.call(`live.stop`)).catch(()=>{}),un(`This interface stopped responding and was closed. Reload it to try again.`),e=!1,i?.abort(),ue.current&&(ue.current.src=`about:blank`))};Ct.current=z?()=>{e&&(clearInterval(se),Promise.resolve(b?.call(`live.stop`)).catch(()=>{}),un(`This interface tried to leave its frame and was closed. Reload it to try again.`),e=!1,i?.abort(),ue.current&&(ue.current.src=`about:blank`))}:null;let fn=()=>{if(typeof PerformanceObserver!=`function`||!PerformanceObserver.supportedEntryTypes?.includes(`longtask`))return;let e=[],t=e=>Array.from(e.attribution||[]).some(e=>e.containerType===`iframe`&&typeof e.containerSrc==`string`&&e.containerSrc.endsWith(`#${mt.session}`));_e=new PerformanceObserver(n=>{for(let r of n.getEntries()){if(!t(r))continue;let n=r.startTime+r.duration;if(e=e.filter(e=>e.end>n-5e3),e.push({end:n,duration:r.duration}),r.duration>=FH.longTaskMs||e.reduce((e,t)=>e+t.duration,0)>=3500)return dn()}});try{_e.observe({type:`longtask`})}catch{_e=null}},pn=()=>{pe=Date.now(),se=setInterval(()=>{if(!e)return clearInterval(se);if(globalThis.document.visibilityState!==`hidden`&&Date.now()-pe>8e3)return dn();Oe({op:`ping`,id:String(++he)})},2e3)};ge(!0);let mn=setTimeout(()=>{e&&!t&&(ge(!1),un(C()?w():`This Block could not start. Reload it to try again.`),e=!1,i?.abort(),ue.current&&(ue.current.src=`about:blank`))},C()?5e3:15e3),hn=e=>{let t=o;t&&(Qt(null),o=null,t.controller.abort(),e&&Oe({op:t.media?`preview-media-result`:`preview-image-result`,id:t.id,error:e}))},gn=()=>{if(!t)return;let e=fe.current;if(e.error){hn(`Preview input is unavailable.`),un(e.error);return}s!==e.signature&&(hn(`Preview input changed. Use its current image.`),s=e.signature,Oe({op:`input`,input:e.value}))};jt.current=gn;let _n=null,vn=!1,yn=0,bn=[],xn=null,Sn=0,Cn=null,wn=$n(()=>{if(xt.current||!t)return Promise.resolve();if(!e)return Promise.reject(Error(`The Block interface is unavailable. Its latest edits could not be checked.`));if(xn)return xn.promise;let n=String(++Sn),r,i,a=new Promise((e,t)=>{r=e,i=t}),o=setTimeout(()=>{xn?.id===n&&(xn=null,i(Error(`The Block did not confirm its pending edits. Stay here to recover the draft.`)))},17e3);return xn={id:n,promise:a,resolve:r,reject:i,timer:o},Oe({op:`flush-shared`,id:n}),a}),Tn=()=>{if(t&&bt.current)try{let e=wq(bt.current),t=ht(e);if(t===_n)return;_n=t,Oe({op:`shared-view`,value:e})}catch(e){un(e.message)}};Et.current=Tn;let En=t=>{e&&xt.current&&(bt.current.outputs=t,Tn())},Dn=r=>{let s=r.data;if(z&&e&&vt(s)&&s.op===`navigated`&&s.channel===lq&&s.session===mt.session&&(r.source===null||r.source===ue.current?.contentWindow)){Ct.current?.();return}if(!e||r.source!==ue.current?.contentWindow||!vt(s)||s.channel!==lq||s.session!==mt.session)return;if(s.op===`document-ready`){n||(n=!0,Oe({op:`document`,html:mt.html}));return}if(s.op===`view-changed`){He=!0;let e=Array.isArray(s.rects)?s.rects.slice(0,40).filter(e=>vt(e)&&[`x`,`y`,`width`,`height`].every(t=>Number.isFinite(e[t]))):[];for(let t of ze)t(e);return}if(s.op===`capture-view-result`||s.op===`view-control-rect`&&Le.has(s.id)){let e=Le.get(s.id),t=s.rect;if(!e){s.bitmap?.close?.();return}e(s.op===`capture-view-result`?s.bitmap instanceof ImageBitmap?s.bitmap:null:vt(t)&&[`x`,`y`,`width`,`height`].every(e=>Number.isFinite(t[e]))&&t.width>0&&t.height>0?t:null);return}if(s.op===`zoom-key`){Pe.current(s.step===`auto`?`auto`:FU(Ne.current,s.step===`bigger`?gU:-gU));return}if(s.op===`media-stage`){let e=ue.current,t=globalThis.document;if(!e)return;if(s.on===!0){if(!t.fullscreenElement&&globalThis.navigator?.userActivation?.isActive&&t.activeElement===e&&typeof e.requestFullscreen==`function`){Se=e;try{Promise.resolve(e.requestFullscreen()).catch(()=>{Se=null})}catch{Se=null}}}else if(t.fullscreenElement===e){Se=null;try{Promise.resolve(t.exitFullscreen?.()).catch(()=>{})}catch{}}return}if(s.op===`zoom-state`){Ae(e=>{let t={supported:s.supported===!0,zoom:Number.isFinite(s.zoom)?s.zoom:1};return e&&e.supported===t.supported&&e.zoom===t.zoom?e:t});return}if(s.op===`ready`){t||(t=!0,ge(!1),clearTimeout(mn),Oe({op:`zoom-mode`,mode:je.current}),F&&Oe({op:`zoom-space`,height:NU(ue.current)}),z&&(pn(),fn()),tn(),gn(),Tn(),rn(),Oe({op:`inspect-view-controls`,offset:0}),Oe({op:`inspect-named-text`}));return}if(s.op===`flush-shared-result`){if(!xn||s.id!==xn.id)return;let e=xn;xn=null,clearTimeout(e.timer);let t=s.error||Cn;t?e.reject(Error(String(t).slice(0,1e3))):e.resolve({queued:!0});return}if(s.op===`escape`){let e=Date.now();globalThis.document.activeElement===ue.current&&e-oe>=300&&(oe=e,window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Escape`,bubbles:!0})));return}if(s.op===`pong`){z&&typeof s.id==`string`&&(pe=Date.now());return}if(s.op===`unresponsive`){z&&dn();return}if(s.op===`interface-error`){un(String(s.error||`The Block interface could not display its input`).slice(0,1e3));return}if(s.op===`document-store-status`){let e=s.status;vt(e)&&[`count`,`dirty`,`pending`,`readonly`].every(t=>Number.isInteger(e[t])&&e[t]>=0&&e[t]<=8)&&[`dirty`,`pending`,`readonly`].every(t=>e[t]<=e.count)&&(e.error===null||typeof e.error==`string`&&e.error.length<=1e3)&&Re(e);return}if(s.op===`text-recovery-status`){let e=s.status;Ze&&vt(e)&&Object.keys(e).every(e=>[`count`,`dirty`,`pending`,`readonly`,`error`,`retryable`].includes(e))&&[`count`,`dirty`,`pending`,`readonly`].every(t=>Number.isInteger(e[t])&&e[t]>=0&&e[t]<=100)&&[`dirty`,`pending`,`readonly`].every(t=>e[t]<=e.count)&&(e.error===null||typeof e.error==`string`&&e.error.length<=1e3)&&typeof e.retryable==`boolean`&&Be(e);return}if(!t)return;if(s.op===`pick-hover`){if(!an)return;let e=uU(s.hover),t=an.bounds,n=null;if(e&&t){let r=Math.max(t.x,e.rect.x+t.x),i=Math.max(t.y,e.rect.y+t.y),a=Math.min(t.right,e.rect.x+t.x+e.rect.width),o=Math.min(t.bottom,e.rect.y+t.y+e.rect.height);a>r&&o>i&&(n={...e,rect:{x:r,y:i,width:a-r,height:o-i},cursor:{x:e.cursor.x+t.x,y:e.cursor.y+t.y}})}window.dispatchEvent(new CustomEvent(aU.hover,{detail:{hover:n}}));return}if(s.op===`pick-result`||s.op===`pick-cancel`){if(!an)return;cn();let e=s.op===`pick-result`?dU(s.target):null;e?window.dispatchEvent(new CustomEvent(aU.result,{detail:{target:e}})):window.dispatchEvent(new CustomEvent(aU.cancel));return}if(s.op===`named-text-controls`){if(s.token===mt.nativeTextToken&&Array.isArray(s.snapshot)&&s.snapshot.length<=50){let e=wq(s.snapshot);e.every(e=>vt(e)&&typeof e.field==`string`&&typeof e.identity==`string`&&typeof e.value==`string`&&e.value.length<=1e4&&typeof e.partial==`boolean`&&typeof e.ready==`boolean`&&typeof e.disabled==`boolean`)&&Vt(e)}return}if(s.op===`named-text-result`){let e=tt;if(!e||s.id!==e.id||s.token!==mt.nativeTextToken)return;try{if(ct(e.context),s.error)throw Error(String(s.error).slice(0,1e3));e.resolve()}catch(t){e.reject(t)}finally{tt=null,clearTimeout(e.timer),e.context.signal?.removeEventListener(`abort`,e.abort),Jt(!1)}return}if(s.op===`view-controls`){try{let e=wq(s.snapshot);if(!vt(e)||!Number.isSafeInteger(e.revision)||!Number.isSafeInteger(e.total)||e.total<0||e.total>1e4||!Number.isSafeInteger(e.offset)||!Array.isArray(e.controls)||e.controls.length>20||e.controls.some(e=>!vt(e)||typeof e.id!=`string`||typeof e.identity!=`string`||typeof e.action!=`string`||typeof e.disabled!=`boolean`||typeof e.hidden!=`boolean`))throw Error(`Invalid declared interface controls.`);if(Wt.current=e,Kt(e),Xt(!rt),et?.op===`inspect-view-controls`&&e.offset===et.offset){let e=et;ct(e.context),et=null,clearTimeout(e.timer),e.context.signal?.removeEventListener(`abort`,e.abort),e.resolve()}}catch(e){lt(e)}return}if(s.op===`view-control-rect`){if(!ke||s.id!==ke.id)return;let{control:e}=ke,t=s.rect;ke=null,Fe(e,vt(t)&&[`x`,`y`,`width`,`height`].every(e=>Number.isFinite(t[e]))&&t.width>0&&t.height>0?t:null);return}if(s.op===`view-controls-error`){lt(Error(String(s.error||`Declared controls are unavailable.`).slice(0,1e3)));return}if(s.op===`view-control-result`){if(et?.op!==`dispatch-view-control`||s.id!==et.id)return;let e=et;try{if(ct(e.context),s.error)throw Error(String(s.error).slice(0,1e3));et=null,clearTimeout(e.timer),e.context.signal?.removeEventListener(`abort`,e.abort),Jt(!1),e.resolve()}catch(e){lt(e)}return}if(s.op===`connected-app-request`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=ft)return;ft=Number(s.id);let t=e=>Oe({op:`connected-app-result`,id:s.id,...e}),n=We.current,r=Ft.current;pt=pt.filter(e=>Date.now()-e<6e4);try{if(ae?.capability?.operation!==`connection.execute`||!n?.request)throw Error(`Open the saved connected Block to choose its task.`);let i=Ot(s.operation,wq(s.args));if(i.operation!==`tasks`&&!bt.current?.canEdit)throw Error(`This workspace is read only.`);if(dt||pt.length>=30)throw Error(`Wait for the current task request.`);dt=!0,pt.push(Date.now()),Promise.resolve().then(()=>n.request(i.operation,i.args)).then(i=>{if(!e||n.projectId!==We.current?.projectId||n.placementId!==We.current?.placementId||Object.keys(r).some(e=>r[e]!==Ft.current[e]))throw Error(`The installed app changed. Open its current workspace.`);t({result:wq(i)})},e=>t({error:String(e.message||`Task selection failed.`).slice(0,1e3)})).catch(e=>t({error:String(e.message).slice(0,1e3)})).finally(()=>{dt=!1})}catch(e){t({error:String(e.message).slice(0,1e3)})}return}if(s.op===`shared-work-media-request`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=yt)return;yt=Number(s.id);let t=Ge.current,n=Ft.current,r=gt,i=e=>Oe({op:`shared-work-result`,id:s.id,...e});try{if(!ae?.manifest?.sharedWork||!ae.manifest.permissions?.project?.includes(`work.shared`)||!t?.previewMedia||typeof s.contributionId!=`string`||!/^[0-9a-f-]{36}$/i.test(s.contributionId))throw Error(`Choose a permitted saved creative in this workspace.`);if(St=St.filter(e=>Date.now()-e<6e4),_t||St.length>=60)throw Error(`Wait for the current media preview.`);_t=!0,St.push(Date.now()),Promise.resolve().then(()=>t.previewMedia(s.contributionId,{signal:AbortSignal.timeout(3e4)})).then(t=>{if(!e||r!==gt||Object.keys(n).some(e=>n[e]!==Ft.current[e]))throw Error(`This workspace changed before the creative preview.`);if(!(t.media instanceof Blob)||!t.media.size||t.media.size>67108864||![`image`,`video`,`audio`].includes(t.kind)||!t.media.type.startsWith(t.kind+`/`))throw Error(`This preview exceeds the media limit.`);i(t)},e=>i({error:String(e.message||`Media preview failed.`).slice(0,1e3)})).catch(e=>i({error:String(e.message).slice(0,1e3)})).finally(()=>{_t=!1})}catch(e){i({error:String(e.message).slice(0,1e3)})}return}if(s.op===`shared-work-request`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=yt)return;yt=Number(s.id);let t=e=>Oe({op:`shared-work-result`,id:s.id,...e}),n=Ge.current,r=Ft.current,i=gt;St=St.filter(e=>Date.now()-e<6e4);try{if(!ae?.manifest?.permissions?.project?.includes(`work.shared`)||!ae.manifest.sharedWork||!n?.request)throw Error(`Shared work is unavailable in this preview. Open the saved Block in its project.`);let a=E(s.operation,wq(s.args));if(![`read`,`list`,`accounts`,`grants`,`creatives`].includes(a.operation)&&!bt.current?.canEdit)throw Error(`This workspace is read only.`);if(_t||St.length>=60)throw Error(`Wait for the current shared-work request.`);_t=!0,St.push(Date.now()),Promise.resolve().then(()=>n.request(a.operation,a.args)).then(o=>{if(!e||n.projectId!==Ge.current?.projectId||n.placementId!==Ge.current?.placementId||Object.keys(r).some(e=>r[e]!==Ft.current[e]))throw Error(`This Block changed before the shared-work response. Reopen its current version.`);if(i!==gt){if([`read`,`list`,`accounts`,`grants`,`creatives`].includes(a.operation))throw Error(`Saved-work access changed. Read its current version.`);t({result:{saved:!0,refreshRequired:!0}});return}t({result:wq(o)})},e=>t({error:String(e.message||`Shared work failed.`).slice(0,1e3)})).catch(e=>t({error:String(e.message).slice(0,1e3)})).finally(()=>{_t=!1})}catch(e){t({error:String(e.message).slice(0,1e3)})}return}if(s.op===`text-request`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=Rt)return;Rt=Number(s.id);let e=e=>Oe({op:`text-result`,id:s.id,...e}),t=Ke.current,n=fe.current.signature,r=Ft.current;if(zt=zt.filter(e=>Date.now()-e<6e4),!Ze||!Yt()||!t||typeof t.request!=`function`||![`read`,`initialize`,`update`,`reset`].includes(s.action)||typeof s.key!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(s.key)||[`constructor`,`prototype`,`__proto__`].includes(s.key)){e({error:{message:`Shared text is unavailable for this field.`}});return}if(Lt>=16||zt.length>=1200){e({error:{message:`Shared text requests are arriving too quickly. Your draft is retained.`}});return}let i=()=>{if(!Yt()||fe.current.error||fe.current.signature!==n||Object.keys(r).some(e=>r[e]!==Ft.current[e]))throw Error(`Shared text input or workspace changed. Your draft is retained.`);if(Gt||s.action!==`read`&&!bt.current?.canEdit)throw Object.assign(Error(`Shared text is read only.`),{code:`READ_ONLY`})},a;try{if(i(),a=wq(s.body),!vt(a)||new TextEncoder().encode(JSON.stringify(a)).length>5e4||Object.keys(a).some(e=>![`protocol`,`requestId`,`sourceIdentity`,`epoch`,`textRevision`,`value`,`update`].includes(e)))throw Error(`Invalid shared text request.`)}catch(t){e({error:Zt(t)});return}Lt++,zt.push(Date.now()),Promise.resolve().then(async()=>{if(i(),ut()&&s.action!==`read`)throw Error(`Assisted shared-text writes require a task-safe native commit interface; this control is unavailable.`);try{let e=tt,n;if(e&&s.action!==`read`){if(ct(e.context),s.action!==`update`||s.key!==e.field||s.nativeText?.token!==mt.nativeTextToken||s.nativeText?.callId!==e.id)throw Error(`Unrelated text events cannot use this native task.`);n=e.context}else if(s.nativeText)throw Error(`The original text invocation is no longer current; do not replay.`);return await t.request(s.action,{...a,placementId:t.placementId,fieldKey:s.key},n)}catch(e){if(s.action===`read`&&e.code===`SHARED_TEXT_FIELD_UNSUPPORTED`&&typeof bt.current?.state?.[s.key]!=`string`)return{unsupported:!0};throw e}}).then(t=>{i(),e({result:wq(t)})}).catch(t=>e({error:Zt(t)})).finally(()=>{Lt--});return}if(s.op===`cursor`){let e=s.cursor;if(vt(e)&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1){let t=ue.current?.getBoundingClientRect(),n=tU(e.anchor),r=kt.current.key;t&&window.dispatchEvent(new CustomEvent(`stillmade:sandbox-cursor`,{detail:{x:(t.left+e.x*t.width)/Math.max(1,window.innerWidth),y:(t.top+e.y*t.height)/Math.max(1,window.innerHeight),visible:e.visible!==!1,...n&&typeof r==`string`&&r.length>0&&r.length<=200&&!xt.current?{anchor:n,surface:r}:{}}}))}return}if(s.op===`shared-view-update`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=yn)return;yn=Number(s.id);let t=e=>{Cn=e.error?String(e.error):null,Oe({op:`shared-view-result`,id:s.id,...e})};if(bn=bn.filter(e=>Date.now()-e<6e4),vn||bn.length>=240){t({error:`Shared edits are arriving too quickly. Wait and retry.`});return}if(!bt.current?.canEdit||!xt.current&&typeof de.current.onSharedChange!=`function`){t({error:`Shared editing is unavailable or read only.`});return}let n;try{if(n=wq(s.request),new TextEncoder().encode(JSON.stringify(n)).length>ur.requestBytes)throw Error(`Shared edit exceeds the limit`)}catch(e){t({error:e.message});return}vn=!0,bn.push(Date.now()),Promise.resolve().then(()=>{if(!e||!bt.current?.canEdit)throw Error(`Shared editing is unavailable or read only.`);if(ut(),xt.current){bt.current.state=dr(bt.current.state,n),Tn();return}let t=ut();return de.current.onSharedChange(n,t||void 0)}).then(()=>t({queued:!0}),e=>t({error:String(e.message).slice(0,1e3)})).finally(()=>{vn=!1});return}if(s.op===`content-size`){Number.isInteger(s.height)&&s.height>0&&s.height<=1e5&&Ie.current?.(s.height),F&&Number.isInteger(s.height)&&s.height>0&&s.height<=1e5&&Te(Math.max(280,Math.min(3e4,B?PU(ue.current):s.height)));return}if(s.op===`live-ack`){b?.liveAck?.();return}if(s.op===`desktop`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=x)return;x=Number(s.id);let t=e=>Oe({op:`desktop-result`,id:s.id,...e});if(T=T.filter(e=>Date.now()-e<6e4),S||T.length>=120){t({error:`Too many desktop requests. Wait before trying again.`});return}let n;try{if(n=wq(s.args||{}),JSON.stringify(n).length>131072||!vt(n))throw Error(`Desktop arguments exceed the limit`)}catch(e){t({error:e.message});return}let r=![`tool.status`,`storage.info`,`storage.list`,`storage.read`,`record.status`,`device.info`,`record.cancel`,`session.close`,`live.status`,`live.stop`,`folder.shared`,`folder.forget`,`folder.list`,`folder.read`].includes(s.operation)&&(s.operation!==`folder.pick`||s.args?.write===!0);if(r&&!bt.current?.canEdit){t({error:`Desktop changes are unavailable while this workspace is read only.`});return}if(s.operation===`record.cut`){let e=n?.source,r=Tq(e),i=[];try{i=Dq(fe.current?.value).map(Tq)}catch{}if(!r||!(b.authorizesMedia(e)||i.includes(r))){t({error:`Cut a video this Block received or recorded in this session.`});return}}let i={native:b};T.push(Date.now()),S=i,Promise.resolve().then(()=>{if(!e||i.native!==b||r&&!bt.current?.canEdit)throw Error(`Desktop access or edit permission changed before this request.`);if(ut()&&r)throw Error(`Assisted desktop mutations require a task-safe native interface; this control is unavailable.`);return i.native.call(s.operation,n,[`record.cut`,`folder.write`].includes(s.operation)?{received:(()=>{try{return Dq(fe.current?.value)}catch{return[]}})()}:void 0)}).then(n=>{if(!e||i.native!==b||r&&!bt.current?.canEdit)throw Error(`Desktop access or edit permission changed before this result could be used.`);t({result:wq(n)})},e=>t({error:String(e.message).slice(0,1e3)})).catch(e=>t({error:String(e.message).slice(0,1e3)})).finally(()=>{S===i&&(S=null)});return}if(s.op===`add-files`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=O)return;O=Number(s.id);let t=e=>Oe({op:`add-files-result`,id:s.id,...e});try{let n=bq(ae?.manifest,s.port);if(!bt.current?.canEdit)throw Error(`You can view this project but not add files to it.`);if(mt.locked.includes(n.name))throw Error(`This input comes from an earlier Step, so files cannot be added to it here.`);if(ut())throw Error(`Only a person adds files. Chat cannot open a file picker.`);if(typeof de.current.onAddFiles!=`function`)throw Error(`Adding files is unavailable here.`);if(D)throw Error(`Files are already being added.`);let r=s.gesture,i=globalThis.navigator?.userActivation;if(!vt(r)||!Number.isInteger(r.id)||r.id<=0||j.has(r.id)||!Number.isFinite(r.age)||r.age<0||r.age>uq||i&&!i.isActive||globalThis.document.activeElement!==ue.current)throw Error(`Add files from a click or key press in this screen.`);j.add(r.id);let a={picker:Sq(n)};D=a,a.picker.then(t=>{if(!e||D!==a)throw Error(`This Block closed before the files were added.`);if(!t.length)return{added:0};if(!bt.current?.canEdit)throw Error(`You can view this project but not add files to it.`);return de.current.onAddFiles(n.name,t,n.port)}).then(e=>t({added:Number.isInteger(e?.added)&&e.added>=0?e.added:0}),e=>t({error:String(e?.message||`The files could not be added.`).slice(0,1e3)})).finally(()=>{D===a&&(D=null)})}catch(e){t({error:String(e.message).slice(0,1e3)})}return}if(s.op===`change-files`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=A)return;A=Number(s.id);let e=e=>Oe({op:`change-files-result`,id:s.id,...e});try{let t=bq(ae?.manifest,s.port);if(!t.multiple)throw Error(`${JSON.stringify(t.name)} holds one file. Only a list input's files are removed or moved.`);if(!bt.current?.canEdit)throw Error(`You can view this project but not change its files.`);if(mt.locked.includes(t.name))throw Error(`This input comes from an earlier Step, so its files cannot be changed here.`);if(ut())throw Error(`Only a person changes files. Chat cannot remove or move them.`);if(typeof de.current.onChangeFiles!=`function`)throw Error(`Changing files is unavailable here.`);if(k)throw Error(`Files are already being changed.`);let n=s.gesture,r=globalThis.navigator?.userActivation;if(!vt(n)||!Number.isInteger(n.id)||n.id<=0||j.has(n.id)||!Number.isFinite(n.age)||n.age<0||n.age>uq||r&&!r.isActive||globalThis.document.activeElement!==ue.current)throw Error(`Remove or move files from a click or key press in this screen.`);let i=vt(s.edit)&&s.edit.op===`remove`?{op:`remove`,index:s.edit.index}:vt(s.edit)&&s.edit.op===`move`?{op:`move`,from:s.edit.from,to:s.edit.to}:null;if(!i)throw Error(`Remove or move one file.`);let a=fe.current.value?.[t.name];if(xq(a,i),ht(wq(s.item??null))!==ht(a[i.op===`move`?i.from:i.index]))throw Error(`These files changed. Look at them again, then try again.`);j.add(n.id),k=!0,Promise.resolve().then(()=>de.current.onChangeFiles(t.name,i,t.port)).then(t=>e({files:Number.isInteger(t?.files)&&t.files>=0?t.files:0}),t=>e({error:String(t?.message||`The files could not be changed.`).slice(0,1e3)})).finally(()=>{k=!1})}catch(t){e({error:String(t.message).slice(0,1e3)})}return}if(s.op===`use-output`){if(typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let e=e=>Oe({op:`use-output-result`,id:s.id,...e});try{if(ut())throw Error(`Assisted media adoption requires a task-safe native commit interface; this control is unavailable.`);if(z&&!bt.current?.canEdit)throw Error(`This workspace is read only.`);let t=wq(s.outputs),n=de.current.onUseOutput;if(typeof n!=`function`)throw Error(`Choosing an existing media output is unavailable in this workspace.`);kq(t,fe.current.value,b),Promise.resolve(n(t)).then(t=>{let n=wq(t);En(n),e({outputs:n})},t=>e({error:String(t?.message||`The media output could not be saved`).slice(0,1e3)}))}catch(t){e({error:String(t.message).slice(0,1e3)})}return}if(s.op===`code`){if(!z||typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let t=e=>Oe({op:`code-result`,id:s.id,...e});if(++ve>FH.codeFiles*4){t({error:`This interface asked for its code files too many times.`});return}Promise.resolve().then(()=>Ti(()=>Promise.resolve().then(()=>(mW(),lW)),void 0)).then(({loadViewCode:e})=>e(ie.files,s.path,{guard:mt.codeGuard})).then(n=>{e&&t({source:n})},n=>{e&&t({error:String(n?.message||`This code file could not be loaded.`).slice(0,1e3)})});return}if(s.op===`allow-spending`){if(typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let t=e=>Oe({op:`allow-spending-result`,id:s.id,...e}),n=vt(s.gesture)&&Number.isInteger(s.gesture.id)&&s.gesture.id>0&&Number.isFinite(s.gesture.age)&&s.gesture.age>=0&&s.gesture.age<=uq&&!g.has(s.gesture.id)&&!!globalThis.navigator?.userActivation?.isActive&&globalThis.document.activeElement===ue.current&&Date.now()-_>uq,r=de.current.onAllowSpending;if(typeof r!=`function`){t({error:`Spending approvals are for Steps in a project.`});return}if(!Number.isSafeInteger(s.credits)||s.credits<1||s.credits>OH.allowanceCredits||typeof s.label!=`string`||!s.label.trim()||s.label.length>120){t({error:`Name the total in whole credits and what it is for.`});return}let i=!n&&typeof de.current.onGoalSpending==`function`&&de.current.onGoalSpending()===!0;if(!n&&!i){t({error:`Ask from a click or key press in this screen.`});return}n&&g.add(s.gesture.id),Promise.resolve().then(()=>r({credits:s.credits,label:s.label.trim(),...i?{goal:!0}:{}})).then(n=>{e&&t({allowed:Number.isSafeInteger(n)&&n>0,credits:Number.isSafeInteger(n)?n:0})},n=>{e&&t({error:String(n?.message||`The approval did not open.`).slice(0,1e3)})});return}if(s.op===`next-run`){let e=null;try{e=s.plan==null?null:wq(s.plan)}catch{e=null}M=vt(e)?e:null,clearTimeout(N),M?N=setTimeout(re,400):re();return}if(s.op===`download`){if(typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let t=e=>Oe({op:`download-result`,id:s.id,...e});if(!(vt(s.gesture)&&Number.isInteger(s.gesture.id)&&s.gesture.id>0&&Number.isFinite(s.gesture.age)&&s.gesture.age>=0&&s.gesture.age<=uq&&!g.has(s.gesture.id)&&globalThis.navigator?.userActivation?.isActive&&globalThis.document.activeElement===ue.current&&Date.now()-_>uq)){t({error:`Download from a click or key press in this screen.`});return}let n=de.current.onDownload;if(typeof n!=`function`){t({error:`Downloads are for Steps in a project.`});return}let r=Date.now();if(L=L.filter(e=>r-e<6e4),L.length>=10){t({error:`Download limit reached. Wait a minute before trying again.`});return}let i=null;try{i=wq(s.value)}catch{}let a=Tq(i),o=[];try{o=Dq([fe.current?.value,bt.current?.outputs,bt.current?.made]).map(Tq)}catch{}if(!a||!(o.includes(a)||b?.authorizesMedia?.(i))){t({error:`Download a picture, clip or sound this screen was given or made.`});return}g.add(s.gesture.id),L.push(r),Promise.resolve().then(()=>n({kind:i.kind,assetId:i.assetId,versionId:i.versionId,url:i.url})).then(()=>{e&&t({})},n=>{e&&t({error:String(n?.message||`The download did not start.`).slice(0,1e3)})});return}if(s.op===`models`){if(typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let t=e=>Oe({op:`models-result`,id:s.id,...e}),n=Date.now();if(p=p.filter(e=>n-e<6e4),p.length>=30){t({error:`Model list limit reached. Wait a minute before asking again.`});return}p.push(n),Promise.resolve().then(()=>Ti(()=>Promise.resolve().then(()=>(cq(),oq)),void 0)).then(({blockModelList:e})=>e(ae?.manifest,s.operation,de.current.onModels)).then(n=>{e&&t({value:n})},n=>{e&&t({error:String(n?.message||`The model list could not be loaded.`).slice(0,1e3)})});return}if(s.op===`preview-voice`){if(typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let t=e=>Oe({op:`preview-voice-result`,id:s.id,...e}),n=Date.now();if(f=f.filter(e=>n-e<6e4),f.length>=OH.voicePreviewsPerMinute){t({error:`Voice sample limit reached. Wait a minute before trying again.`});return}f.push(n);let r=de.current.onPreviewVoice;if(typeof r!=`function`||!(ae?.manifest?.permissions?.capabilities||[]).includes(`audio.speech`)){t({error:`Voice samples are for Blocks that make speech (audio.speech).`});return}if(typeof s.voice!=`string`||!/^[a-z0-9_-]{1,64}$/.test(s.voice)){t({error:`Name a StillMade voice.`});return}Promise.resolve().then(()=>r(s.voice)).then(n=>{if(e){if(!(n instanceof Blob)||!/^audio\//.test(n.type))throw Error(`The voice sample could not be loaded.`);t({blob:n})}},n=>{e&&t({error:String(n?.message||`The voice sample could not be loaded.`).slice(0,1e3)})});return}if(s.op===`preview-image`||s.op===`preview-media`){let t=s.op===`preview-media`;if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=l)return;Qt(null),l=Number(s.id);let n=e=>Oe({op:t?`preview-media-result`:`preview-image-result`,id:s.id,...e}),r=Date.now();if(d=d.filter(e=>r-e<6e4),o&&hn(),d.length>=OH.imagePreviewsPerMinute){++h<=3&&n({error:`Image preview limit reached. Wait a minute before trying again.`}),h===4&&(un(`Preview paused after too many image requests. Reset it to continue.`),e=!1,hn(),i?.abort(),ue.current&&(ue.current.src=`about:blank`));return}d.push(r);let c=t||s.edge===void 0?void 0:s.edge;if(c!==void 0&&!(Number.isInteger(c)&&c>=64&&c<=OH.imagePreviewMaxEdge)){n({error:`Ask for an image preview edge from 64 to ${OH.imagePreviewMaxEdge} pixels.`});return}let u;try{if(u=t?wq(s.value):Aq(s.value),t&&(!vt(u)||![`image`,`video`,`audio`].includes(u.kind)||![`assetId`,`versionId`,`url`].every(e=>typeof u[e]==`string`&&u[e].length>0&&u[e].length<=32768)))throw Error(`Keep the complete picture, audio or video reference supplied by this workspace.`)}catch(e){n({error:e.message});return}let f=t&&Zn(u),p=f?(e,t)=>Jn({kind:`audio`,url:e.url},t):t&&b?.authorizesMedia?.(u)?(e,t)=>Jn(e,t):t?de.current.onPreviewMedia:de.current.onPreviewImage;if(typeof p!=`function`){n({error:t?`Audio/video preview is unavailable in this workspace.`:`Image preview is unavailable in this workspace. Choose an image with the host controls.`});return}let m=new AbortController,g=Ft.current,_={controller:m,id:s.id,media:t};o=_;let v=It.current,y=a,x=Mt(),S=()=>{if(m.signal.aborted||x!==Mt()||v!==It.current||Object.keys(g).some(e=>g[e]!==Ft.current[e]))throw Error(`Image preview input or workspace changed.`)},C=setTimeout(()=>{e&&o===_&&hn(`Image preview timed out. Try a smaller image.`)},OH.imagePreviewMs);m.signal.addEventListener(`abort`,()=>clearTimeout(C),{once:!0}),Promise.resolve().then(()=>(S(),p(u,{signal:m.signal,...c?{edge:c}:{}}))).then(r=>{if(e&&!m.signal.aborted&&o===_){if(S(),t&&r?.kind!==u.kind)throw Error(`The host returned a different media kind.`);let e=t?Kn(r):jq(r,c);S(),!f&&typeof u.assetId==`string`&&u.assetId.length<=512&&typeof u.versionId==`string`&&u.versionId.length<=512&&Qt({actor:y,runtimeActor:x,identity:v,session:mt.session,authority:g,evidence:{assetId:u.assetId,versionId:u.versionId,kind:t?e.kind:`image`,mime:t?e.blob.type:e.url.startsWith(`data:image/jpeg`)?`image/jpeg`:`image/png`,...t?{byteLength:e.blob.size}:{width:e.width,height:e.height},status:`broker-loaded`}}),n({preview:e})}},t=>{e&&!m.signal.aborted&&o===_&&n({error:String(t?.message||`This image could not be previewed`).slice(0,1e3)})}).catch(t=>{e&&!m.signal.aborted&&o===_&&n({error:String(t?.message||`This image could not be previewed`).slice(0,1e3)})}).finally(()=>{clearTimeout(C),o===_&&(o=null)});return}if(s.op!==`run`||typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=c)return;c=Number(s.id);let y=e=>Oe({op:`result`,id:s.id,...e});if(z&&!bt.current?.canEdit){y({error:`Shared editing is unavailable or read only.`});return}let C=Date.now();if(u=u.filter(e=>C-e<6e4),i||u.length>=OH.runsPerMinute){++m<=3&&y({error:i?`A run is already in progress`:`Preview run limit reached. Wait a minute before trying again.`}),m===4&&(un(`Preview paused after too many requests. Reset it to continue.`),e=!1,hn(),i?.abort(),ue.current&&(ue.current.src=`about:blank`));return}let w;try{if(!vt(s.input))throw Error(`Expected input values`);w=wq(s.input)}catch(e){y({error:e.message});return}u.push(C),me(``);let P=new AbortController;i=P,qe.current=!0,et?.context.signal?.addEventListener(`abort`,()=>P.abort(),{once:!0});let I=setTimeout(()=>{e&&i===P&&(P.abort(),i=null,y({error:ce?`Preview confirmation or execution timed out. Cancellation was requested; the backend may still be finishing.`:`Preview execution timed out. Try a smaller input.`}))},ce?le:15e3);P.signal.addEventListener(`abort`,()=>clearTimeout(I),{once:!0});let ee=et?.op===`dispatch-view-control`?et:null,te=ee?async e=>{if(et!==ee||i!==P||P.signal.aborted||!vt(e)||e.receipt?.status!==`completed`||e.receipt.saved!==!0||ht(e.taskFence)!==ht(ee.context.taskFence)||ht([e.projectId,e.placementId,e.sourceDigest,e.actorId])!==st||ht(wq(e.beforeInput))!==ee.inputIdentity)throw Error(`The native input commit does not match this active declared action.`);let t=ht(wq(e.input));for(let e=0;e<25&&fe.current.signature!==t;e++)if(ct(ee.context,t),await new Promise(e=>setTimeout(e,10)),et!==ee||i!==P||P.signal.aborted)throw Error(`The native input commit was stopped before its render.`);if(ct(ee.context,t),fe.current.signature!==t)throw Error(`The native input commit does not match the current rendered inputs.`);ee.inputIdentity=t}:void 0,R=vt(s.gesture)&&Number.isInteger(s.gesture.id)&&s.gesture.id>0&&Number.isFinite(s.gesture.age)&&s.gesture.age>=0&&s.gesture.age<=uq&&!g.has(s.gesture.id)&&!!globalThis.navigator?.userActivation?.isActive&&globalThis.document.activeElement===ue.current&&Date.now()-_>uq&&Date.now()-v>uq;R&&(g.add(s.gesture.id),v=Date.now()),Promise.resolve().then(()=>de.current.onRun(w,{...ut(),signal:P.signal,userActivated:R,...te?{onInputCommitted:te}:{},...ae?.manifest?.desktopTools?.length?{nativeDesktopSession:b}:{}})).then(t=>{if(e&&!P.signal.aborted){if(!vt(t))throw Error(`Block execution must return named outputs`);let e=wq(t);En(e),y({outputs:e})}},t=>{e&&!P.signal.aborted&&y({error:String(t?.message||`The Block could not run`).slice(0,1e3)})}).catch(t=>{e&&!P.signal.aborted&&y({error:String(t.message).slice(0,1e3)})}).finally(()=>{clearTimeout(I),i===P&&(i=null),qe.current=!1,setTimeout(()=>{e&&!qe.current&&Xe()},250)})};return window.addEventListener(`message`,Dn),()=>{clearTimeout(N),I?.abort(),ee&&de.current.onRunPriced?.(null),Nt.current=null,D?.picker.cancel(),globalThis.document.removeEventListener(`fullscreenchange`,we),Se&&globalThis.document.fullscreenElement===Se&&Promise.resolve(globalThis.document.exitFullscreen?.()).catch(()=>{}),Se=null,Tt.current=null,Fe(null,null),Ye?.();for(let e of[...Le.values()])e(null);tt&&=(clearTimeout(tt.timer),tt.context.signal?.removeEventListener(`abort`,tt.abort),tt.reject(Error(`Original text closed; retain its pending request.`)),null),globalThis.document.removeEventListener(`pointerdown`,y,!0),globalThis.document.removeEventListener(`keydown`,y,!0),Ht.current=null,lt(Error(`The declared interface was closed.`)),Ut.current=null,$t?.(),en?.(),clearTimeout(Bt),wn(),xn&&=(clearTimeout(xn.timer),xn.reject(Error(`Block closed before pending edits were confirmed.`)),null),clearTimeout(mn),clearInterval(se),_e?.disconnect(),Oe({op:`dispose`}),e=!1,b.close(),ye.current===b&&(ye.current=null),be.current===De&&(be.current=null),hn(),i?.abort(),qe.current=!1,window.removeEventListener(`message`,Dn),window.removeEventListener(`stillmade:cursor-preferences`,rn),window.removeEventListener(`storage`,rn),window.removeEventListener(aU.control,ln),cn(),Dt.current=null,jt.current=null,Et.current=null}},[mt,at,ce,le,F,r,a,Qe,$e]),(0,v.useEffect)(()=>{jt.current?.()},[t]),(0,v.useEffect)(()=>{Nt.current?.()},[O]),(0,v.useEffect)(()=>{Et.current?.(),Nt.current?.(),n?.canEdit===!1&&Promise.resolve(ye.current?.close()).catch(()=>{})},[n,at]),(0,v.useEffect)(()=>{Dt.current?.()},[i,r,a,n]),(0,v.useEffect)(()=>{At.current?.()},[ee,Ve]);let $t=!!globalThis.stillmadeDesktop?.blockDesktop,en=z?.camera&&z?.microphone?`camera and microphone`:z?.camera?`camera`:`microphone`;return(0,V.jsxs)(`div`,{className:`bs-sandbox-ui`,style:{position:`relative`},children:[z?.kind===`live`&&z.awaitingStart&&(0,V.jsxs)(`div`,{className:`bs-notice`,role:`status`,children:[(0,V.jsx)(`p`,{children:`Ready to share your ${en} live with this Block. It receives nothing until you press Start, and nothing is saved.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:z.start,children:`Start ${en}`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ye.current?.close(),children:`Cancel`})]}),z?.kind===`live`&&z.active&&(0,V.jsxs)(`div`,{role:`status`,className:`bs-notice`,children:[(0,V.jsx)(`strong`,{children:`${en[0].toUpperCase()}${en.slice(1)} on`}),(0,V.jsx)(`span`,{children:` · Shared live with this Block. Nothing is saved.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:z.stop,children:`Turn off ${en}`})]}),z?.awaitingStart&&(z.kind===`folder`||z.kind===`folder-access`)&&(0,V.jsxs)(`div`,{className:`bs-notice`,role:`status`,children:[(0,V.jsx)(`p`,{children:z.kind===`folder`?`This Block asks for a folder to ${z.write?`read and change`:`read`}. It reaches only the folder you choose.`:`Allow StillMade to use ${z.folder} again for this Block.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:z.start,children:z.kind===`folder`?`Choose folder`:`Allow`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>z.cancel?z.cancel():ye.current?.close(),children:`Cancel`})]}),z?.awaitingStart&&![`live`,`folder`,`folder-access`].includes(z.kind)&&(0,V.jsxs)(`div`,{className:`bs-notice`,role:`status`,children:[(0,V.jsx)(`p`,{children:z.kind===`camera`?`Ready to record your camera. This Block records only after you press Start.`:z.kind===`microphone`?`Ready to record your microphone. This Block records only after you press Start.`:z.microphone?`Ready to record your screen with your microphone. Choose your screen or window after pressing Start.`:`Ready to record. Choose your screen or window after pressing Start.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:z.start,children:z.kind===`camera`?`Start camera recording`:z.kind===`microphone`?`Start microphone recording`:`Start screen recording`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ye.current?.close(),children:`Cancel`})]}),z?.active&&z.kind!==`live`&&(0,V.jsxs)(`div`,{role:`status`,className:`bs-notice`,children:[(0,V.jsxs)(`strong`,{children:[z.ended?`Recording stopped`:`Recording`,` `,z.kind||`media`]}),(0,V.jsxs)(`span`,{children:[` · `,z.ended?z.message:$t?`This Block has temporary desktop access.`:`Recording runs in StillMade, outside the Block.`]}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ye.current?.close(),children:$t?`Cancel recording and revoke access`:`Discard recording`})]}),$t&&z?.closed&&ae?.manifest?.permissions?.desktop?.length>0&&(0,V.jsx)(`button`,{type:`button`,className:`btn`,disabled:!at||!bt.current?.canEdit,onClick:()=>be.current?.(),children:`Reopen desktop access`}),$t&&!z?.closed&&!z?.active&&ae?.manifest?.permissions?.desktop?.length>0&&(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ye.current?.close(),children:`Revoke this Block’s desktop access`}),mt.loading?(0,V.jsx)(Sr,{label:`Loading the interface…`}):mt.error?(0,V.jsxs)(`p`,{role:`alert`,children:[`This interface cannot be previewed: `,mt.error]}):at?(0,V.jsxs)(V.Fragment,{children:[he&&!pe&&(0,V.jsx)(`p`,{className:`sm-status`,"data-state":`loading`,role:`status`,children:`Opening this Block…`}),(0,V.jsx)(`iframe`,{ref:ue,onLoad:()=>{St.current.session!==mt.session&&(St.current={session:mt.session,count:0}),++St.current.count>2&&Ct.current?.()},title:N,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,src:`${x(`/block-ui-sandbox.html`)}#${mt.session}`,style:{width:`100%`,height:F&&we||P,minHeight:280,border:`1px solid var(--border-tok)`,borderRadius:`var(--r-3)`,background:`var(--bg)`,...pe&&!tt?{display:`none`}:{}}},mt.session),(0,V.jsx)(`span`,{ref:wt,hidden:!0,"aria-hidden":`true`,"data-agent-control-anchor":``,style:{position:`absolute`,left:0,top:0,pointerEvents:`none`}})]}):(0,V.jsx)(`p`,{role:rt?.error?`alert`:`status`,children:rt?.error||`Checking Block safety…`}),Le?.count>0&&(Le.error?(0,V.jsx)(`p`,{role:`alert`,className:`bs-notice`,children:Le.error}):Le.dirty||Le.pending?(0,V.jsx)(`p`,{role:`status`,className:`bs-notice`,children:`Sharing changes…`}):null),ze?.count>0&&(ze.error||ze.dirty||ze.pending)?(0,V.jsxs)(`div`,{className:`bs-notice`,role:ze.error?`alert`:`status`,children:[(0,V.jsx)(`p`,{children:ze.error||`Saving shared text…`}),ze.error&&(0,V.jsx)(`p`,{children:`Your text is retained here. Copy it before leaving; reloading cannot safely recover an unacknowledged draft.`}),ze.retryable&&(0,V.jsx)(`button`,{type:`button`,className:`btn`,disabled:ze.pending>0||!bt.current?.canEdit,onClick:()=>ue.current?.contentWindow?.postMessage({channel:lq,session:mt.session,op:`text-retry`},`*`),children:`Retry save`})]}):null,(pe||rt?.error)&&(0,V.jsxs)(V.Fragment,{children:[pe&&!tt&&(0,V.jsx)(`p`,{role:`alert`,children:pe}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,disabled:et,onClick:()=>{et||ve(e=>e+1)},children:`Reload`})]}),(0,V.jsx)(Pq,{activity:Se,declaresFolders:(ae?.manifest?.permissions?.desktop||[]).includes(`folder.read`),session:ye})]})}ut();var Iq=50,Lq=new Intl.NumberFormat(void 0,{maximumFractionDigits:4});new Intl.NumberFormat(void 0,{maximumFractionDigits:1});var Rq=e=>e==null?``:typeof e==`number`?Lq.format(e):String(e);function zq(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}function Bq({value:e,label:t=`Table`}){let[n,r]=(0,v.useState)(0);if(!Ye(e))return(0,V.jsx)(`p`,{role:`alert`,children:`This result is not a valid table.`});let i=Math.max(1,Math.ceil(e.rows.length/Iq)),a=Math.min(n,i-1),o=e.rows.slice(a*Iq,a*Iq+Iq),s=e.columns.map(t=>e.rows.length>0&&e.rows.every(e=>e[t]===void 0||e[t]===null||typeof e[t]==`number`));return(0,V.jsxs)(`div`,{className:`bd-table`,children:[(0,V.jsx)(`div`,{className:`bd-table-scroll`,tabIndex:0,role:`region`,"aria-label":`${t}, ${e.rows.length} rows`,children:(0,V.jsxs)(`table`,{children:[(0,V.jsx)(`thead`,{children:(0,V.jsx)(`tr`,{children:e.columns.map(e=>(0,V.jsx)(`th`,{scope:`col`,children:e},e))})}),(0,V.jsx)(`tbody`,{children:o.map((t,n)=>(0,V.jsx)(`tr`,{children:e.columns.map((e,n)=>(0,V.jsx)(`td`,{className:s[n]?`bd-number`:void 0,children:Rq(t[e])},e))},a*Iq+n))})]})}),(0,V.jsxs)(`div`,{className:`bd-bar`,children:[(0,V.jsxs)(`span`,{children:[e.rows.length,` `,e.rows.length===1?`row`:`rows`,i>1?` · page ${a+1} of ${i}`:``]}),i>1&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:a===0,onClick:()=>r(a-1),children:`Previous`}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:a>=i-1,onClick:()=>r(a+1),children:`Next`})]}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>zq(new Blob([$e(e)],{type:`text/csv`}),`${t.replace(/[^\w-]+/g,`-`).toLowerCase()||`table`}.csv`),children:`Download CSV`})]})]})}Et(),ut();var Vq=new Set([`image`,`audio`,`video`]),Hq=e=>Vq.has(e?.kind)&&typeof e.url==`string`,Uq=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,Wq=e=>{let t=String(e).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)},Gq=50,Kq=e=>Object.keys(e).filter(t=>t!==`schemaVersion`&&e[t]!==void 0&&e[t]!==null&&e[t]!==``),qq=e=>{if(!vt(e))return e;let t=Kq(e);return t.length===1&&(Array.isArray(e[t[0]])||vt(e[t[0]]))?qq(e[t[0]]):e},Jq=e=>e===null||[`string`,`number`,`boolean`].includes(typeof e),Yq=e=>typeof e==`boolean`?e?`Yes`:`No`:String(e??``),Xq=e=>{let t=t=>/^start/i.test(t)?e.find(e=>/^end/i.test(e)&&e.slice(3).toLowerCase()===t.slice(5).toLowerCase()):void 0,n=new Set(e.map(t).filter(Boolean));return e.filter(e=>!n.has(e)).flatMap(e=>t(e)?[e,t(e)]:[e])};function Zq(e){if(e.length<2||!e.every(e=>vt(e)&&Kq(e).every(t=>Jq(e[t]))))return null;let t=Xq([...new Set(e.flatMap(Kq))]);if(!t.length||t.length>6)return null;let n={columns:t.map(Wq),rows:e.map(e=>Object.fromEntries(Kq(e).map(t=>[Wq(t),typeof e[t]==`boolean`?Yq(e[t]):e[t]])))};return Ye(n)?n:null}function Qq({value:e,renderMedia:t,depth:n=0}){let r=qq(e);if(Jq(r))return(0,V.jsx)(`span`,{children:Yq(r)});if(Hq(r))return t?.(r)??null;if(Ye(r))return(0,V.jsx)(Bq,{value:r,label:`Results`});if(Array.isArray(r)){if(!r.length)return(0,V.jsx)(`span`,{className:`sm-data-none`,children:`None`});let e=n<2&&!r.some(Hq)&&Zq(r);return e?(0,V.jsx)(Bq,{value:e,label:`Results`}):n>=3?(0,V.jsx)(`span`,{children:Uq(r.length,`item`)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`ul`,{className:`sm-data-list`,children:r.slice(0,Gq).map((e,r)=>(0,V.jsx)(`li`,{children:(0,V.jsx)(Qq,{value:e,renderMedia:t,depth:n+1})},r))}),r.length>Gq&&(0,V.jsxs)(`p`,{className:`sm-data-none`,children:[`And `,r.length-Gq,` more.`]})]})}if(!vt(r))return null;let i=Kq(r);return i.length?n>=3?(0,V.jsx)(`span`,{children:Uq(i.length,`detail`)}):(0,V.jsx)(`dl`,{className:`sm-data-record`,children:i.map(e=>(0,V.jsxs)(v.Fragment,{children:[(0,V.jsx)(`dt`,{children:Wq(e)}),(0,V.jsx)(`dd`,{children:(0,V.jsx)(Qq,{value:r[e],renderMedia:t,depth:n+1})})]},e))}):(0,V.jsx)(`span`,{className:`sm-data-none`,children:`None`})}var $q=[`M3 8V5a2 2 0 0 1 2-2h3M16 3h3a2 2 0 0 1 2 2v3M21 16v3a2 2 0 0 1-2 2h-3M8 21H5a2 2 0 0 1-2-2v-3`,`M6.5 12s2.2-3.8 5.5-3.8 5.5 3.8 5.5 3.8-2.2 3.8-5.5 3.8S6.5 12 6.5 12Z`],eJ={cx:12,cy:12,r:1.8},tJ=[`M10.3 17.5H4.5a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2h13a2 2 0 0 1 2 2v7.7`,`M2.5 7h17M6 5.25h10`,`M6 9.5h4a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1Z`,`M5.3 14.2l2.2-2.4 1.6 1.5 1.1-1M13.5 10h3.5M13.5 12.3h2`,`M12 18s2-3.2 5.5-3.2S23 18 23 18s-2 3.2-5.5 3.2S12 18 12 18Z`],nJ={cx:17.5,cy:18,r:1.3};function rJ(e){switch(e){case`minus`:return(0,V.jsx)(`path`,{d:`M5 12h14`});case`messageCircle`:return(0,V.jsx)(`path`,{d:`M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8z`});case`arrowLeft`:return(0,V.jsx)(`path`,{d:`M20 12H4M11 5l-7 7 7 7`});case`link`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M10 13a5 5 0 0 0 7 .5l3-3a5 5 0 0 0-7-7l-2 2`}),(0,V.jsx)(`path`,{d:`M14 11a5 5 0 0 0-7-.5l-3 3a5 5 0 0 0 7 7l2-2`})]});case`unlink`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`m18.8 12.3 1.7-1.7a5 5 0 0 0-7.1-7.1l-1.7 1.7`}),(0,V.jsx)(`path`,{d:`m5.2 11.7-1.7 1.7a5 5 0 0 0 7.1 7.1l1.7-1.7`}),(0,V.jsx)(`path`,{d:`M8 2v3M2 8h3M16 19v3M19 16h3`})]});case`copy`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`9`,y:`9`,width:`12`,height:`12`,rx:`2`}),(0,V.jsx)(`path`,{d:`M15 9V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4`})]});case`arrowUp`:return(0,V.jsx)(`path`,{d:`M12 20V4M5 11l7-7 7 7`});case`star`:return(0,V.jsx)(`path`,{d:`M12 3.5l2.6 5.3 5.9.9-4.25 4.15 1 5.85L12 16.95 6.75 19.7l1-5.85L3.5 9.7l5.9-.9z`});case`arrowUpRight`:return(0,V.jsx)(`path`,{d:`M7 17 17 7M8 7h9v9`});case`arrowDown`:return(0,V.jsx)(`path`,{d:`M12 4v16M5 13l7 7 7-7`});case`thumbsUp`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M7 10v11H3V10Z`}),(0,V.jsx)(`path`,{d:`M7 18c2 0 3 3 7 3h2.5a2 2 0 0 0 1.9-1.4l2.4-7A2 2 0 0 0 18.9 10H14l.7-3.5A3 3 0 0 0 11.8 3L7 10Z`})]});case`thumbsDown`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M7 14V3H3v11Z`}),(0,V.jsx)(`path`,{d:`M7 6c2 0 3-3 7-3h2.5a2 2 0 0 1 1.9 1.4l2.4 7a2 2 0 0 1-1.9 2.6H14l.7 3.5a3 3 0 0 1-2.9 3.5L7 14Z`})]});case`undo`:return(0,V.jsx)(`path`,{d:`M3 10h11a7 7 0 0 1 0 14M3 10l5-5M3 10l5 5`,transform:`translate(0 -3)`});case`redo`:return(0,V.jsx)(`path`,{d:`M21 7H10a7 7 0 0 0 0 14M21 7l-5-5M21 7l-5 5`});case`remix`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M5 5h5a5 5 0 0 1 5 5v9`}),(0,V.jsx)(`path`,{d:`m11 15 4 4 4-4`}),(0,V.jsx)(`path`,{d:`M5 19h2`}),(0,V.jsx)(`circle`,{cx:`5`,cy:`5`,r:`2`}),(0,V.jsx)(`circle`,{cx:`5`,cy:`19`,r:`2`})]});case`more`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,V.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1`})]});case`palette`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`13.5`,cy:`6.5`,r:`.6`,fill:`currentColor`,stroke:`none`}),(0,V.jsx)(`circle`,{cx:`17`,cy:`11`,r:`.6`,fill:`currentColor`,stroke:`none`}),(0,V.jsx)(`circle`,{cx:`8.5`,cy:`7.5`,r:`.6`,fill:`currentColor`,stroke:`none`}),(0,V.jsx)(`circle`,{cx:`6.5`,cy:`12.5`,r:`.6`,fill:`currentColor`,stroke:`none`}),(0,V.jsx)(`path`,{d:`M12 3a9 9 0 0 0 0 18c1 0 1.6-.8 1.6-1.6 0-.5-.2-.8-.4-1.1-.3-.3-.4-.6-.4-1.1A1.6 1.6 0 0 1 14.3 15h1.9A4.8 4.8 0 0 0 21 10.2C21 6 16.9 3 12 3Z`})]});case`lock`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`5`,y:`11`,width:`14`,height:`10`,rx:`2`}),(0,V.jsx)(`path`,{d:`M8 11V7a4 4 0 0 1 8 0v4`})]});case`unlock`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`5`,y:`11`,width:`14`,height:`10`,rx:`2`}),(0,V.jsx)(`path`,{d:`M8 11V7a4 4 0 0 1 7.9-1`})]});case`pushpin`:return(0,V.jsxs)(`g`,{transform:`rotate(35 12 12)`,children:[(0,V.jsx)(`path`,{d:`M8 3h8l-1 6 3 3v2H6v-2l3-3Z`}),(0,V.jsx)(`path`,{d:`M12 14v7`})]});case`pushpinFilled`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M8 3h8l-1 6 3 3v2H6v-2l3-3Z`,fill:`currentColor`}),(0,V.jsx)(`path`,{d:`M12 14v7`})]});case`pin`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 21s7-5.7 7-11a7 7 0 0 0-14 0c0 5.3 7 11 7 11Z`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`10`,r:`2.5`})]});case`user`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`8`,r:`4`}),(0,V.jsx)(`path`,{d:`M5 21a7 7 0 0 1 14 0`})]});case`image`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),(0,V.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`1.5`}),(0,V.jsx)(`path`,{d:`m21 15-5-5L5 21`})]});case`imageOff`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M2 2l20 20`}),(0,V.jsx)(`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`}),(0,V.jsx)(`path`,{d:`M13.5 13.5 6 21`}),(0,V.jsx)(`path`,{d:`m18 12 3 3`}),(0,V.jsx)(`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`}),(0,V.jsx)(`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`})]});case`film`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),(0,V.jsx)(`path`,{d:`M7 3v18M17 3v18M3 8h4M3 16h4M17 8h4M17 16h4`})]});case`folder`:return(0,V.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`});case`list`:return(0,V.jsx)(`path`,{d:`M9 6h12M9 12h12M9 18h12M4 6h.01M4 12h.01M4 18h.01`});case`grid`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,V.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,V.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,V.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]});case`zap`:return(0,V.jsx)(`path`,{d:`M13 2 4 14h7l-1 8 9-12h-7Z`});case`plug`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 22v-5M9 8V2M15 8V2`}),(0,V.jsx)(`path`,{d:`M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z`})]});case`book`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,V.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2Z`})]});case`bookOpen`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 7v14`}),(0,V.jsx)(`path`,{d:`M3 5v14h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6V5h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3Z`})]});case`input`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`}),(0,V.jsx)(`path`,{d:`m10 17 5-5-5-5`}),(0,V.jsx)(`path`,{d:`M15 12H3`})]});case`upload`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 16V4M7 9l5-5 5 5`}),(0,V.jsx)(`path`,{d:`M5 20h14`})]});case`download`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 4v12M7 11l5 5 5-5`}),(0,V.jsx)(`path`,{d:`M5 20h14`})]});case`save`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M5 3h11l3 3v15H5Z`}),(0,V.jsx)(`path`,{d:`M8 3v5h7M8 21v-7h8v7`})]});case`search`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,V.jsx)(`path`,{d:`m20 20-3.5-3.5`})]});case`magnet`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M6 4h4v8a2 2 0 0 0 4 0V4h4v8a6 6 0 0 1-12 0Z`}),(0,V.jsx)(`path`,{d:`M6 8h4M14 8h4`})]});case`bot`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`4`,y:`8`,width:`16`,height:`11`,rx:`2`}),(0,V.jsx)(`path`,{d:`M12 8V4M9 13h.01M15 13h.01M9 16h6`})]});case`note`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`4`,y:`3`,width:`16`,height:`18`,rx:`2`}),(0,V.jsx)(`path`,{d:`M8 8h8M8 12h8M8 16h5`})]});case`clock`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`path`,{d:`M12 7v5l3 2`})]});case`calendar`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,V.jsx)(`path`,{d:`M16 3v4M8 3v4M3 10h18`})]});case`hourglass`:return(0,V.jsx)(`path`,{d:`M6 3h12M6 21h12M7 3c0 5 5 6 5 9s-5 4-5 9M17 3c0 5-5 6-5 9s5 4 5 9`});case`edit`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 20h9`}),(0,V.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]});case`music`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M9 18V5l12-2v13`}),(0,V.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,V.jsx)(`circle`,{cx:`18`,cy:`16`,r:`3`})]});case`mic`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`}),(0,V.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),(0,V.jsx)(`path`,{d:`M12 19v3`})]});case`target`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`5`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`})]});case`pointer`:return(0,V.jsx)(`path`,{d:`M4.5 3.5 20 10.4l-6.5 1.9a1.9 1.9 0 0 0-1.3 1.3L10.3 20z`,strokeLinejoin:`round`});case`sprout`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 21V9`}),(0,V.jsx)(`path`,{d:`M12 9C9 9 6 7 6 4c3 0 6 2 6 5ZM12 12c3 0 6-2 6-5-3 0-6 2-6 5Z`})]});case`hand`:return(0,V.jsx)(`path`,{d:`M8 13V5a1.5 1.5 0 0 1 3 0v6M11 11V4a1.5 1.5 0 0 1 3 0v7M14 11V6a1.5 1.5 0 0 1 3 0v8a6 6 0 0 1-6 6h-1a6 6 0 0 1-5.2-3l-2-3.5a1.5 1.5 0 0 1 2.6-1.5L8 14`});case`scissors`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2.5`}),(0,V.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2.5`}),(0,V.jsx)(`path`,{d:`M8 8l12 8M8 16 20 8`})]});case`maximize`:return(0,V.jsx)(`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M21 16v3a2 2 0 0 1-2 2h-3M3 16v3a2 2 0 0 0 2 2h3`});case`settings`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,V.jsx)(`path`,{d:`M19.4 15a1.6 1.6 0 0 0 .3 1.8 2 2 0 1 1-2.8 2.8 1.6 1.6 0 0 0-1.8-.3 1.6 1.6 0 0 0-1 1.5 2 2 0 1 1-4 0 1.6 1.6 0 0 0-1-1.5 1.6 1.6 0 0 0-1.8.3 2 2 0 1 1-2.8-2.8 1.6 1.6 0 0 0 .3-1.8 1.6 1.6 0 0 0-1.5-1 2 2 0 1 1 0-4 1.6 1.6 0 0 0 1.5-1 1.6 1.6 0 0 0-.3-1.8 2 2 0 1 1 2.8-2.8 1.6 1.6 0 0 0 1.8.3H9a1.6 1.6 0 0 0 1-1.5 2 2 0 1 1 4 0 1.6 1.6 0 0 0 1 1.5 1.6 1.6 0 0 0 1.8-.3 2 2 0 1 1 2.8 2.8 1.6 1.6 0 0 0-.3 1.8V9a1.6 1.6 0 0 0 1.5 1 2 2 0 1 1 0 4 1.6 1.6 0 0 0-1.5 1Z`})]});case`scale`:return(0,V.jsx)(`path`,{d:`M12 3v18M7 21h10M6 7h12M6 7 3 14h6ZM18 7l-3 7h6ZM3 14a3 3 0 0 0 6 0M15 14a3 3 0 0 0 6 0`});case`checkbox`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),(0,V.jsx)(`path`,{d:`m8 12 3 3 5-6`})]});case`warning`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M10.3 4 2.6 17a2 2 0 0 0 1.7 3h15.4a2 2 0 0 0 1.7-3L13.7 4a2 2 0 0 0-3.4 0Z`}),(0,V.jsx)(`path`,{d:`M12 9v4M12 17h.01`})]});case`sparkle`:return(0,V.jsx)(`path`,{d:`M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8Z`});case`check`:return(0,V.jsx)(`path`,{d:`m5 12 5 5 9-10`});case`x`:return(0,V.jsx)(`path`,{d:`M6 6 18 18M18 6 6 18`});case`plus`:return(0,V.jsx)(`path`,{d:`M12 5v14M5 12h14`});case`refresh`:return(0,V.jsx)(`path`,{d:`M3 12a9 9 0 0 1 15-6.7L21 8M21 3v5h-5M21 12a9 9 0 0 1-15 6.7L3 16M3 21v-5h5`});case`play`:return(0,V.jsx)(`path`,{d:`M7 4v16l13-8Z`});case`preview`:return(0,V.jsxs)(V.Fragment,{children:[$q.map(e=>(0,V.jsx)(`path`,{d:e},e)),(0,V.jsx)(`circle`,{...eJ})]});case`listingPreview`:return(0,V.jsxs)(V.Fragment,{children:[tJ.map(e=>(0,V.jsx)(`path`,{d:e},e)),(0,V.jsx)(`circle`,{...nJ})]});case`pause`:return(0,V.jsx)(`path`,{d:`M9 5v14M15 5v14`});case`playFilled`:return(0,V.jsx)(`path`,{d:`M7 4.6v14.8c0 .8.9 1.2 1.5.8l11.4-7.4a1 1 0 0 0 0-1.6L8.5 3.8C7.9 3.4 7 3.8 7 4.6Z`,fill:`currentColor`,stroke:`none`});case`pauseFilled`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`6`,y:`4.5`,width:`4`,height:`15`,rx:`1`,fill:`currentColor`,stroke:`none`}),(0,V.jsx)(`rect`,{x:`14`,y:`4.5`,width:`4`,height:`15`,rx:`1`,fill:`currentColor`,stroke:`none`})]});case`volume2`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4V5Z`,fill:`currentColor`}),(0,V.jsx)(`path`,{d:`M15.5 8.5a5 5 0 0 1 0 7M19 5a10 10 0 0 1 0 14`})]});case`volumeX`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4V5Z`,fill:`currentColor`}),(0,V.jsx)(`path`,{d:`m22 9-6 6M16 9l6 6`})]});case`minimize`:return(0,V.jsx)(`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3M21 8h-3a2 2 0 0 1-2-2V3M3 16h3a2 2 0 0 1 2 2v3M16 21v-3a2 2 0 0 1 2-2h3`});case`stop`:return(0,V.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`});case`chevronRight`:return(0,V.jsx)(`path`,{d:`m9 6 6 6-6 6`});case`chevronLeft`:return(0,V.jsx)(`path`,{d:`m15 6-6 6 6 6`});case`chevronDown`:return(0,V.jsx)(`path`,{d:`m6 9 6 6 6-6`});case`trash`:return(0,V.jsx)(`path`,{d:`M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13`});case`layers`:return(0,V.jsx)(`path`,{d:`m12 3 9 5-9 5-9-5Zm9 9-9 5-9-5m18 4-9 5-9-5`});case`type`:return(0,V.jsx)(`path`,{d:`M4 6V4h16v2M12 4v16M9 20h6`});case`home`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M3 10.5 12 3l9 7.5`}),(0,V.jsx)(`path`,{d:`M5 9.5V20a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9.5`}),(0,V.jsx)(`path`,{d:`M9 21v-6h6v6`})]});case`menu`:return(0,V.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h16`});case`logout`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,V.jsx)(`path`,{d:`M16 17l5-5-5-5`}),(0,V.jsx)(`path`,{d:`M21 12H9`})]});case`help`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`path`,{d:`M9.1 9a3 3 0 0 1 5.8 1c0 2-3 3-3 3`}),(0,V.jsx)(`path`,{d:`M12 17h.01`})]});case`bug`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`m8 2 1.9 1.9M14.1 3.9 16 2`}),(0,V.jsx)(`path`,{d:`M9 7.1v-1a3 3 0 1 1 6 0v1`}),(0,V.jsx)(`path`,{d:`M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6`}),(0,V.jsx)(`path`,{d:`M12 20v-9`}),(0,V.jsx)(`path`,{d:`M6.5 9C4.6 8.8 3 7.1 3 5M6 13H2M3 21c0-2.1 1.7-3.9 3.8-4M21 5c0 2.1-1.6 3.8-3.5 4M22 13h-4M17.2 17c2.1.1 3.8 1.9 3.8 4`})]});default:return null}}function iJ({name:e,size:t=`1em`,style:n,className:r,strokeWidth:i=1.5}){let a=rJ(e);return a?(0,V.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:i,strokeLinecap:`round`,strokeLinejoin:`round`,className:r,style:{display:`inline-block`,verticalAlign:`-0.14em`,flexShrink:0,...n||{}},"aria-hidden":`true`,children:a}):null}function aJ(e,t){let n=(0,v.useRef)(t),r=wU(e),[i,a]=(0,v.useState)(null);return n.current=t,(0,v.useEffect)(()=>{if(!r)return;let t=!0;return Promise.resolve().then(()=>n.current?.(e)).then(n=>{t&&a({src:e,url:n||null})},()=>{t&&a({src:e,url:null})}),()=>{t=!1}},[e,r]),r?i?.src===e?{url:i.url,missing:!i.url}:{url:null,missing:!1}:{url:e||null,missing:!1}}function oJ({src:e,resolveUrl:t,label:n,"aria-label":r,fill:i=!1,className:a,style:o,onMissing:s,controls:c,playsInline:l,preload:u=`metadata`,...d}){let{url:f,missing:p}=aJ(e,t),m=(0,v.useRef)(null),h=(0,v.useRef)(null),g=(0,v.useRef)(null),_=(0,v.useRef)(s);return _.current=s,(0,v.useEffect)(()=>{if(p){_.current?.(e);return}let t=EU(g.current,{root:m.current,ui:h.current});return()=>t?.destroy()},[p]),p?(0,V.jsx)(`span`,{role:`img`,className:a?`sm-player-off ${a}`:`sm-player-off`,"aria-label":`On another device`,title:`On another device`,children:(0,V.jsx)(iJ,{name:`imageOff`,size:24})}):(0,V.jsxs)(`div`,{ref:m,className:a?`sm-player ${a}`:`sm-player`,style:o,"data-mode":`dark`,"data-fill":i?``:void 0,tabIndex:0,role:`group`,"aria-label":n||r||`Video`,children:[(0,V.jsx)(`video`,{ref:g,src:f||void 0,preload:u,playsInline:!0,...d}),(0,V.jsx)(`div`,{ref:h,className:`sm-player-ui`})]})}var sJ=e=>String(e).padStart(2,`0`),cJ=/^(\d{4})-(\d{2})-(\d{2})$/,lJ=/^([01]\d|2[0-3]):([0-5]\d)$/,uJ=e=>{let t=cJ.exec(e||``);return t?{year:+t[1],month:+t[2],day:+t[3]}:null},dJ=e=>{let t=uJ(e);return!!t&&new Date(Date.UTC(t.year,t.month-1,t.day)).toISOString().slice(0,10)===e},fJ=e=>{let{year:t,month:n,day:r}=uJ(e);return new Date(Date.UTC(t,n-1,r))},pJ=(e,t)=>{let n=fJ(e);return n.setUTCDate(n.getUTCDate()+t),n.toISOString().slice(0,10)},mJ=(e,t)=>{let{year:n,month:r,day:i}=uJ(e),a=new Date(Date.UTC(n,r-1+t,1)),o=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth()+1,0)).getUTCDate();return`${a.getUTCFullYear()}-${sJ(a.getUTCMonth()+1)}-${sJ(Math.min(i,o))}`},hJ=/(?:time|when|start|schedule|post|send|publish|remind)/i,gJ=(e,t,n)=>typeof n==`string`&&n.includes(`T`)||hJ.test(e||``)||/(?:At|_at)$/.test(e||``)||/\b(?:time|when|starts?|at)\b/i.test(t||``),_J=e=>`${yJ(e.slice(0,10))}${e[10]===`T`?` · ${bJ(e.slice(11,16))}`:``}`;function vJ({utc:e=!1,now:t=new Date}={}){return e?t.toISOString().slice(0,10):`${t.getFullYear()}-${sJ(t.getMonth()+1)}-${sJ(t.getDate())}`}function yJ(e,t=vJ()){return fJ(e).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,...e.slice(0,4)===t.slice(0,4)?{}:{year:`numeric`},timeZone:`UTC`})}function bJ(e){let[t,n]=e.split(`:`).map(Number);return new Date(Date.UTC(2e3,0,1,t,n)).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,timeZone:`UTC`})}function xJ(e=30){return Array.from({length:Math.floor(1440/e)},(t,n)=>`${sJ(Math.floor(n*e/60))}:${sJ(n*e%60)}`)}function SJ(e,t,n,r){return(0,v.useEffect)(()=>{if(!e)return;let r=e=>{n.current?.contains(e.target)||t(!1)};return document.addEventListener(`pointerdown`,r),()=>document.removeEventListener(`pointerdown`,r)},[e]),n=>{n.key===`Escape`&&e&&(n.stopPropagation(),n.preventDefault(),t(!1),r.current?.focus())}}function CJ({value:e,onChange:t,min:n,max:r,utc:i=!1,disabled:a=!1,label:o=`Day`,placeholder:s=`Pick a day`,clearable:c=!1}){let[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=(0,v.useRef)(null),g=SJ(l,u,p,m),_=vJ({utc:i}),y=dJ(e)?e:null,b=e=>(!n||e>=n)&&(!r||e<=r),x=e=>n&&e<n?n:r&&e>r?r:e;(0,v.useEffect)(()=>{l&&d&&h.current?.querySelector(`[data-day="${d}"]`)?.focus()},[l,d]);let S=()=>{if(l){u(!1);return}f(x(y||_)),u(!0)},C=e=>{b(e)&&(t?.(e),u(!1),m.current?.focus())},w={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7},T=e=>{let t=null;if(w[e.key])t=pJ(d,w[e.key]);else if(e.key===`PageUp`||e.key===`PageDown`)t=mJ(d,e.key===`PageUp`?-1:1);else if(e.key===`Home`||e.key===`End`){let n=fJ(d).getUTCDay();t=pJ(d,e.key===`Home`?-n:6-n)}t!==null&&(e.preventDefault(),f(x(t)))},E=d||y||_,{year:D,month:O}=uJ(E),k=`${D}-${sJ(O)}-01`,A=new Date(Date.UTC(D,O,0)).getUTCDate(),j=fJ(k).getUTCDay(),M=fJ(k).toLocaleDateString(void 0,{month:`long`,year:`numeric`,timeZone:`UTC`}),N=pJ(k,-1),P=mJ(k,1),F=Array.from({length:A},(e,t)=>`${D}-${sJ(O)}-${sJ(t+1)}`);return(0,V.jsxs)(`span`,{className:`sm-when-pick`,ref:p,onKeyDown:g,children:[(0,V.jsxs)(`button`,{type:`button`,ref:m,className:`sm-when-button`,"aria-haspopup":`dialog`,"aria-expanded":l,"aria-label":`${o}: ${y?yJ(y,_):`not chosen`}`,disabled:a,onClick:S,children:[(0,V.jsx)(iJ,{name:`calendar`,size:16}),(0,V.jsx)(`span`,{children:y?yJ(y,_):s}),(0,V.jsx)(iJ,{name:`chevronDown`,size:13})]}),l&&(0,V.jsxs)(`div`,{className:`sm-when-pop sm-when-calendar`,role:`dialog`,"aria-label":`Pick a ${o.toLowerCase()}`,children:[(0,V.jsxs)(`div`,{className:`sm-when-cal-head`,children:[(0,V.jsx)(`b`,{children:M}),(0,V.jsxs)(`span`,{className:`sm-when-cal-nav`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":`Previous month`,title:`Previous month`,disabled:!!n&&N<n,onClick:()=>f(x(mJ(E,-1))),children:(0,V.jsx)(iJ,{name:`chevronLeft`,size:16})}),(0,V.jsx)(`button`,{type:`button`,"aria-label":`Next month`,title:`Next month`,disabled:!!r&&P>r,onClick:()=>f(x(mJ(E,1))),children:(0,V.jsx)(iJ,{name:`chevronRight`,size:16})})]})]}),(0,V.jsxs)(`div`,{className:`sm-when-cal-grid`,ref:h,onKeyDown:T,children:[[`S`,`M`,`T`,`W`,`T`,`F`,`S`].map((e,t)=>(0,V.jsx)(`i`,{"aria-hidden":`true`,children:e},t)),j>0&&(0,V.jsx)(`span`,{style:{gridColumn:`span ${j}`},"aria-hidden":`true`}),F.map(e=>(0,V.jsx)(`button`,{type:`button`,"data-day":e,tabIndex:e===d?0:-1,disabled:!b(e),"aria-pressed":e===y,"aria-current":e===_?`date`:void 0,"aria-label":fJ(e).toLocaleDateString(void 0,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`,timeZone:`UTC`}),onClick:()=>C(e),children:Number(e.slice(8))},e))]}),c&&y&&(0,V.jsx)(`button`,{type:`button`,className:`sm-quiet sm-when-clear`,onClick:()=>{t?.(``),u(!1),m.current?.focus()},children:`Clear`})]})]})}function wJ({value:e,onChange:t,min:n,step:r=30,disabled:i=!1,label:a=`Time`,placeholder:o=`Pick a time`}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(-1),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(null),m=(0,v.useId)(),h=SJ(s,c,d,f),g=lJ.test(e||``)?e:null,_=g&&!xJ(r).includes(g)?[...xJ(r),g].sort():xJ(r),y=e=>!n||e>=n;(0,v.useEffect)(()=>{s&&(p.current?.focus(),p.current?.querySelector(`[data-active="true"]`)?.scrollIntoView?.({block:`nearest`}))},[s,l]);let b=()=>{if(s){c(!1);return}let e=_.indexOf(g);u(e>=0?e:Math.max(0,_.findIndex(y))),c(!0)},x=e=>{y(e)&&(t?.(e),c(!1),f.current?.focus())};return(0,V.jsxs)(`span`,{className:`sm-when-pick`,ref:d,onKeyDown:h,children:[(0,V.jsxs)(`button`,{type:`button`,ref:f,className:`sm-when-button`,"aria-haspopup":`listbox`,"aria-expanded":s,"aria-label":`${a}: ${g?bJ(g):`not chosen`}`,disabled:i,onClick:b,children:[(0,V.jsx)(iJ,{name:`clock`,size:16}),(0,V.jsx)(`span`,{children:g?bJ(g):o}),(0,V.jsx)(iJ,{name:`chevronDown`,size:13})]}),s&&(0,V.jsx)(`ul`,{className:`sm-when-pop sm-when-times`,role:`listbox`,ref:p,tabIndex:-1,"aria-label":`Pick a ${a.toLowerCase()}`,"aria-activedescendant":l>=0?`${m}-${l}`:void 0,onKeyDown:e=>{let t=t=>{let n=t,r=e.key===`ArrowUp`||e.key===`End`?-1:1;for(;n>=0&&n<_.length&&!y(_[n]);)n+=r;return n>=0&&n<_.length?n:l};if(e.key===`ArrowDown`)u(t(l+1));else if(e.key===`ArrowUp`)u(t(l-1));else if(e.key===`Home`)u(t(0));else if(e.key===`End`)u(t(_.length-1));else if(e.key===`Enter`||e.key===` `)_[l]&&x(_[l]);else return;e.preventDefault()},children:_.map((e,t)=>(0,V.jsx)(`li`,{id:`${m}-${t}`,role:`option`,"aria-selected":e===g,"aria-disabled":!y(e)||void 0,"data-active":t===l||void 0,onPointerDown:e=>e.preventDefault(),onClick:()=>x(e),children:bJ(e)},e))})]})}function TJ({value:e,onChange:t,min:n,max:r,utc:i=!1,disabled:a=!1,label:o=`Date`,clearable:s=!1,defaultTime:c=`09:00`,step:l=30}){let u=dJ(e?.slice(0,10))?e.slice(0,10):``,d=lJ.test(e?.slice(11,16)||``)?e.slice(11,16):``,f=n?.slice(0,10)||void 0,p=f?n.slice(11,16):``,m=e=>e===f&&p?xJ(l).find(e=>e>=p)||p:null;return(0,V.jsxs)(`span`,{className:`sm-when-pickers`,children:[(0,V.jsx)(CJ,{value:u,onChange:e=>{if(!e){t?.(``);return}let n=m(e),r=d||c;n&&r<n&&(r=n),t?.(`${e}T${r}`)},min:f,max:r?.slice(0,10),utc:i,disabled:a,label:`${o} day`,clearable:s}),(0,V.jsx)(wJ,{value:d,onChange:e=>t?.(`${u||f||vJ({utc:i})}T${e}`),min:(u||f||vJ({utc:i}))===f&&p||void 0,step:l,disabled:a,label:`${o} time`})]})}var EJ=new Set([`image`,`image[]`,`video`,`video[]`,`audio`,`audio[]`,`asset`,`asset[]`,`file`]),DJ=3,OJ=e=>String(e||``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();function kJ(e){let t=String(e||``).trim();if(!t)return``;let n=(t.match(/^.+?[.!?](?=\s|$)/)||[t])[0].trim();return n.length<=160?n:``}function AJ(e,{inputs:t,labels:n={},groups:r=[]}={}){let i=t||Object.entries(e?.inputs||{}).filter(([,e])=>!e?.context),a=i.length>0&&i.length<=DJ&&!r.length,o=i.find(([,e])=>e?.required!==!1&&e?.primary)||i.find(([,e])=>e?.required!==!1)||i[0],s=o?OJ(n[o[0]]||o[1]?.label||o[0]):``;return{focused:a,heading:s?`Add your ${s}`:String(e?.action?.label||e?.name||``).trim(),line:kJ(e?.description),media:!!o&&EJ.has(o[1]?.type)}}var jJ=new Set([`text`,`script`,`transcript`,`brief`,`json`,`metadata`,`research`,`document`,`table`]),MJ=e=>{let t=String(e||``).replace(/\[\]$/,``);return jJ.has(t)?`text`:[`video`,`image`,`audio`].includes(t)?t:void 0},NJ=/^\s*(\d+(?:\.\d+)?)\s*[:/x]\s*(\d+(?:\.\d+)?)\s*$/;function PJ(e,{inputs:t={},aspectRatio:n}={}){let r=Object.entries(e?.outputs||{}).filter(([,e])=>!e?.context),i=(r.find(([,e])=>e?.primary)||r[0]||[])[1],a=MJ(i?.type);if(a!==`video`&&a!==`image`)return{kind:a};let o=Object.keys(e?.inputs||{}).find(e=>/aspect/i.test(e)),s=[o&&t[o],o&&e.inputs[o]?.default,n].find(e=>NJ.test(String(e||``))),c=NJ.exec(String(s||``));return{kind:a,ratio:c?`${c[1]}/${c[2]}`:a===`video`?`16/9`:`1/1`}}function FJ({kind:e,ratio:t,words:n=`Your result shows up here`}){return(0,V.jsxs)(`div`,{className:`sm-result-place`,"data-kind":e||`other`,children:[e===`text`&&(0,V.jsxs)(`span`,{className:`sm-result-lines`,"aria-hidden":`true`,children:[(0,V.jsx)(`i`,{}),(0,V.jsx)(`i`,{}),(0,V.jsx)(`i`,{}),(0,V.jsx)(`i`,{}),(0,V.jsx)(`i`,{}),(0,V.jsx)(`i`,{})]}),(e===`video`||e===`image`)&&(0,V.jsx)(`span`,{className:`sm-result-frame`,style:{aspectRatio:t},"aria-hidden":`true`,children:(0,V.jsx)(`span`,{className:`sm-glyph`,"data-glyph":e})}),e===`audio`&&(0,V.jsxs)(`span`,{className:`sm-result-audio`,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{className:`sm-glyph`,"data-glyph":`audio`}),(0,V.jsx)(`span`,{className:`sm-result-wave`,children:Array.from({length:24},(e,t)=>(0,V.jsx)(`i`,{},t))})]}),!e&&(0,V.jsx)(`span`,{className:`sm-glyph`,"data-glyph":`spark`,"aria-hidden":`true`}),(0,V.jsx)(`p`,{children:n})]})}var IJ=Object.freeze({video:`video`,image:`image`,audio:`audio file`,file:`file`,asset:`file`}),LJ=new Set([`video`,`videos`,`image`,`images`,`photo`,`photos`,`picture`,`audio`,`sound`,`file`,`files`,`media`,`asset`,`input`,`upload`,`source`]),RJ=Object.freeze({video:[`video`],image:[`image`],audio:[`audio`],file:[`file`],asset:[`image`,`video`,`audio`]}),zJ=e=>/^[aeiou]/i.test(e)?`an`:`a`;function BJ(e,t={},{label:n}={}){let r=String(n||e||``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_\-.]+/g,` `).trim(),i=IJ[t.type]||`file`,a=r.split(/\s+/).map(e=>/^[A-Z0-9]{2,}$/.test(e)?e:e.toLowerCase()).join(` `),o=!a||LJ.has(a)||a===i,s=rW(RJ[t.type]||[`file`]);return{title:o?i.charAt(0).toUpperCase()+i.slice(1):a.charAt(0).toUpperCase()+a.slice(1),drop:o?`Drop ${zJ(i)} ${i} here`:`Drop your ${a} here`,choose:`Choose ${zJ(i)} ${i}`,formats:t.type===`audio`?`${s}, or a video for its sound`:s}}var VJ=160,HJ=/\blines\b|\b(?:per|each|every|own|by)\s+line\b|\bline\s+(?:per|for each)\b|\bparagraphs?\b|\bbullet(?:s|ed)?\b/i,UJ=/\blists?\b/i,WJ=/\bcomma/i;function GJ(e,t,n){if(e?.type!==`text`)return!1;if(n?.multiline===!0||[t,e.default].some(e=>typeof e==`string`&&e.includes(`
2104
- `)))return!0;let r=String(e.description||``);return HJ.test(r)||UJ.test(r)&&!WJ.test(r)}function KJ(e,t,n){if(e?.type!==`text`||GJ(e,t,n)||t!=null&&(typeof t!=`string`||t.length>VJ))return!1;let r=String(e.description||``),i=Number(/\bup to (\d+) characters\b/i.exec(r)?.[1]),a=Number.isSafeInteger(e.maxLength)?e.maxLength:i;return Number.isFinite(a)&&a>0&&a<=VJ}dK(),bK();var qJ=[[`light`,`Light`],[`dark`,`Dark`],[`white`,`White`]],JJ=[[`full`,`Full width`,null],[`tablet`,`Tablet`,768],[`phone`,`Phone`,390]],YJ=new Set([`image`,`video`,`audio`,`file`]),XJ={image:`image`,video:`film`,audio:`music`,file:`image`},ZJ=e=>{let t;try{t=JSON.parse(e)}catch{return String(e)}return Array.isArray(t)?t.map(e=>e?.message===`Unknown manifest field`?`This SDK does not know the Block’s “${e.path}” setting. Update the SDK, then restart the preview.`:`${e?.path?`${e.path}: `:``}${e?.message||`Something is wrong with the Block.`}`).join(` `):String(e)},QJ={pdf:`application/pdf`,txt:`text/plain`,csv:`text/csv`,md:`text/markdown`,json:`application/json`,zip:`application/zip`},$J={image:`image/*`,video:`video/*`,audio:`audio/*`,file:Object.keys(QJ).map(e=>`.${e}`).join(`,`)};async function eY(e,t){if(t===`image`){let t=await createImageBitmap(e),n={width:t.width,height:t.height};return t.close?.(),n}if(t!==`video`&&t!==`audio`)return{};let n=URL.createObjectURL(e),r=document.createElement(t);try{r.preload=`metadata`,r.src=n,await new Promise((e,t)=>{r.onloadedmetadata=e,r.onerror=()=>t(Error(`This file does not play in the browser.`)),setTimeout(e,8e3)});let e=Number.isFinite(r.duration)&&r.duration>0?Math.round(r.duration*1e3)/1e3:void 0;return t===`video`?{...r.videoWidth?{width:r.videoWidth,height:r.videoHeight}:{},...e?{duration:e}:{}}:e?{duration:e}:{}}finally{URL.revokeObjectURL(n)}}async function tY(e,t){let n=e.name.split(`.`).pop().toLowerCase(),r=t===`file`?QJ[n]||e.type:e.type||`application/octet-stream`,i=await eY(e,t).catch(()=>({})),a=await fetch(`/__dev/files`,{method:`POST`,headers:{"Content-Type":r,"X-File-Name":encodeURIComponent(e.name)},body:e}),o=await a.json().catch(()=>({}));if(!a.ok||!o.url)throw Error(o.error||`The preview could not keep this file.`);return{kind:t,assetId:`picked-${o.url.split(`/`)[4]}`,versionId:`v1`,url:o.url,mimeType:r,bytes:e.size,name:e.name,...i}}async function nY(e,t,n,{pick:r=tY}={}){if(!t)throw Error(`This Block has no input named ${e}.`);let i=t.type.endsWith(`[]`),a=i?t.type.slice(0,-2):t.type,o=[];for(let e of i?n:n.slice(0,1))o.push(await r(e,a===`asset`?String(e.type).split(`/`)[0]:a));return{refs:o,apply:t=>({...t||{},[e]:i?[...Array.isArray(t?.[e])?t[e]:[],...o]:o[0]})}}function rY(e,t,n){for(let t of Object.keys(n||{}))if(!Object.hasOwn(e||{},t))throw Error(`Unknown input: ${t}`);return{...t||{},...n}}function iY({name:e,port:t,value:n,own:r,disabled:i,onPick:a,title:o=Wq(e)}){let s=(0,v.useRef)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),m=async e=>{if(e){l(!0),d(``);try{a(await tY(e,t.type))}catch(e){d(e.message)}finally{l(!1)}}},h=e=>{let t=e.target.files?.[0];e.target.value=``,m(t)},g=BJ(e,t),_=(0,V.jsx)(`input`,{ref:s,type:`file`,hidden:!0,accept:$J[t.type],onChange:h});return r&&!n?(0,V.jsxs)(`div`,{className:`dh-media dh-media-empty`,children:[(0,V.jsx)(`span`,{className:`dh-media-label`,children:o}),(0,V.jsxs)(`div`,{className:`dh-media-drop`,"data-over":f||void 0,onDragOver:e=>{e.preventDefault(),f||p(!0)},onDragLeave:()=>p(!1),onDrop:e=>{e.preventDefault(),p(!1),!i&&!c&&m(e.dataTransfer.files?.[0])},children:[(0,V.jsx)(`strong`,{children:c?`Adding…`:g.drop}),t.description&&(0,V.jsx)(`span`,{children:t.description}),(0,V.jsx)(`small`,{children:g.formats}),(0,V.jsx)(`button`,{type:`button`,className:`dh-media-tile dh-media-pick`,disabled:i||c,onClick:()=>s.current?.click(),children:g.choose}),_,u&&(0,V.jsx)(`span`,{className:`dh-media-problem`,role:`alert`,children:u})]})]}):(0,V.jsxs)(`div`,{className:`dh-media`,children:[(0,V.jsx)(`span`,{className:`dh-media-label`,children:o}),r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{type:`button`,className:`dh-media-tile dh-media-pick`,disabled:i||c,onClick:()=>s.current?.click(),children:[(0,V.jsx)(iJ,{name:n?XJ[t.type]:`plus`,size:16}),(0,V.jsx)(`span`,{children:c?`Adding…`:oY(n)||g.choose})]}),_,u&&(0,V.jsx)(`span`,{className:`dh-media-problem`,role:`alert`,children:u})]}):n&&typeof n==`object`?(0,V.jsxs)(`span`,{className:`dh-media-tiles`,title:`The example from the Block's tests`,children:[(0,V.jsx)(aY,{item:n,title:o}),(0,V.jsx)(`small`,{className:`dh-media-note`,children:`Example`})]}):(0,V.jsxs)(`span`,{className:`dh-media-tile`,title:`The example from the Block's tests`,children:[(0,V.jsx)(iJ,{name:XJ[t.type],size:16}),(0,V.jsx)(`span`,{children:`Add one in the example`}),(0,V.jsx)(`small`,{children:`Example`})]})]})}function aY({item:e,title:t}){let n=(0,v.useRef)(null),[r,i]=(0,v.useState)(!1),a=oY(e)||t;if(!(typeof e?.url==`string`&&e.url.startsWith(`/api/media/`))||![`image`,`video`,`audio`].includes(e.kind))return(0,V.jsxs)(`span`,{className:`dh-media-tile`,title:a,children:[(0,V.jsx)(iJ,{name:XJ[e?.kind]||`image`,size:16}),(0,V.jsx)(`span`,{children:a})]});if(e.kind===`image`)return(0,V.jsx)(`span`,{className:`dh-thumb`,title:a,children:(0,V.jsx)(`img`,{src:e.url,alt:a,loading:`lazy`,decoding:`async`})});let o=()=>{let e=n.current;e&&(e.paused?e.play()?.catch?.(()=>{}):e.pause())},s={onPlay:()=>i(!0),onPause:()=>i(!1),onEnded:()=>i(!1)},c=(0,V.jsx)(`button`,{type:`button`,className:`dh-thumb-play`,"aria-label":`${r?`Pause`:`Play`} ${a}`,onClick:o,children:(0,V.jsx)(iJ,{name:r?`pauseFilled`:`playFilled`,size:14})});return e.kind===`video`?(0,V.jsxs)(`span`,{className:`dh-thumb`,title:a,"data-playing":r||void 0,children:[(0,V.jsx)(`video`,{ref:n,src:e.url,preload:`metadata`,muted:!0,playsInline:!0,...s}),c]}):(0,V.jsxs)(`span`,{className:`dh-media-tile dh-media-sound`,title:a,children:[c,(0,V.jsx)(iJ,{name:`music`,size:16}),(0,V.jsx)(`span`,{children:a}),(0,V.jsx)(`audio`,{ref:n,src:e.url,preload:`none`,...s})]})}var oY=e=>{let t=(typeof e?.url==`string`?e.url:``).split(/[?#]/)[0].split(`/`).pop();return e?.name||(t?decodeURIComponent(t):``)},sY=(e,t)=>{try{return localStorage.getItem(e)||t}catch{return t}},cY=(e,t)=>{try{localStorage.setItem(e,t)}catch{}};async function lY(e,t=``){return(await fetch(`/__dev/run${t}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({input:e})})).json()}async function uY(e,{signal:t,edge:n}={}){if(typeof e?.url!=`string`||!e.url.startsWith(`/api/media/`))throw Error(`The local preview shows stand-in media and files mapped in tests/mocks.json.`);let r=await fetch(e.url,{signal:t});if(!r.ok)throw Error(`This image is not available in the local preview. Map it to a file under files in tests/mocks.json.`);let i=await createImageBitmap(await r.blob()),a=n??512,o=Math.min(1,a/Math.max(i.width,i.height)),s=document.createElement(`canvas`);s.width=Math.max(1,Math.round(i.width*o)),s.height=Math.max(1,Math.round(i.height*o));let c=s.getContext(`2d`);c.drawImage(i,0,0,s.width,s.height),i.close?.();let l=s.toDataURL(`image/png`);return l.length>3145728&&a>512&&c.getImageData(0,0,s.width,s.height).data.every((e,t)=>t%4!=3||e===255)&&(l=s.toDataURL(`image/jpeg`,.92)),{url:l,width:s.width,height:s.height}}function dY(e,{signal:t}={}){return typeof e?.url!=`string`||!e.url.startsWith(`/api/media/`)?Promise.reject(Error(`The local preview plays stand-in media and files mapped in tests/mocks.json.`)):Jn(e,{signal:t})}async function fY(e,{signal:t}={}){let n=await fetch(`/api/media/example/kitchen.wav`,{signal:t});if(!n.ok)throw Error(`The stand-in voice sample is not available.`);return new Blob([await n.arrayBuffer()],{type:`audio/wav`})}function pY({value:e}){let t=oY(e);if(!e.url.startsWith(`/api/media/`))return(0,V.jsxs)(`span`,{className:`dh-media-tile`,children:[(0,V.jsx)(iJ,{name:XJ[e.kind],size:16}),(0,V.jsx)(`span`,{children:t||`Result`})]});let n=e.width>0&&e.height>0?`${e.width}/${e.height}`:null,r=n?{aspectRatio:n}:void 0;return(0,V.jsxs)(`figure`,{className:`dh-result-media`,children:[e.kind===`image`?(0,V.jsx)(`img`,{src:e.url,alt:t,style:r}):e.kind===`video`?(0,V.jsx)(oJ,{src:e.url,preload:`metadata`,style:n?{"--dh-shape":n}:void 0}):(0,V.jsx)(`audio`,{src:e.url,controls:!0,preload:`metadata`}),t&&(0,V.jsx)(`figcaption`,{children:t})]})}var mY=e=>(0,V.jsx)(pY,{value:e}),hY=new Set([`image[]`,`video[]`,`audio[]`,`asset`,`asset[]`,`file[]`]);function gY({name:e,port:t,control:n,value:r,onCommit:i,disabled:a}){let o=r??t.default??(t.type!==`boolean`&&``),s=n?.label||Wq(e),[c,l]=(0,v.useState)(o);(0,v.useEffect)(()=>{l(o)},[o]);let u=`dh-input-${e}`,d=t.description||void 0,f=n?.control===`select`&&Array.isArray(n.options)?n.options:null,p=f?(0,V.jsx)(`select`,{id:u,value:c,disabled:a,onChange:e=>{l(e.target.value),i(e.target.value)},children:f.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))}):n?.control===`slider`&&[`number`,`integer`].includes(t.type)&&Number.isFinite(t.min)&&Number.isFinite(t.max)?(0,V.jsxs)(`span`,{className:`dh-slider`,children:[(0,V.jsx)(`input`,{id:u,type:`range`,min:t.min,max:t.max,step:t.type===`integer`?1:`any`,value:c,disabled:a,onChange:e=>l(Number(e.target.value)),onPointerUp:()=>i(Number(c)),onKeyUp:()=>i(Number(c)),onBlur:()=>i(Number(c))}),(0,V.jsx)(`output`,{htmlFor:u,children:c})]}):t.type===`boolean`?(0,V.jsx)(`input`,{id:u,type:`checkbox`,checked:!!c,disabled:a,onChange:e=>{l(e.target.checked),i(e.target.checked)}}):[`number`,`integer`].includes(t.type)?(0,V.jsx)(`input`,{id:u,type:`number`,step:t.type===`integer`?1:`any`,value:c,disabled:a,onChange:e=>l(e.target.value),onBlur:()=>{if(c===``)return i(void 0);let e=Number(c);Number.isFinite(e)&&i(e)}}):[`text`,`string`].includes(t.type)?!n?.control&&KJ(t,o,n)?(0,V.jsx)(`input`,{id:u,type:`text`,value:c,disabled:a,onChange:e=>l(e.target.value),onBlur:()=>{c!==o&&i(c)}}):(0,V.jsx)(`textarea`,{id:u,className:`dh-text`,rows:Math.min(16,Math.max(3,String(c).split(`
2105
- `).length)),value:c,disabled:a,onChange:e=>l(e.target.value),onBlur:()=>{c!==o&&i(c)}}):t.type===`date`?(0,V.jsx)(`span`,{id:u,role:`group`,"aria-label":s,children:gJ(e,s,typeof o==`string`?o:``)?(0,V.jsx)(TJ,{value:typeof o==`string`?o:``,onChange:e=>i(e||void 0),disabled:a,label:s}):(0,V.jsx)(CJ,{value:typeof o==`string`?o.slice(0,10):``,onChange:e=>i(e||void 0),disabled:a,label:s,clearable:!t.required})}):hY.has(t.type)?(0,V.jsxs)(`span`,{className:`dh-media-tiles`,children:[(Array.isArray(o)?o:o?[o]:[]).filter(e=>e&&typeof e==`object`).map((e,t)=>(0,V.jsx)(aY,{item:e,title:`${s} ${t+1}`},t)),!(Array.isArray(o)?o.length:o)&&(0,V.jsx)(`span`,{className:`dh-muted`,children:`None in this example`})]}):(0,V.jsx)(`span`,{className:`dh-muted`,children:`Set in the example input`});return(0,V.jsxs)(`div`,{className:`dh-row`,children:[(0,V.jsx)(`label`,{htmlFor:u,title:d,children:s}),p]})}function _Y({value:e,onCommit:t,disabled:n}){let r=(0,v.useMemo)(()=>JSON.stringify(e,null,2),[e]),[i,a]=(0,v.useState)(r),[o,s]=(0,v.useState)(``);return(0,v.useEffect)(()=>{a(r),s(``)},[r]),(0,V.jsxs)(`div`,{className:`dh-input`,children:[(0,V.jsx)(`textarea`,{"aria-label":`Input JSON`,spellCheck:!1,rows:8,value:i,disabled:n,onChange:e=>a(e.target.value),onBlur:()=>{if(i!==r)try{let e=JSON.parse(i||`{}`);if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`The input is one JSON object, keyed by input port.`);s(``),t(e)}catch(e){s(e.message)}}}),o&&(0,V.jsx)(`p`,{role:`alert`,children:o})]})}var vY=(0,v.memo)(function({entries:e,onClear:t}){let n=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight)},[e]),(0,V.jsxs)(`section`,{className:`dh-console`,"aria-label":`Console`,children:[(0,V.jsxs)(`div`,{className:`dh-section-head`,children:[(0,V.jsx)(`span`,{className:`dh-muted`,children:`Reloads, runs, logs, stand-ins and errors, newest last.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:t,disabled:!e.length,children:`Clear`})]}),(0,V.jsx)(`ol`,{ref:n,children:e.map(e=>(0,V.jsxs)(`li`,{className:`dh-entry dh-${e.kind}`,children:[(0,V.jsx)(`time`,{children:e.time}),(0,V.jsx)(`span`,{className:`dh-kind`,children:e.label}),(0,V.jsx)(`pre`,{children:e.text})]},e.id))}),!e.length&&(0,V.jsx)(`p`,{className:`dh-muted`,children:`Runs, logs, stand-ins, reloads and errors appear here.`})]})}),yY={run:`Run`,log:`Log`,"stand-in":`Stand-in`,reload:`Reload`,build:`Build`,error:`Error`,view:`View`},bY={full:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,V.jsx)(`path`,{d:`M8 20h8M12 16v4`})]}),tablet:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`5`,y:`2`,width:`14`,height:`20`,rx:`2`}),(0,V.jsx)(`path`,{d:`M11 18h2`})]}),phone:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`7`,y:`2`,width:`10`,height:`20`,rx:`2`}),(0,V.jsx)(`path`,{d:`M11 18h2`})]}),light:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,V.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}),dark:(0,V.jsx)(`path`,{d:`M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5z`}),white:(0,V.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`3`}),example:(0,V.jsx)(`path`,{d:`M9 3h6M10 3v6l-5 9a2 2 0 0 0 1.7 3h10.6a2 2 0 0 0 1.7-3l-5-9V3`}),done:(0,V.jsx)(`path`,{d:`M5 12.5l4.5 4.5L19 7`}),todo:(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`,strokeDasharray:`3 3`}),problem:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`}),(0,V.jsx)(`path`,{d:`M12 7.5v5.5M12 16.4v.1`})]}),focus:(0,V.jsx)(`path`,{d:`M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5`}),unfocus:(0,V.jsx)(`path`,{d:`M9 4v5H4M20 9h-5V4M15 20v-5h5M4 15h5v5`})},xY=({name:e})=>(0,V.jsx)(`svg`,{className:`dh-glyph`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:bY[e]});function SY(){let[e,t]=(0,v.useState)(()=>sY(`stillmade.dev.focus`,``)===`1`);(0,v.useEffect)(()=>{e?document.documentElement.dataset.focus=`true`:delete document.documentElement.dataset.focus,cY(`stillmade.dev.focus`,e?`1`:``)},[e]);let n=e?`Show the bars`:`Hide the bars`;return(0,V.jsx)(`button`,{type:`button`,className:`dh-focus-toggle`,"aria-pressed":e,"aria-label":n,title:n,onClick:()=>t(e=>!e),children:(0,V.jsx)(xY,{name:e?`unfocus`:`focus`})})}function CY(e,t){(0,v.useLayoutEffect)(()=>{let t=e.current,n=t?.closest(`.dh-main`);if(!t||!n)return;let r=0,i=()=>{r=0;let e=parseFloat(getComputedStyle(n).paddingTop)+parseFloat(getComputedStyle(n).paddingBottom),i=_U({width:t.parentElement.clientWidth,available:n.clientHeight-e,heightAt:e=>{t.style.zoom=e===1?``:String(e),t.style.flex=`none`,t.style.minHeight=`0`;let n=Math.ceil(t.getBoundingClientRect().height);return t.style.flex=``,t.style.minHeight=``,n},mode:`auto`});t.style.zoom=i===1?``:String(i)},a=()=>{r||=requestAnimationFrame(i)};i(),addEventListener(`resize`,a);let o=e=>{[`IMG`,`VIDEO`,`AUDIO`].includes(e.target?.tagName)&&a()};return t.addEventListener(`load`,o,!0),t.addEventListener(`loadedmetadata`,o,!0),()=>{cancelAnimationFrame(r),removeEventListener(`resize`,a),t.removeEventListener(`load`,o,!0),t.removeEventListener(`loadedmetadata`,o,!0),t.style.zoom=``}},t)}function wY({label:e,value:t,options:n,onChange:r}){return(0,V.jsx)(`div`,{className:`dh-seg`,role:`radiogroup`,"aria-label":e,children:n.map(([e,n])=>(0,V.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e,"aria-label":n,title:n,onClick:()=>r(e),children:(0,V.jsx)(xY,{name:e})},e))})}var TY=140,EY=260,DY={"text.generate":`Write`,"image.generate":`Generate a picture`,"video.generate":`Generate a video`,"audio.speech":`Speak`,"audio.music":`Make music`,"audio.sfx":`Make a sound effect`,"audio.transcribe":`Transcribe`,"image.describe":`Describe a picture`,"media.analyze":`Look at the media`,"web.fetch":`Read a web page`,"web.research":`Research the web`,"timeline.render":`Render`,"audio.decode":`Decode audio`,"audio.extract":`Take out the audio`,"audio.normalize":`Even out the loudness`,"video.cut":`Cut the video`,"video.concat":`Join videos`,"video.resize":`Resize the video`,"image.thumbnail":`Take a still`,"image.compose":`Join pictures`,"document.text":`Read a document`,"files.read":`Read a file`,"files.write":`Save a file`,"net.fetch":`Call a web service`,"connections.call":`Use a connected app`,"actions.run":`Run an action`,"assets.create":`Add to the project`},OY=e=>DY[e.name]||DY[e.api]||e.name;function kY({on:e,label:t,onChange:n}){return(0,V.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e,className:`dh-switch`,onClick:()=>n(!e),children:[(0,V.jsx)(`span`,{className:`dh-switch-track`,children:(0,V.jsx)(`span`,{className:`dh-switch-knob`})}),(0,V.jsx)(`span`,{children:t})]})}function AY({tabs:e,status:t,control:n,children:r,initial:i=null}){let[a,o]=(0,v.useState)(i),[s,c]=(0,v.useState)(()=>Number(sY(`stillmade.dev.dock`,``))||EY),l=(0,v.useRef)(null),u=e=>o(t=>t===e?null:e),d=e=>{a&&(l.current={y:e.clientY,height:s},e.currentTarget.setPointerCapture(e.pointerId))},f=e=>{let t=l.current;t&&c(Math.round(Math.max(TY,Math.min(window.innerHeight*.75,t.height+t.y-e.clientY))))},p=()=>{l.current&&(l.current=null,cY(`stillmade.dev.dock`,String(s)))},m=e.find(e=>e.key===a);return(0,V.jsxs)(`section`,{className:`dh-dock`,"data-open":m?`true`:`false`,style:m?{height:s}:void 0,"aria-label":`Run details`,children:[m&&(0,V.jsx)(`div`,{className:`dh-dock-grip`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Drag to resize`,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p}),(0,V.jsxs)(`div`,{className:`dh-tabs`,role:`tablist`,"aria-label":`Run details`,children:[e.map(e=>(0,V.jsxs)(`button`,{type:`button`,role:`tab`,id:`dh-tab-${e.key}`,"aria-selected":a===e.key,"aria-controls":`dh-tabpanel-${e.key}`,onClick:()=>u(e.key),children:[e.label,e.alert&&(0,V.jsx)(`span`,{className:`dh-alert`,"aria-label":`has a problem`})]},e.key)),(0,V.jsx)(`span`,{className:`dh-tabs-status`,role:`status`,children:t}),n,(0,V.jsx)(`button`,{type:`button`,className:`dh-icon dh-fold`,"aria-label":m?`Fold the panel`:`Open the panel`,title:m?`Fold the panel`:`Open the panel`,"aria-expanded":!!m,onClick:()=>o(t=>t?null:e[0].key),children:(0,V.jsx)(iJ,{name:`chevronRight`,size:16})})]}),m&&(0,V.jsx)(`div`,{className:`dh-tabpanel`,role:`tabpanel`,id:`dh-tabpanel-${m.key}`,"aria-labelledby":`dh-tab-${m.key}`,children:r(m.key)})]})}function jY({item:e=null,extraTabs:t=[],badges:n=null,dockOpen:r=null}={}){let i=e?`?item=${encodeURIComponent(e)}`:``,[a,o]=(0,v.useState)({revision:0,content:null,problem:null,folder:``}),[s,c]=(0,v.useState)(0),[l,u]=(0,v.useState)(()=>sY(`stillmade.dev.theme`,`light`)),[d,f]=(0,v.useState)(()=>sY(`stillmade.dev.width`,`full`)),[p,m]=(0,v.useState)(0),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)({}),[A,j]=(0,v.useState)([]),[M,N]=(0,v.useState)({}),P=(0,v.useRef)({}),F=(0,v.useRef)(0),I=(0,v.useCallback)((e,t)=>j(n=>[...n.slice(-299),{id:++F.current,kind:e,label:yY[e]||e,time:new Date().toLocaleTimeString(),text:String(t)}]),[]),ee=(0,v.useCallback)(async()=>{let e=await(await fetch(`/__dev/package${i}`,{cache:`no-store`})).json();return o(e),e},[i]);(0,v.useEffect)(()=>{let t=!0;ee().then(e=>{t&&(g(t=>t??(e.content?.tests?.[0]?.input||{})),I(`reload`,`Previewing ${e.folder}`),e.problem&&I(`error`,ZJ(e.problem)))}).catch(e=>I(`error`,e.message));let n=new EventSource(`/__dev/events`);return n.addEventListener(`package`,async n=>{let r=JSON.parse(n.data);if(!(e&&r.item!==e))try{if(await ee(),!t)return;c(e=>e+1),I(r.problem?`error`:`reload`,r.problem?`Reloaded with a problem: ${ZJ(r.problem)}`:`Reloaded after a change`)}catch(e){I(`error`,e.message)}}),n.addEventListener(`build`,t=>{let n=JSON.parse(t.data);e&&n.items&&!n.items.includes(e.slice(e.indexOf(`/`)+1))||(n.state===`running`?I(`build`,`Building: ${n.command||n.items.join(`, `)}`):n.state===`done`?I(`build`,`Build finished`):I(`error`,`Build failed${n.output?`\n${n.output}`:``}`))}),()=>{t=!1,n.close()}},[]),(0,v.useEffect)(()=>{document.documentElement.dataset.mode=l,cY(`stillmade.dev.theme`,l)},[l]),(0,v.useEffect)(()=>{cY(`stillmade.dev.width`,d)},[d]);let te=a.content,L=te?.manifest,R=te?.tests||[],ne=e=>{m(e),g(R[e]?.input||{})},re=(0,v.useCallback)(async(e,{signal:t}={})=>{I(`run`,`Run started`),x(!0),C(``);try{let n=await lY(e,i);if(t?.aborted)throw Object.assign(Error(`Run cancelled`),{code:`CANCELLED`});for(let e of n.logs||[])I(`log`,e);for(let e of n.standIns||[])I(`stand-in`,`${e.api} ${e.name} (${e.source===`picked`?`your file`:e.source===`example`?`example file`:/mocks/.test(e.source)?`the Block's tests`:`recorded stand-in`})`);if(T({ms:n.ms,calls:n.standIns||[],failed:!!n.error}),n.error)throw I(`error`,`${n.error}${n.code?` (${n.code})`:``}`),Object.assign(Error(n.error),{code:n.code});return y(n.outputs),I(`run`,`Finished in ${n.ms} ms`),n.outputs}catch(e){throw e?.code!==`CANCELLED`&&(y(null),C(e?.message||`The run did not finish.`)),e}finally{x(!1)}},[I,i]),ie=(0,v.useCallback)(async e=>{let t=dr(P.current,e);P.current=t,N(t)},[]),ae=()=>{P.current={},N({}),c(e=>e+1),I(`view`,`Shared state cleared`)},[oe,se]=(0,v.useState)([]),ce=(0,v.useMemo)(()=>({state:M,outputs:{},made:oe,memory:null,canEdit:!0}),[M,oe]),le=(0,v.useCallback)(async e=>{y(e),I(`view`,`The view chose its outputs`)},[I]),ue=(0,v.useCallback)(async(e,t)=>{let n=a.content?.manifest?.inputs?.[e],{refs:r,apply:i}=await nY(e,n,t);return E&&YJ.has(n.type)?k(t=>({...t,[e]:r[0]})):g(i),I(`view`,`Added ${r.length} ${r.length===1?`file`:`files`} to ${Wq(e)}`),{added:r.length}},[a.content,E,I]),de=(0,v.useCallback)(async(e,t)=>{let n=xq(h?.[e],t);return g(t=>({...t,[e]:n})),I(`view`,`${t.op===`remove`?`Removed a file from`:`Moved a file in`} ${Wq(e)}`),{files:n.length}},[h,I]),fe=(0,v.useCallback)(e=>I(`error`,String(e?.message||e)),[I]),pe=(0,v.useCallback)(async e=>{let t=Array.isArray(e?.items)?e.items.length:0,n=Array.isArray(e?.hosted)?e.hosted.length:0;return I(`view`,`StillMade would price the next run: ${[t&&`${t} generated ${t===1?`item`:`items`}`,n&&`${n} hosted ${n===1?`call`:`calls`}`].filter(Boolean).join(` and `)||`nothing`}. The preview shows 0 credits.`),{credits:0}},[I]),me=(0,v.useCallback)(async e=>{let t=document.createElement(`a`);t.href=e.url,t.download=String(e.url).split(/[?#]/)[0].split(`/`).pop()||e.kind,document.body.append(t),t.click(),t.remove(),I(`view`,`Downloaded the ${e.kind===`image`?`picture`:e.kind===`video`?`clip`:`sound`}`)},[I]),he=(0,v.useMemo)(()=>{let e={...h||{}};if(E)for(let[t,n]of Object.entries(a.content?.manifest?.inputs||{}))YJ.has(n.type)&&(O[t]?e[t]=O[t]:delete e[t]);return e},[h,E,O,a.content]),ge=(0,v.useCallback)(e=>g(t=>{if(!E)return e;let n={...e};for(let[e,r]of Object.entries(a.content?.manifest?.inputs||{}))YJ.has(r.type)&&(t&&Object.hasOwn(t,e)?n[e]=t[e]:delete n[e]);return n}),[E,a.content]),_e=(0,v.useCallback)(async(e,t)=>{let n=rY(a.content?.manifest?.inputs,he,e);Object.keys(e).length&&ge({...h||{},...e});let r=await re(n,t),i=Object.values(r||{}).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>e&&[`image`,`video`,`audio`].includes(e.kind)&&typeof e.url==`string`&&typeof e.assetId==`string`).map(({kind:e,assetId:t,versionId:n,url:r})=>({kind:e,assetId:t,versionId:n,url:r}));return i.length&&se(e=>[...i,...e.filter(e=>!i.some(t=>t.url===e.url))].slice(0,400)),r},[a.content,he,h,ge,re]),ve=JJ.find(([e])=>e===d)?.[2],ye=te?.capability?.operation?[te.capability.operation]:(L?.permissions?.capabilities||[]).filter(e=>![`connection.execute`,`comfyui.execute`].includes(e)),be=b?eK(ye.length===1?ye[0]:void 0,te)[1]:nK(ye.length===1?ye[0]:void 0,{credits:0},{connector:te}),z=(0,v.useMemo)(()=>AJ(L,{labels:Object.fromEntries((L?.ui||[]).filter(e=>e?.label).map(e=>[e.port,e.label])),groups:L?.uiLayout?.groups||[]}),[L]),xe=(0,v.useRef)(null);CY(xe,[te,d,_,S,b]);let Se=_?Object.entries(L?.outputs||{}).filter(([e])=>_[e]!==void 0).map(([e,t])=>t?.type===`date`&&typeof _[e]==`string`&&/^\d{4}-\d{2}-\d{2}/.test(_[e])?(0,V.jsx)(`p`,{className:`dh-date`,children:(0,V.jsx)(`time`,{dateTime:_[e],children:_J(_[e])})},e):(0,V.jsx)(Qq,{value:_[e],renderMedia:mY},e)):null,Ce=b?`Running…`:w?w.failed?`Last run failed`:`Ran in ${w.ms} ms${w.calls.length?` · ${w.calls.length} ${w.calls.length===1?`call`:`calls`} answered by stand-ins`:``}`:`Reloads when you save`,we=[...t,{key:`activity`,label:`Activity`,alert:A.some(e=>e.kind===`error`)},{key:`calls`,label:`Calls${w?.calls.length?` · ${w.calls.length}`:``}`},...te?.view?[{key:`result`,label:`Result`}]:[],{key:`input`,label:`Input data`}];return(0,V.jsxs)(`div`,{className:`dh-page`,children:[(0,V.jsxs)(`header`,{className:`dh-bar`,children:[(0,V.jsxs)(`div`,{className:`dh-title`,children:[(0,V.jsx)(`h1`,{children:L?.name||`Block preview`}),L&&(0,V.jsx)(`span`,{className:`dh-meta`,children:L.version}),n]}),(0,V.jsx)(`span`,{className:`dh-spacer`}),R.length>1&&(0,V.jsxs)(`label`,{className:`dh-picker`,title:`Example input`,children:[(0,V.jsx)(xY,{name:`example`}),(0,V.jsx)(`select`,{"aria-label":`Example`,value:p,onChange:e=>ne(Number(e.target.value)),children:R.map((e,t)=>(0,V.jsx)(`option`,{value:t,children:e.name},t))})]}),(0,V.jsx)(wY,{label:`Width`,value:d,options:JJ,onChange:f}),(0,V.jsx)(wY,{label:`Appearance`,value:l,options:qJ,onChange:u}),(0,V.jsx)(`button`,{type:`button`,className:`dh-icon`,"aria-label":`Reload the Block`,title:`Reload the Block`,onClick:()=>c(e=>e+1),children:(0,V.jsx)(iJ,{name:`refresh`,size:16})})]}),a.problem&&(0,V.jsx)(`p`,{className:`dh-problem`,role:`alert`,children:ZJ(a.problem)}),(0,V.jsx)(`main`,{className:`dh-main`,"aria-label":`Preview`,children:(0,V.jsx)(`div`,{className:`dh-frame`,style:ve?{maxWidth:ve}:void 0,children:te?te.view?(0,V.jsx)(Fq,{fitContent:!0,view:te.view,policyContent:te,input:he,sharedView:ce,onSharedChange:ie,onRun:_e,onUseOutput:le,onAddFiles:ue,onChangeFiles:de,onPreviewImage:uY,onPreviewMedia:dY,onPreviewVoice:fY,onModels:hK,onRunPrice:pe,onDownload:me,onAllowSpending:async({credits:e,label:t})=>(console.info(`StillMade would ask to approve up to ${e} credits for "${t}". The SDK preview spends none.`),e),onError:fe,actorId:`dev-preview`,title:`${L.name} preview`,height:560,fitContent:!0},s):(0,V.jsxs)(`div`,{className:z.focused?`dh-noview dh-focus`:`dh-noview`,ref:xe,children:[z.focused&&(0,V.jsxs)(`header`,{className:`dh-intro`,children:[(0,V.jsx)(`h2`,{children:z.heading}),z.line&&(0,V.jsx)(`p`,{children:z.line})]}),(0,V.jsx)(`div`,{className:`dh-form`,children:Object.entries(L.inputs||{}).map(([e,t])=>YJ.has(t.type)?(0,V.jsx)(iY,{name:e,port:t,title:(L.ui||[]).find(t=>t?.port===e)?.label||Wq(e),value:he[e],own:E,disabled:b,onPick:t=>k(n=>({...n,[e]:t}))},e):(0,V.jsx)(gY,{name:e,port:t,control:(L.ui||[]).find(t=>t?.port===e),value:he[e],disabled:b,onCommit:t=>g(n=>({...n,[e]:t}))},e))}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:b,onClick:()=>re(he).catch(()=>{}),children:be}),S&&(0,V.jsx)(`p`,{className:`dh-run-problem`,role:`alert`,children:S}),Se?(0,V.jsxs)(`div`,{className:`dh-results`,children:[(0,V.jsx)(`h2`,{children:`Result`}),Se]}):!S&&(0,V.jsx)(`div`,{className:`dh-results dh-results-empty`,children:(0,V.jsx)(FJ,{...PJ(L,{inputs:he})})})]}):(0,V.jsx)(`p`,{className:`dh-muted`,role:`status`,children:`Loading the Block`})})}),(0,V.jsx)(AY,{tabs:we,status:Ce,initial:r,control:(0,V.jsx)(kY,{on:!E,label:`Example media`,onChange:e=>D(!e)}),children:e=>t.find(t=>t.key===e)?.render()??(e===`activity`?(0,V.jsx)(vY,{entries:A,onClear:()=>j([])}):e===`calls`?w?.calls.length?(0,V.jsx)(`ol`,{className:`dh-calls`,children:w.calls.map((e,t)=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`strong`,{children:OY(e)}),(0,V.jsx)(`span`,{children:e.name}),(0,V.jsx)(`small`,{children:e.source===`picked`?`read from your file`:e.source===`example`?`read from a StillMade example file`:/mocks/.test(e.source)?`answered from the Block's tests`:`answered by a recorded stand-in`})]},t))}):(0,V.jsx)(`p`,{className:`dh-muted`,children:w?`The last run made no hosted or media calls.`:`Run the Block to see the calls it makes and what answered each one.`}):e===`result`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`dh-section-head`,children:[(0,V.jsx)(`span`,{className:`dh-muted`,children:`What the Block's view returned.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:ae,children:`Clear shared state`})]}),S&&(0,V.jsx)(`p`,{className:`dh-run-problem`,role:`alert`,children:S}),Se||!S&&(0,V.jsx)(`p`,{className:`dh-muted`,children:`Nothing has run yet.`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`dh-section-head`,children:[(0,V.jsx)(`span`,{className:`dh-muted`,children:`The exact input the Block runs with, for values the controls cannot set.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:b||!te,onClick:()=>re(he).catch(()=>{}),children:be})]}),h&&(0,V.jsx)(_Y,{value:he,onCommit:ge,disabled:!te}),_&&(0,V.jsx)(`pre`,{className:`dh-json`,children:JSON.stringify(_,null,2)})]}))})]})}var MY={block:`layers`,connector:`plug`,automation:`clock`,workflow:`list`},NY={block:`Block`,connector:`Connector`,automation:`Automation`,workflow:`Project Type`},PY={module:`Module`,javascript:`JavaScript`,recipe:`Recipe`,capability:`Hosted`,comfyui:`ComfyUI`,desktop:`Desktop`,"browser-application":`Application`},FY={ready:`Gate passed`,"needs-fix":`Needs a fix`,unchecked:`Not checked since it changed`,building:`Being built`},IY=e=>e.kind===`workflow`?`workflow`:e.blockKind||`block`,LY=e=>e.kind===`workflow`?`${e.automation?`Automation`:`Project Type`} · ${e.steps} ${e.steps===1?`Step`:`Steps`}`:[IY(e)===`block`?PY[e.runtime]||`Block`:NY[IY(e)],e.version].filter(Boolean).join(` · `);function RY({status:e}){return(0,V.jsx)(`span`,{className:`ws-dot ws-dot-${e}`,role:`img`,"aria-label":FY[e]||e,title:FY[e]||e})}function zY({templates:e,onAdded:t,onCancel:n}){let[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(`module`),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``);return(0,V.jsxs)(`form`,{className:`ws-new`,onSubmit:async e=>{if(e.preventDefault(),r.trim()){c(!0),u(``);try{let e=await fetch(`/__dev/new`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:r,template:a})}),n=await e.json();if(!e.ok)throw Error(n.error||`The Block could not be added.`);t(n.key)}catch(e){u(e.message)}finally{c(!1)}}},children:[(0,V.jsxs)(`label`,{className:`ws-field`,children:[(0,V.jsx)(`span`,{children:`Name`}),(0,V.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`price-drop-alert`,autoFocus:!0,disabled:s})]}),(0,V.jsxs)(`label`,{className:`ws-field`,children:[(0,V.jsx)(`span`,{children:`Start from`}),(0,V.jsx)(`select`,{value:a,onChange:e=>o(e.target.value),disabled:s,children:e.map(e=>(0,V.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),l&&(0,V.jsx)(`p`,{className:`ws-problem`,role:`alert`,children:l}),(0,V.jsxs)(`div`,{className:`ws-new-actions`,children:[(0,V.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,disabled:s||!r.trim(),children:s?`Adding`:`Add Block`}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:n,children:`Cancel`})]})]})}function BY({data:e,selected:t,onSelect:n,folded:r,onFold:i,follow:a,onFollow:o}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)([]),d=()=>{r&&i(!1),c(!0),l.length||fetch(`/__dev/templates`).then(e=>e.json()).then(u).catch(()=>{})},f=e.items.filter(e=>e.kind===`block`),p=e.items.filter(e=>e.kind===`workflow`),m=e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`ws-item`,"aria-current":t===e.key?`true`:void 0,onClick:()=>n(e.key),title:r?`${e.name}: ${FY[e.status]||``}`:void 0,children:[(0,V.jsx)(`span`,{className:`ws-kind`,children:(0,V.jsx)(iJ,{name:MY[IY(e)],size:14})}),(0,V.jsxs)(`span`,{className:`ws-text`,children:[(0,V.jsx)(`b`,{children:e.name}),(0,V.jsx)(`small`,{children:LY(e)})]}),(0,V.jsx)(RY,{status:e.status})]})},e.key),h=`${f.length} ${f.length===1?`Block`:`Blocks`} · ${p.length} ${p.length===1?`workflow`:`workflows`}`;return(0,V.jsxs)(`aside`,{className:`ws-side`,"aria-label":`Workspace`,children:[(0,V.jsxs)(`div`,{className:`ws-head`,children:[(0,V.jsx)(`button`,{type:`button`,className:`dh-icon ws-fold`,"aria-label":r?`Open the list`:`Fold the list`,title:r?`Open the list`:`Fold the list`,"aria-expanded":!r,onClick:()=>i(!r),children:(0,V.jsx)(iJ,{name:r?`chevronRight`:`chevronLeft`,size:16})}),(0,V.jsxs)(`div`,{className:`ws-title`,children:[(0,V.jsx)(`h1`,{children:e.name}),(0,V.jsx)(`small`,{children:h})]})]}),(0,V.jsxs)(`nav`,{className:`ws-list`,children:[(0,V.jsx)(`h2`,{className:`ws-group`,children:`Blocks`}),f.length?(0,V.jsx)(`ul`,{children:f.map(m)}):(0,V.jsx)(`p`,{className:`ws-empty`,children:`No Blocks yet. Add one below, or ask your agent.`}),p.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`ws-group`,children:`Workflows`}),(0,V.jsx)(`ul`,{children:p.map(m)})]}),e.shared.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`ws-group`,children:`Shared code`}),(0,V.jsx)(`ul`,{children:(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`ws-item`,"aria-current":t===`shared`?`true`:void 0,onClick:()=>n(`shared`),title:r?`Shared code`:void 0,children:[(0,V.jsx)(`span`,{className:`ws-kind`,children:(0,V.jsx)(iJ,{name:`folder`,size:14})}),(0,V.jsxs)(`span`,{className:`ws-text`,children:[(0,V.jsx)(`b`,{children:`shared/`}),(0,V.jsxs)(`small`,{children:[e.shared.length,` `,e.shared.length===1?`file`:`files`]})]}),(0,V.jsx)(`span`,{})]})})})]})]}),(0,V.jsxs)(`div`,{className:`ws-foot`,children:[s?(0,V.jsx)(zY,{templates:l.length?l:[{name:`module`}],onAdded:e=>{c(!1),n(e)},onCancel:()=>c(!1)}):(0,V.jsxs)(`button`,{type:`button`,className:`btn btn-ghost ws-add`,onClick:d,title:r?`New Block`:void 0,children:[(0,V.jsx)(iJ,{name:`plus`,size:14}),(0,V.jsx)(`span`,{className:`ws-text`,children:`New Block`})]}),!s&&(0,V.jsxs)(`div`,{className:`ws-text ws-follow`,children:[(0,V.jsx)(kY,{on:a,label:`Follow the agent`,onChange:o}),(0,V.jsx)(`small`,{children:`Opens the Block your agent last saved.`})]})]})]})}function VY({item:e,onCheck:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(``),o=async()=>{r(!0),a(``);try{await t()}catch(e){a(e.message)}finally{r(!1)}},s=e.gate,c=s?.current;return(0,V.jsxs)(`div`,{className:`ws-checks`,children:[(0,V.jsxs)(`div`,{className:`dh-section-head`,children:[(0,V.jsxs)(`span`,{className:`dh-muted`,children:[FY[e.status],`. The gate runs StillMade's readiness check on every Block that changed.`]}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:n,onClick:o,children:n?`Running the gate`:`Run the gate`})]}),(0,V.jsxs)(`ul`,{className:`ws-checklist`,children:[e.problem&&(0,V.jsxs)(`li`,{"data-state":`failed`,children:[(0,V.jsx)(xY,{name:`problem`}),(0,V.jsx)(`span`,{children:e.problem})]}),e.buildProblem&&(0,V.jsxs)(`li`,{"data-state":`failed`,children:[(0,V.jsx)(xY,{name:`problem`}),(0,V.jsxs)(`span`,{children:[`Build from `,e.source,` failed: `,e.buildProblem]})]}),e.source&&!e.buildProblem&&(0,V.jsxs)(`li`,{"data-state":`done`,children:[(0,V.jsx)(xY,{name:`done`}),(0,V.jsxs)(`span`,{children:[`Built from `,e.source,e.shared.length?`, with shared/${e.shared.join(`, shared/`)}`:``]})]}),e.triggers?.length>0&&(0,V.jsxs)(`li`,{"data-state":`done`,children:[(0,V.jsx)(xY,{name:`done`}),(0,V.jsxs)(`span`,{children:[`Runs on its own: `,e.triggers.join(`; `),`. Its owner turns it on for a Step in a project; here it runs when you press its button.`]})]}),e.apps?.length>0&&(0,V.jsxs)(`li`,{"data-state":`done`,children:[(0,V.jsx)(xY,{name:`done`}),(0,V.jsxs)(`span`,{children:[`Uses `,e.apps.map(e=>e.replace(/^app:(openapi:)?/,``)).join(`, `),` with the account each person connects. Here `,e.apps.length===1?`it answers`:`they answer`,` from tests/mocks.json.`]})]}),e.checklist?.map(e=>(0,V.jsxs)(`li`,{"data-state":e.done?`done`:`todo`,children:[(0,V.jsx)(xY,{name:e.done?`done`:`todo`}),(0,V.jsx)(`span`,{children:e.label}),(0,V.jsx)(`small`,{children:e.done?`done`:`to do`})]},e.id)),(0,V.jsxs)(`li`,{"data-state":c?s.ok?`done`:`failed`:`waiting`,children:[(0,V.jsx)(xY,{name:c?s.ok?`done`:`problem`:`todo`}),(0,V.jsxs)(`span`,{children:[`Readiness gate`,c?`: ${s.status}`:s?`: changed since it last ran`:`: not run yet`]}),(0,V.jsx)(`small`,{children:s?.checkedAt?new Date(s.checkedAt).toLocaleTimeString():``})]}),c&&!s.ok&&s.failures.map((e,t)=>(0,V.jsx)(`li`,{className:`ws-failure`,children:e},t))]}),i&&(0,V.jsx)(`p`,{className:`ws-problem`,role:`alert`,children:i})]})}var HY={completed:`Done`,skipped:`Skipped`,disabled:`Off in this workflow`,failed:`Failed`,blocked:`Waiting on an earlier Step`,"needs-project":`Runs only in a StillMade project`,"needs-context":`Needs project context`,"needs-sample":`Needs a sample input`,"needs-hosted-run":`Runs on credits in StillMade`,deferred:`Runs in StillMade`},UY=e=>e===`completed`?`done`:e===`failed`?`failed`:e===`running`?`running`:e?`waiting`:`idle`;function WY({itemKey:e,revision:t,theme:n,setTheme:r}){let[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{let t=!0;return fetch(`/__dev/workflow?item=${encodeURIComponent(e)}`,{cache:`no-store`}).then(e=>e.json()).then(e=>{t&&(a(e),p(t=>t??e.samples??{}))}).catch(e=>t&&a({problem:e.message})),()=>{t=!1}},[e,t]),(0,v.useEffect)(()=>{let t=new EventSource(`/__dev/events`);return t.addEventListener(`step`,t=>{let n=JSON.parse(t.data);n.item===e&&s(e=>({...e,[n.step.id]:n.step}))}),()=>t.close()},[e]);let m=async()=>{d(!0),s({}),l(null);try{let t=await(await fetch(`/__dev/workflow/run?item=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({inputs:f})})).json();l(t),t.results&&s(Object.fromEntries(t.results.map(e=>[e.id,e])))}catch(e){l({error:e.message})}finally{d(!1)}};if(!i)return(0,V.jsx)(`div`,{className:`dh-page`,children:(0,V.jsx)(`p`,{className:`dh-muted ws-pad`,role:`status`,children:`Loading the workflow`})});if(i.problem)return(0,V.jsx)(`div`,{className:`dh-page`,children:(0,V.jsx)(`p`,{className:`dh-problem`,role:`alert`,children:i.problem})});let h=[...i.steps].reverse().find(e=>o[e.id]?.outputs),g=h&&o[h.id],_=c?.standIns||[],y=u?`Running the Steps…`:c?.error?`The run did not finish`:c?`Ran in ${c.ms} ms${_.length?` · ${_.length} ${_.length===1?`call`:`calls`} answered by stand-ins`:``}`:`Runs on this computer with stand-ins`,b=[{key:`steps`,label:`Steps`},{key:`samples`,label:`Sample inputs`},{key:`connections`,label:`Connections · ${i.connections.length}`}],x=e=>i.steps.find(t=>t.id===e)?.label||e;return(0,V.jsxs)(`div`,{className:`dh-page`,children:[(0,V.jsxs)(`header`,{className:`dh-bar`,children:[(0,V.jsxs)(`div`,{className:`dh-title`,children:[(0,V.jsx)(`h1`,{children:i.name}),(0,V.jsxs)(`span`,{className:`dh-meta`,children:[i.automation?`Automation`:`Project Type`,` · `,i.version]})]}),(0,V.jsx)(`span`,{className:`dh-spacer`}),(0,V.jsx)(wY,{label:`Appearance`,value:n,options:qJ,onChange:r}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:u,onClick:m,children:u?`Running the workflow`:i.automation?`Run once now · 0 credits`:`Run the workflow · 0 credits`})]}),(0,V.jsxs)(`main`,{className:`dh-main ws-flow`,"aria-label":`Workflow`,children:[(0,V.jsx)(`ol`,{className:`ws-steps`,children:i.steps.map((e,t)=>{let n=o[e.id],r=u&&!n?`running`:UY(n?.status);return(0,V.jsxs)(`li`,{className:`ws-step`,"data-tone":r,children:[(0,V.jsxs)(`span`,{className:`ws-step-n`,children:[`Step `,t+1]}),(0,V.jsx)(`b`,{children:e.label}),(0,V.jsxs)(`span`,{className:`ws-ports`,children:[(0,V.jsxs)(`span`,{children:[`In: `,e.inputs.map(e=>e.name).join(`, `)||`nothing`]}),(0,V.jsxs)(`span`,{children:[`Out: `,e.outputs.map(e=>e.name).join(`, `)||`nothing`]})]}),(0,V.jsx)(`span`,{className:`ws-step-state`,children:r===`running`?`Waiting to run`:n?`${HY[n.status]||n.status}${n.status===`failed`&&n.message?`: ${n.message}`:``}`:`Not run yet`})]},e.id)})}),(0,V.jsxs)(`section`,{className:`ws-outcome`,"aria-label":`Result`,children:[(0,V.jsx)(`div`,{className:`ws-outcome-main`,children:c?.error?(0,V.jsx)(`p`,{className:`dh-run-problem`,role:`alert`,children:c.error}):g?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{children:h.label}),Object.entries(g.outputs).map(([e,t])=>(0,V.jsxs)(`div`,{className:`ws-output`,children:[(0,V.jsx)(`span`,{children:Wq(e)}),(0,V.jsx)(Qq,{value:t,renderMedia:mY})]},e))]}):(0,V.jsx)(`p`,{className:`dh-muted`,children:u?`Running…`:`Run the workflow to see what its last Step makes.`})}),(0,V.jsxs)(`aside`,{className:`ws-outcome-side`,children:[(0,V.jsx)(`h2`,{children:`What this run used`}),_.length?(0,V.jsx)(`ul`,{children:_.map((e,t)=>(0,V.jsxs)(`li`,{children:[e.api,` `,e.name,`: `,/mocks/.test(e.source)?`answered from the Block's tests`:`a recorded stand-in`]},t))}):(0,V.jsx)(`p`,{className:`dh-muted`,children:c?`No hosted calls.`:`Nothing yet.`}),(0,V.jsx)(`p`,{className:`ws-note`,children:`A stand-in run proves the Steps fit together. Real voices, pictures and video run only in StillMade, on credits.`}),i.automation&&(0,V.jsx)(`p`,{className:`ws-note`,children:`An automation. In a project its first Step waits for what is turned on on the Automation page: a schedule, an app event or a webhook. Here it runs once, as if started by hand.`})]})]})]}),(0,V.jsx)(AY,{tabs:b,status:y,children:t=>t===`steps`?(0,V.jsx)(`ol`,{className:`dh-calls`,children:i.steps.map(e=>{let t=o[e.id];return(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`strong`,{children:e.label}),(0,V.jsx)(`span`,{children:e.folder?`blocks/${e.folder}`:`${e.blockId}@${e.version}`}),(0,V.jsxs)(`small`,{children:[t?HY[t.status]||t.status:`Not run yet`,t?.message&&t.status!==`completed`?`: ${t.message}`:``]})]},e.id)})}):t===`samples`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`dh-section-head`,children:(0,V.jsxs)(`span`,{className:`dh-muted`,children:[`What each Step starts with, by Step id. Saved in workflows/`,e.split(`/`).pop(),`.samples.json, the run uses that file instead.`]})}),(0,V.jsx)(_Y,{value:f||{},onCommit:p,disabled:u})]}):(0,V.jsxs)(`ol`,{className:`dh-calls`,children:[i.connections.map((e,t)=>(0,V.jsxs)(`li`,{children:[(0,V.jsxs)(`strong`,{children:[x(e.from.stage),`: `,e.from.port]}),(0,V.jsxs)(`span`,{children:[`to `,x(e.to.stage),`: `,e.to.port]})]},t)),!i.connections.length&&(0,V.jsx)(`li`,{children:`No connections. Each Step takes only its own inputs.`})]})})]})}function GY({data:e}){return(0,V.jsxs)(`div`,{className:`dh-page`,children:[(0,V.jsx)(`header`,{className:`dh-bar`,children:(0,V.jsxs)(`div`,{className:`dh-title`,children:[(0,V.jsx)(`h1`,{children:`Shared code`}),(0,V.jsx)(`span`,{className:`dh-meta`,children:`shared/`})]})}),(0,V.jsx)(`main`,{className:`dh-main`,children:(0,V.jsxs)(`div`,{className:`ws-shared`,children:[(0,V.jsx)(`p`,{className:`dh-muted`,children:`Module Blocks import these files from src/main.js. Building joins them into each Block, so every packed Block still stands alone.`}),(0,V.jsx)(`ul`,{className:`dh-calls`,children:e.shared.map(e=>(0,V.jsxs)(`li`,{children:[(0,V.jsxs)(`strong`,{children:[`shared/`,e.file]}),(0,V.jsx)(`small`,{children:e.usedBy.length?`Used by ${e.usedBy.join(`, `)}`:`Not used yet`})]},e.file))})]})})]})}var KY=()=>{try{return decodeURIComponent(location.hash.slice(1))}catch{return``}};function qY({initial:e}){let[t,n]=(0,v.useState)(e),[r,i]=(0,v.useState)(()=>{let t=KY();return e.items.some(e=>e.key===t)||t===`shared`?t:e.items[0]?.key||``}),[a,o]=(0,v.useState)(()=>sY(`stillmade.dev.workspace.folded`,``)===`1`),[s,c]=(0,v.useState)(()=>sY(`stillmade.dev.workspace.follow`,`1`)===`1`),[l,u]=(0,v.useState)(()=>sY(`stillmade.dev.theme`,`light`)),[d,f]=(0,v.useState)(0),p=(0,v.useRef)(s);p.current=s;let m=(0,v.useCallback)(()=>fetch(`/__dev/workspace`,{cache:`no-store`}).then(e=>e.json()).then(e=>(n(e),e)),[]),h=(0,v.useCallback)(e=>{i(e);try{history.replaceState(null,``,`#${encodeURIComponent(e)}`)}catch{}},[]);(0,v.useEffect)(()=>{let e=new EventSource(`/__dev/events`);return e.addEventListener(`workspace`,e=>{let t=JSON.parse(e.data);m().then(e=>{t.focus&&p.current&&e.items.some(e=>e.key===t.focus)&&h(t.focus),f(e=>e+1)}).catch(()=>{})}),()=>e.close()},[m,h]),(0,v.useEffect)(()=>{document.documentElement.dataset.mode=l,cY(`stillmade.dev.theme`,l)},[l]),(0,v.useEffect)(()=>{cY(`stillmade.dev.workspace.folded`,a?`1`:``)},[a]),(0,v.useEffect)(()=>{cY(`stillmade.dev.workspace.follow`,s?`1`:``)},[s]);let g=t.items.find(e=>e.key===r),_=(0,v.useCallback)(async()=>{if(!(await fetch(`/__dev/check`,{method:`POST`})).ok)throw Error(`The gate could not run.`);await m()},[m]),y=(0,v.useMemo)(()=>g?.kind===`block`?[{key:`checks`,label:`Checks`,alert:g.status===`needs-fix`,render:()=>(0,V.jsx)(VY,{item:g,onCheck:_})}]:[],[g,_]),b=g?.kind===`block`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`ws-chip`,children:NY[IY(g)]}),g.status!==`ready`&&(0,V.jsx)(`span`,{className:`ws-chip`,"data-status":g.status,children:FY[g.status]})]}):null;return(0,V.jsxs)(`div`,{className:`ws-page`,"data-folded":a?`true`:`false`,children:[(0,V.jsx)(BY,{data:t,selected:r,onSelect:h,folded:a,onFold:o,follow:s,onFollow:c}),(0,V.jsx)(`div`,{className:`ws-content`,children:!g&&r!==`shared`?(0,V.jsx)(`div`,{className:`dh-page`,children:(0,V.jsxs)(`div`,{className:`ws-pad`,children:[(0,V.jsx)(`h2`,{className:`ws-hello`,children:t.name}),(0,V.jsxs)(`p`,{className:`dh-muted`,children:[`Add a Block from the list, or ask your agent to run `,(0,V.jsx)(`code`,{children:`stillmade-block add <name>`}),`. It shows up here by itself.`]})]})}):r===`shared`?(0,V.jsx)(GY,{data:t}):g.kind===`workflow`?(0,V.jsx)(WY,{itemKey:g.key,revision:d,theme:l,setTheme:u},g.key):(0,V.jsx)(jY,{item:g.key,extraTabs:y,badges:b,dockOpen:g.status===`ready`?null:`checks`},g.key)})]})}var JY=(0,y.createRoot)(document.getElementById(`root`));fetch(`/__dev/workspace`,{cache:`no-store`}).then(e=>e.ok?e.json():null).catch(()=>null).then(e=>JY.render((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(SY,{}),e?(0,V.jsx)(qY,{initial:e}):(0,V.jsx)(jY,{})]})));
2102
+ `})})),FK=o((()=>{PK(),Object.freeze({notice:NK.MIT.replace(`<year> <copyright holders>`,`2026 StillMade SDK contributors`)})})),IK,LK=o((()=>{IK=[`to`,`recipient`,`recipients`,`recipient_email`,`subject`,`body`,`message_body`,`text_body`,`html_body`,`thread_id`,`threadId`],[...IK]})),RK=o((()=>{LK()})),zK=o((()=>{Et(),FK(),RK(),Object.freeze(`email.firstname.first_name.lastname.last_name.name.full_name.phone.mobilephone.phone_number.company.website.jobtitle.job_title.city.state.zip.country.address.lifecyclestage.hs_lead_status.message.notes.description.subject.body.to.recipient_email.title.status.amount.tags`.split(`.`))})),BK=o((()=>{Et(),MK(),zK(),JW(),Object.freeze({prompt:32e3,contextBytes:24e3,system:8e3,output:32768,maxTokens:4096,fixtures:3,includes:8,includeLength:256,packageBytes:262144,metadataBytes:8192}),Object.freeze({system:32e3,prompt:64e3,maxTokens:24e3,output:131072}),Object.freeze({text:3800,duration:1400,bytes:67108864,sampleRate:24e3,channels:1}),Object.freeze({images:4,question:2e3,range:12}),Object.freeze({images:10,question:8e3,instructions:8e3,maxTokens:4e3}),Object.freeze([`check`]),Object.freeze({turns:20,turn:8e3,total:24e3}),Object.freeze({url:2048,instruction:4e3,topic:500,sources:12,answer:32768}),Object.freeze({images:4}),Object.freeze({bytes:134217728,duration:1800,music:Object.freeze({min:5,max:240,default:30}),sfx:Object.freeze({min:.5,max:22,default:4})}),Object.freeze({prompt:32e3,bytes:268435456,duration:60,width:3840,height:3840,pixels:8294400}),Object.freeze({prompt:32e3,bytes:12e6,width:1024,height:1024,maxSide:8192,maxPixels:4e7,maxBytes:67108864}),Object.freeze({bytes:16777216,nodes:408192})})),VK=o((()=>{Et(),BK()})),HK=o((()=>{Et(),BK()}));function UK({signal:e,service:t=`capability`}={}){let n=t===`connections`?`/api/connections`:`/api/block-capabilities`,r=ir(),i=KK(r),a=new AbortController,o=!1,s=()=>!o&&!!i&&KK(ir())===i,c=()=>{s()||a.abort()},l=()=>a.abort();e?.addEventListener(`abort`,l,{once:!0});let u=setInterval(c,250);return globalThis.window?.addEventListener(`storage`,c),globalThis.window?.addEventListener(`focus`,c),(e?.aborted||!i)&&a.abort(),{signal:a.signal,assertCurrent(){if(c(),a.signal.aborted)throw i?WK():GK()},async request(e,{body:t,method:r=t===void 0?`GET`:`POST`,settleAfterCancel:o=!1,operation:s,claimedResult:c=!1}={}){!i&&r!==`GET`&&!kK.test(e)&&DK()&&wK(AK),this.assertCurrent();let l=new AbortController,u=()=>l.abort(),d=setTimeout(u,[`audio.transcribe`,`audio.music`,`audio.sfx`,`web.research`,`media.analyze`,`image.generate`,`video.generate`].includes(s)&&r===`POST`&&(/^\/(reviews|runs)$/.test(e)||/^\/runs\/[^/]+\/poll$/.test(e))?s===`video.generate`?305e3:165e3:65e3);o||a.signal.addEventListener(`abort`,u,{once:!0});try{B(!c||e===`/claimed-results/verify`,`SEGMENT_RECEIPT`,`Choose the claimed result verification endpoint`);let i=await fetch((c?`/api/public-tools`:n)+e,{method:r,headers:ir(),credentials:`same-origin`,cache:`no-store`,...t===void 0?{}:{body:JSON.stringify(t)},signal:l.signal}),a=await i.json().catch(()=>({}));if(o||this.assertCurrent(),!i.ok)throw Object.assign(Error(a.error||(i.status===401?`Sign in to use your StillMade capabilities.`:`Generation is unavailable. Check your account and server setup.`)),{code:a.code,status:i.status});return r===`POST`&&(e===`/runs`||/^\/runs\//.test(e)&&[`completed`,`failed`,`cancelled`].includes(a.state))&&globalThis.window?.dispatchEvent(new Event(`aivw-credits-refresh`)),a}finally{clearTimeout(d),a.signal.removeEventListener(`abort`,u)}},async cancel(e){let t=new AbortController,i=setTimeout(()=>t.abort(),65e3);try{await fetch(n+e,{method:`POST`,headers:r,credentials:`same-origin`,cache:`no-store`,body:`{}`,signal:t.signal}),globalThis.window?.dispatchEvent(new Event(`aivw-credits-refresh`))}finally{clearTimeout(i)}},dispose(){o||(o=!0,a.abort(),clearInterval(u),e?.removeEventListener(`abort`,l),globalThis.window?.removeEventListener(`storage`,c),globalThis.window?.removeEventListener(`focus`,c))}}}var WK,GK,KK,qK=o((()=>{VK(),jK(),Et(),HK(),BK(),JW(),MK(),WK=()=>Object.assign(new DOMException(`Preview cancelled. Reopen it to confirm the current account and model.`,`AbortError`),{codeName:`CAPABILITY_CANCELLED`}),GK=()=>Object.assign(new DOMException(`Sign in to preview this.`,`AbortError`),{codeName:`CAPABILITY_SIGNED_OUT`}),KK=e=>{let t=e.Authorization||``;if(!t)return null;try{let e=JSON.parse(atob(t.slice(7).split(`.`)[1].replaceAll(`-`,`+`).replaceAll(`_`,`/`)));if(typeof e.sub==`string`&&e.sub)return e.sub}catch{}return t}})),JK,YK=o((()=>{IG(),Object.fromEntries(PG.map(e=>[e.value,e.label])),JK=[{slug:`standard`,label:`Standard`,blurb:`Fast everyday — free on a plan`,model:`google/gemini-2.5-flash`},{slug:`balanced`,label:`Balanced`,blurb:`Stronger & quick`,model:`anthropic/claude-sonnet-4.5`},{slug:`reasoning`,label:`Reasoning`,blurb:`Deepest, most careful`,model:`google/gemini-2.5-pro`},{slug:`premium`,label:`Premium`,blurb:`Best writing`,model:`anthropic/claude-opus-4.8`}],Object.fromEntries(JK.map(e=>[e.slug,e]))})),XK,ZK,QK,$K,eq,tq,nq=o((()=>{YK(),NG(),{wholeCredits:XK,exactCredits:ZK,FLAT:QK}=YW,$K=e=>XK(QK[e].usd,QK[e].tier),eq=e=>XK(e,`other`),tq=Object.freeze({LLM_CHAT_MESSAGE:eq(.01),LLM_BIBLE_GENERATION:eq(.05),LLM_CANVAS_GENERATION:eq(.03),LLM_VOICEOVER_SHOT_ANALYSIS:eq(.01),LLM_MOOD_MAP_GENERATION:eq(.01),LLM_MUSIC_PROMPT_GENERATION:eq(.01),LLM_AUTO_EDIT_ANALYSIS:eq(.01),LLM_GENERIC:eq(.01),"project:assistant":Math.ceil(ZK(TG,`chat`)-1e-9),"chat:web-search":ZK(EG,`chat`),"narrative:compile":$K(`narrative:compile`),"narrative:compile-research":$K(`narrative:compile-research`),"narrative:learn-voice":$K(`narrative:learn-voice`),VISION_EXTERNAL_VIDEO_ANALYSIS:eq(.02),VISION_AUTO_ANALYZE_PER_IMAGE:$K(`vision`),...Object.fromEntries(Object.keys(dG).map(e=>[`IMAGE_${e}`,XK(QW({model:e}),`media`)])),...Object.fromEntries(Object.keys(lG).map(e=>[`VIDEO_${e}`,ZK($W({model:e,seconds:1}),`video`)])),VOICEOVER_PER_MINUTE:XK(eG({seconds:60}),`media`),"transcribe:timestamp":$K(`transcribe:timestamp`),"transcribe:upload":$K(`transcribe:upload`),"transcribe:captions":$K(`transcribe:captions`),MUSIC_PER_MINUTE:XK(jG(60),`media`),SFX_PER_GENERATION:XK(MG(4),`media`),ROUGHCUT_BASE:$K(`roughcut:base`),ROUGHCUT_PER_MINUTE:$K(`roughcut:per-min`),FINALEDIT_BASE:$K(`finaledit:base`),FINALEDIT_PER_MINUTE:$K(`finaledit:per-min`),AOMOTION_BASE:$K(`aomotion:base`),AOMOTION_PER_MINUTE:$K(`aomotion:per-min`),AOMOTION_BASE_OPUS:$K(`aomotion:base:opus`),AOMOTION_PER_MINUTE_OPUS:$K(`aomotion:per-min:opus`),MOTIONGRAPHIC:$K(`motiongraphic`),"transcript:parse":$K(`transcript:parse`),VIBE_EDIT:$K(`vibe-edit`),RESEARCH_SEARCH:$K(`research:search`),RESEARCH_SUMMARIZE:$K(`research:summarize`),MEDIA_ANALYZE:$K(`media:analyze`),MEDIA_CHECK:$K(`media:check`),CONNECTION_ACTION:$K(`connection:action`),"automation:app-events":1,"automation:app-checks":1,CONTEXT_CONNECT:$K(`canvas:context-connect`),"anim2:plan":$K(`anim2:plan`),"anim2:vibe":$K(`anim2:vibe`),"anim2:qa":$K(`anim2:qa`),"anim2:trigger":$K(`anim2:trigger`),"gif:plan":$K(`gif:plan`),"canvas:plan":$K(`canvas:plan`),"canvasChat:build":$K(`canvasChat:build`),"strip:plan":$K(`strip:plan`),"panel:qa":$K(`panel:qa`),IMAGE_MOTION_EFFECT:0}),tq.RESEARCH_SEARCH+tq.RESEARCH_SUMMARIZE,tq.RESEARCH_SUMMARIZE,tq.CONTEXT_CONNECT,tq[`project:assistant`],tq[`chat:web-search`],Object.freeze(Object.fromEntries(Object.entries(wG).map(([e,t])=>[e,XK(t,`build`)]))),ZK(5e-4,`other`),Object.freeze({providerUsd:`0.000300`,readCredits:1,writeCredits:2}),Math.floor(tG/(QK[`automation:app-event`].usd*nG.other)),Math.floor(tG/(QK[`automation:app-check`].usd*nG.other))})),rq=o((()=>{nq()}));function iq(e){let t=sq.get(e);if(!t){let n=UK();t=n.request(oq(e)).finally(()=>n.dispose()),t.catch(()=>{sq.get(e)===t&&sq.delete(e)}),sq.set(e,t)}return t}var aq,oq,sq,cq=o((()=>{qK(),VG(),mK(),rq(),aq=new Set([`image.generate`,`video.generate`,`audio.speech`,`audio.transcribe`,`audio.music`,`audio.sfx`,`web.fetch`,`web.research`,`media.analyze`]),oq=e=>aq.has(e)?`/options?operation=${e}`:`/options`,sq=new Map})),lq=c({blockModelList:()=>uq});async function uq(e,t,n){if(typeof t!=`string`||!hK(e).includes(t))throw Error(`This Block does not declare ${typeof t==`string`?t.slice(0,60):`that operation`}. Declare it in permissions.capabilities, or the media.generate action for image, video, speech, music and sound effects, to list its models.`);if(typeof n==`function`)return n(t);let r;try{r=await iq(t)}catch(e){if(DK())return vK(t);throw e}return _K(t,RG(t,r,{firstFrame:!0}))}var dq=o((()=>{CK(),jK(),cq(),VG()}));k(),ar(),QH(),DH(),Et(),Ei();var fq=`stillmade.block.view.v1`,pq=5e3,mq=()=>globalThis.crypto.randomUUID(),hq=`*{box-sizing:border-box}html{container:stillmade-view/inline-size;overflow-wrap:anywhere}body{min-width:0;margin:0;padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));overflow-x:hidden;background:var(--bg);color:var(--fg);font:16px/1.5 var(--font-body)}h1,h2{font:200 italic clamp(26px,8cqi,32px)/1.1 var(--font-display);letter-spacing:var(--tr-display)}button,input,textarea,select,summary{font:inherit;color:inherit;max-width:100%}button:where(:not(.sm-add,.sm-tile-tools>*)),input,textarea,select{min-height:44px;border:1px solid var(--border-tok);border-radius:var(--r-3);padding:10px 14px;background:transparent}:where(details:not(.sm-hint))>summary{display:flex;align-items:center;min-height:44px;cursor:pointer}.sm-hint>summary{max-width:none}button:where(:not(.sm-add,.sm-tile-tools>*)){min-width:44px;cursor:pointer;border-radius:var(--r-pill);background:var(--fg);color:var(--bg)}button:disabled{opacity:.5;cursor:default}textarea{display:block;width:100%;min-height:120px}input[type=checkbox],input[type=radio]{width:20px;height:20px;min-height:0;padding:0;margin:0 8px 0 0;vertical-align:middle;accent-color:var(--fg)}input[type=range]{width:100%;min-height:32px;padding:0;border:0;accent-color:var(--fg)}img,video,canvas{max-width:100%}:focus-visible{outline:2px solid var(--signal);outline-offset:3px}@container stillmade-view (max-width:360px){body{padding:12px}button,input,textarea,select{font-size:16px}}`,gq=`*{box-sizing:border-box}html{overflow-wrap:anywhere}body{min-width:0;margin:0;padding:16px;overflow-x:hidden;background:var(--bg);color:var(--fg);font:16px/1.5 var(--font-body)}body:has(> [data-stillmade-layout="own"]){padding:0}`,_q=`:where(html){background:Canvas;color:CanvasText}`,vq=`:where(html[data-stillmade-center="1"])>:where(body)>:where(:not([data-stillmade-host])),:where(html[data-stillmade-center="2"])>:where(body)>:where(:not([data-stillmade-host]))>:where(*){margin-inline:auto}`,yq=`html[data-stillmade-pick],html[data-stillmade-pick] *{cursor:crosshair!important}html[data-stillmade-pick] [data-stillmade-media]{display:none!important}`,bq=Object.freeze({image:`image/png,image/jpeg,image/webp,image/gif`,video:`video/*`,audio:`audio/*,video/*`,asset:`image/png,image/jpeg,image/webp,image/gif,audio/*,video/*`,file:Object.entries(nW).filter(([,e])=>e.kind===`file`).map(([e])=>`.${e}`).join(`,`)}),xq=e=>e.filter(e=>typeof e==`string`&&/^[A-Za-z][A-Za-z0-9_-]{0,99}$/.test(e)),Sq=`html[data-stillmade-price]:not([data-stillmade-running]) button[data-stillmade-action="run"]::after{content:" · " var(--stillmade-price)!important;white-space:nowrap}html[data-stillmade-price] button[data-stillmade-action="run"]:is(.sm-primary,.sm-quiet){flex-wrap:wrap;row-gap:0}html[data-stillmade-price] button[data-stillmade-action="run"]:is(.sm-primary,.sm-quiet)::after{margin-inline-start:calc(.28em - var(--s-2,8px))}`,Cq=e=>`html[data-stillmade-readonly] [data-stillmade-add]${xq(e).map(e=>`,[data-stillmade-add="${e}"]`).join(``)}{display:none!important}html[data-stillmade-readonly] [data-stillmade-remove],html[data-stillmade-readonly] [data-stillmade-move]${xq(e).map(e=>`,[data-stillmade-remove="${e}"],[data-stillmade-move="${e}"]`).join(``)}{display:none!important}html[data-stillmade-readonly] [data-stillmade-action="run"]{display:none!important}`;function wq(e,t){let n=typeof t==`string`&&vt(e?.inputs)&&Object.hasOwn(e.inputs,t)?e.inputs[t]:null;if(!vt(n))throw Error(`${JSON.stringify(String(t))} is not an input of this Block.`);let r=String(n.type||``),i=r.replace(/\[\]$/,``);if(!Object.hasOwn(bq,i))throw Error(`${JSON.stringify(t)} is a ${r} input. Only image, video, audio, asset and file inputs take added files.`);return{name:t,port:n,type:i,multiple:r.endsWith(`[]`),accept:bq[i]}}function Tq(e,t){let n=Array.isArray(e)?e:[],r=e=>Number.isInteger(e)&&e>=0&&e<n.length;if(t?.op===`remove`&&r(t.index))return n.filter((e,n)=>n!==t.index);if(t?.op===`move`&&r(t.from)&&r(t.to)){let e=[...n],[r]=e.splice(t.from,1);return e.splice(t.to,0,r),e}throw Error(n.length?`Choose a file from 0 to ${n.length-1}.`:`This input has no files.`)}function Eq({accept:e,multiple:t},n=globalThis.document){let r,i=new Promise(i=>{let a=n.createElement(`input`);a.type=`file`,a.accept=e,a.multiple=!!t,a.hidden=!0;let o=!1;r=e=>{o||(o=!0,a.remove(),i(e))},a.addEventListener(`change`,()=>r(Array.from(a.files||[])),{once:!0}),a.addEventListener(`cancel`,()=>r([]),{once:!0}),n.body.append(a),a.click()});return i.cancel=()=>r([]),i}var Dq=e=>JSON.stringify(e).replace(/</g,`\\u003c`).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`);function Oq(e){if(mt(e),new TextEncoder().encode(JSON.stringify(e)).length>LH.messageBytes)throw Error(`Preview data exceeds 4 MiB`);return structuredClone(e)}var kq=e=>vt(e)&&[`image`,`video`,`audio`].includes(e.kind)&&[`assetId`,`versionId`,`url`].every(t=>typeof e[t]==`string`&&e[t])?ht([e.kind,e.assetId,e.versionId,e.url]):``;function Aq(e){let t=(0,v.useRef)({has:!1,original:null,signature:null,value:null});if(t.current.has&&Object.is(t.current.original,e))return t.current.value;let n=e===void 0?`undefined`:ht(e);return t.current.signature===n?t.current.original=e:t.current={has:!0,original:e,signature:n,value:e},t.current.value}function jq(e,t=[]){return Array.isArray(e)?(e.forEach(e=>jq(e,t)),t):vt(e)?kq(e)?(t.push(e),t):(Object.values(e).forEach(e=>jq(e,t)),t):t}var Mq=e=>Array.isArray(e)?e.length>0&&e.every(Mq):!!kq(e);function Nq(e,t,n){if(!vt(e)||!Object.values(e).length||!Object.values(e).every(Mq))throw Error(`Only complete saved media references can be chosen as outputs.`);let r=new Set(jq(t).map(kq));for(let t of jq(e))if(!r.has(kq(t))&&!n?.authorizesMedia(t))throw Error(`Choose media supplied by this workspace or recorded in this session.`);return Oq(e)}function Pq(e){let t=Oq(e);if(!vt(t)||!_t(t,`image`))throw Error(`Choose a valid image supplied by this workspace.`);if(t.role!==void 0&&(typeof t.role!=`string`||!/^[a-z][a-z0-9_]{0,79}$/.test(t.role)))throw Error(`This image has an invalid semantic role.`);if(!Array.isArray(t.data)&&!([`assetId`,`versionId`,`url`].every(e=>typeof t[e]==`string`&&t[e].length>0)&&t.assetId.length<=512&&t.versionId.length<=512&&t.url.length<=32768))throw Error(`Keep the complete image reference supplied by this workspace.`);return t}function Fq(e,t=LH.imagePreviewEdge){let n=()=>Error(`The host returned an invalid image preview.`),r=Oq(e),i=vt(r)&&Object.keys(r).length===3&&[`url`,`width`,`height`].every(e=>Object.hasOwn(r,e))&&[`width`,`height`].every(e=>Number.isInteger(r[e])&&r[e]>0&&r[e]<=t),a=typeof r?.url==`string`&&/^data:image\/(png|jpeg);base64,[A-Za-z0-9+/]+={0,2}$/.exec(r.url)?.[1];if(!i||!a)throw n();let o=r.url.slice(a===`png`?22:23);if(o.length%4!=0)throw n();if(a===`png`){let e=atob(o.slice(0,44)),t=t=>e.charCodeAt(t),i=e=>t(e)*16777216+t(e+1)*65536+t(e+2)*256+t(e+3);if(e.length<33||![137,80,78,71,13,10,26,10].every((e,n)=>t(n)===e)||i(8)!==13||e.slice(12,16)!==`IHDR`||i(16)!==r.width||i(20)!==r.height)throw n();return r}let s=atob(o.slice(0,4096)),c=e=>s.charCodeAt(e),l=e=>c(e)*256+c(e+1);if(c(0)!==255||c(1)!==216)throw n();for(let e=2;e+9<s.length;){if(c(e)!==255)throw n();let t=c(e+1),i=l(e+2);if(t>=192&&t<=207&&![196,200,204].includes(t)){if(l(e+5)!==r.height||l(e+7)!==r.width)throw n();return r}if(i<2)throw n();e+=2+i}throw n()}var Iq=()=>`__sm_guard_${globalThis.crypto.randomUUID().replaceAll(`-`,``)}`;function Lq(e,t,n=`light`,r=`package`,i=!1,a=[],o=null,s=!1,c=!1,{assets:l={},filming:u=null,inputTypes:d=null,frameGuard:f=null}={}){jH(e);let p=XH(e),m=e.appearance===`none`,h=m?`none`:r===`package`?e.appearance??`host`:r;h===`host`&&!p&&bH(e,{appearance:`host`});let g=(h===`host`?e.themedCss??e.css??``:e.css??``)+`
2103
+ `+(p||m?``:nU),_=globalThis.crypto.randomUUID().replaceAll(`-`,``),v=`__sm_view_${_}`,y=f||Iq(),b=`__sm_media_${globalThis.crypto.randomUUID().replaceAll(`-`,``)}`,x=`(()=>{"use strict";${p?`const codeNonce=document.currentScript.nonce;`:``}document.currentScript.remove();const session=${Dq(t)},channel=${Dq(fq)},send=parent.postMessage.bind(parent);let input={},ready=false,inputRevision=0,editRevision=0,sequence=0,pending=null,pendingAdopt=null,adoptSequence=0,pendingImage=null,imageSequence=0,pendingDesktop=null,desktopSequence=0,pendingAdd=null,addSequence=0,pendingChange=null,changeSequence=0,voiceSequence=0,pendingAllow=null,allowSequence=0,pendingDownload=null,downloadSequence=0;const pendingVoice=new Map(),voiceURLs=new Map(),pendingModels=new Map(),issued=new Map();let modelSequence=0;const addTypes=${Dq(vt(d)?d:null)},addLocked=new Set(${Dq(a.filter(e=>typeof e==`string`))});const addPortProblem=port=>{if(typeof port!=="string"||!port)return "Name the input to add files to, as in StillMade.addFiles('listingPhotos').";if(!addTypes)return "";if(!Object.hasOwn(addTypes,port))return JSON.stringify(port)+" is not an input of this Block. Name a declared image, video, audio, asset or file input.";if(!/^(image|video|audio|asset|file)(\\[\\])?$/.test(addTypes[port]))return JSON.stringify(port)+" is a "+addTypes[port]+" input. Only image, video, audio, asset and file inputs take added files.";return ""};const filesPortProblem=(port,call)=>{if(typeof port!=="string"||!port)return "Name the list input, as in StillMade."+call+"('listingPhotos', 0).";const problem=addPortProblem(port);if(problem)return problem;if(addTypes&&!addTypes[port].endsWith("[]"))return JSON.stringify(port)+" holds one file. StillMade."+call+" changes a list input; StillMade.addFiles replaces a single file.";return ""};const idle=()=>Promise.resolve().then(()=>{if(!pending)document.documentElement?.removeAttribute("data-stillmade-running")});const mediaURLs=new Set();const mintedImages=new Set();Object.defineProperty(globalThis,${Dq(b)},{configurable:true,value:url=>mintedImages.has(url)});const clearMedia=()=>{for(const url of mediaURLs){URL.revokeObjectURL(url);issued.delete(url)}mediaURLs.clear()};const issue=(url,value)=>{if(typeof url!=="string"||!value)return;issued.delete(url);issued.set(url,value);if(issued.size>96)issued.delete(issued.keys().next().value)};const listeners=new Set();let calls=0,started=0;const now=performance.now.bind(performance),resetTask=setTimeout.bind(globalThis);let gestureId=0,gestureAt=-Infinity;for(const type of ["pointerdown","keydown"])addEventListener(type,event=>{if(event.isTrusted){gestureId++;gestureAt=now();}},true);${p?`for(const meta of document.querySelectorAll("meta[http-equiv]"))meta.remove();const frameRuntime=(${$H.toString()})(channel,session,send,${Dq({guardName:y,taskMs:WH.taskMs,assets:l})});const codeAPI=(${eU.toString()})(channel,session,send,codeNonce);`:`const codeAPI=null;Object.defineProperty(globalThis,${Dq(v)},{configurable:true,value:()=>{if(calls===0){started=now();resetTask(()=>{calls=0},0)}if(++calls>10000||now()-started>50)throw Error("Interface is doing too much work. Move processing into the Block runtime.")}});addEventListener("message",event=>{if(event.isTrusted&&event.source===parent)calls=0},true);`}let controlEffects=0;let assisted=false,trackedCalls=new Set(),trackedFailure=null,controlOffset=0;const track=promise=>{if(assisted){trackedCalls.add(promise);promise.then(()=>trackedCalls.delete(promise),error=>{trackedFailure=error;trackedCalls.delete(promise)})}return promise};const controlSnapshot=(offset=controlOffset,automatic=true)=>{try{let snapshot;try{snapshot=dynamicUI.inspectControls({offset})}catch(error){if(!automatic||error.message!=="Choose a current control page"||!Number.isSafeInteger(offset)||offset<0)throw error;snapshot=dynamicUI.inspectControls({offset:0});}controlOffset=snapshot.offset;send({channel,session,op:"view-controls",snapshot},"*")}catch(error){send({channel,session,op:"view-controls-error",error:String(error.message).slice(0,1000)},"*")}};const dynamicUI=(${pr.toString()})(document,error=>send({channel,session,op:"interface-error",error},"*"),()=>Promise.resolve().then(controlSnapshot),{frame:${p?`true`:`false`}});const sharedLifecycle={};const sharedAPI=(${fr.toString()})(channel,session,${Dq(ur)},sharedLifecycle);const textControls=${i?`(()=>{${tr};return StillMadeTextFrame.installTextFrame(document,sharedAPI,error=>send({channel,session,op:"interface-error",error},"*"),channel,session,{token:${Dq(o)},send});})()`:`null`};const sharedControls=(${er.toString()})(document,sharedAPI,error=>send({channel,session,op:"interface-error",error},"*"),textControls,${Dq(a)});const {documentTools,sharedDocuments}=(${nr})(sharedAPI,status=>send({channel,session,op:"document-store-status",status},"*"));const previews=(${jt.toString()})((kind,value,options)=>{if(kind==="media"){if(mediaURLs.size>=${p?WH.mediaPreviews:2})throw Error("Release a previous media preview before opening another");if(!["image","video","audio"].includes(value.kind))throw Error("Choose a picture, audio or video reference");}return new Promise((resolve,reject)=>{const id=String(++imageSequence);pendingImage={id,resolve,reject,media:kind==="media",value};send({channel,session,op:kind==="media"?"preview-media":"preview-image",id,value,...(options?.edge?{edge:options.edge}:{})},"*")})});const connectionAPI=(${kt.toString()})(${Dq(fq)},${Dq(t)},${c},send),workAPI=(${D.toString()})(${Dq(fq)},${Dq(t)},${s},send);const liveBridge=(${At.toString()})(${Dq(fq)},${Dq(t)},send,(operation,args)=>api.desktop(operation,args));const editFiles=(call,port,edit)=>{if(!ready)return Promise.reject(Error("Preview is loading"));const problem=filesPortProblem(port,call);if(problem)return Promise.reject(Object.assign(Error(problem),{code:"FILES_PORT"}));const files=Array.isArray(input[port])?input[port]:[],places=edit.op==="move"?[edit.from,edit.to]:[edit.index];if(!places.every(place=>Number.isInteger(place)&&place>=0&&place<files.length))return Promise.reject(Object.assign(Error(files.length?"Choose a file from 0 to "+(files.length-1)+" in StillMade."+call+".":JSON.stringify(port)+" has no files yet."),{code:"FILES_INDEX"}));if(addLocked.has(port))return Promise.reject(Error("This input comes from an earlier Step, so its files cannot be changed here."));if(assisted)return Promise.reject(Error("Only a person changes files. Chat cannot remove or move them."));if(!sharedAPI.getShared().canEdit)return Promise.reject(Error("You can view this project but not change its files."));if(!gestureId||now()-gestureAt>5000||navigator.userActivation&&!navigator.userActivation.isActive)return Promise.reject(Error("Remove or move files from a click or key press in this screen."));if(pendingChange)return Promise.reject(Error("Files are already being changed."));if(edit.op==="move"&&edit.from===edit.to)return Promise.resolve({files:files.length});return new Promise((resolve,reject)=>{const id=String(++changeSequence);pendingChange={id,resolve,reject};send({channel,session,op:"change-files",id,port,edit,item:files[edit.op==="move"?edit.from:edit.index],gesture:{id:gestureId,age:now()-gestureAt}},"*")})};const api=Object.freeze({...connectionAPI,...workAPI,live:liveBridge.live,${p?`asset:frameRuntime.asset,assetBytes:frameRuntime.assetBytes,loadCode:codeAPI.load,`:``}connectedApp(...args){controlEffects++;return track(connectionAPI.connectedApp(...args))},sharedWork(...args){controlEffects++;return track(workAPI.sharedWork(...args))},previewSharedWorkMedia(...args){controlEffects++;return track(workAPI.previewSharedWorkMedia(...args))},schemaFields:(${mr.toString()})(${JSON.stringify(a)}),...sharedAPI,...documentTools,updateShared(...args){sharedControls.ownSharing();return sharedAPI.updateShared(...args)},connectDocument(...args){sharedControls.ownSharing();return sharedDocuments.connectDocument(...args)},bindShared:sharedControls.bindShared,setSharedDefaults:sharedControls.setSharedDefaults,scheduleSharedEdit:sharedControls.scheduleSharedEdit,render:dynamicUI.render,onAction:dynamicUI.onAction,releaseMedia(url){if(mediaURLs.delete(url)){URL.revokeObjectURL(url);issued.delete(url)}},previewMedia(value){if(!ready)return Promise.reject(Error("Preview is loading"));return track(previews.request("media",value))},desktop(operation,args={}){controlEffects++;if(!ready)return Promise.reject(Error("Preview is loading"));if(pendingDesktop)return Promise.reject(Error("A desktop request is already pending"));if(typeof operation!=="string"||JSON.stringify(args).length>131072)return Promise.reject(Error("Invalid desktop request"));return track(new Promise((resolve,reject)=>{const id=String(++desktopSequence);pendingDesktop={id,resolve,reject};send({channel,session,op:"desktop",id,operation,args},"*")}))},get input(){return structuredClone(input)},onInput(fn){if(typeof fn!=="function")throw Error("Expected a function");listeners.add(fn);if(ready)fn(structuredClone(input));return()=>listeners.delete(fn)},useOutput(values){controlEffects++;if(!ready)return Promise.reject(Error("Preview is loading"));if(pendingAdopt)return Promise.reject(Error("An output choice is already pending"));let serialized;try{serialized=JSON.stringify(values);if(!values||Array.isArray(values)||typeof values!=="object"||serialized.length>4194304)throw Error("Expected bounded output values")}catch(error){return Promise.reject(error)}return track(new Promise((resolve,reject)=>{const id=String(++adoptSequence);pendingAdopt={id,resolve,reject};send({channel,session,op:"use-output",id,outputs:values},"*")}))},addFiles(port){if(!ready)return Promise.reject(Error("Preview is loading"));const problem=addPortProblem(port);if(problem)return Promise.reject(Object.assign(Error(problem),{code:"ADD_FILES_PORT"}));if(addLocked.has(port))return Promise.reject(Error("This input comes from an earlier Step, so files cannot be added to it here."));if(assisted)return Promise.reject(Error("Only a person adds files. Chat cannot open a file picker."));if(!sharedAPI.getShared().canEdit)return Promise.reject(Error("You can view this project but not add files to it."));if(!gestureId||now()-gestureAt>5000||navigator.userActivation&&!navigator.userActivation.isActive)return Promise.reject(Error("Add files from a click or key press in this screen."));if(pendingAdd)return Promise.reject(Error("Files are already being added."));return new Promise((resolve,reject)=>{const id=String(++addSequence);pendingAdd={id,resolve,reject};send({channel,session,op:"add-files",id,port,gesture:{id:gestureId,age:now()-gestureAt}},"*")})},removeFile(port,index){return editFiles("removeFile",port,{op:"remove",index})},moveFile(port,from,to){return editFiles("moveFile",port,{op:"move",from,to})},previewImage(value,options){if(!ready)return Promise.reject(Error("Preview is loading"));return track(previews.request("image",value,options))},allowSpending(request){if(!ready)return Promise.reject(Error("Preview is loading"));const credits=request?.credits,label=request?.label;if(!Number.isSafeInteger(credits)||credits<1||credits>${LH.allowanceCredits})return Promise.reject(Error("Name the total in whole credits, from 1 to ${LH.allowanceCredits}, as in StillMade.allowSpending({credits: 24, label: 'Build the panels'})."));if(typeof label!=="string"||!label.trim()||label.length>120)return Promise.reject(Error("Say what the credits are for, in up to 120 characters."));if(assisted)return Promise.reject(Error("Only a person approves spending. Chat cannot."));if(!gestureId||now()-gestureAt>5000||navigator.userActivation&&!navigator.userActivation.isActive)return Promise.reject(Error("Ask from a click or key press in this screen."));if(pendingAllow)return Promise.reject(Error("A spending approval is already open."));return new Promise((resolve,reject)=>{const id=String(++allowSequence);pendingAllow={id,resolve,reject};send({channel,session,op:"allow-spending",id,credits,label:label.trim(),gesture:{id:gestureId,age:now()-gestureAt}},"*")})},models(operation){if(!ready)return Promise.reject(Error("Preview is loading"));if(typeof operation!=="string"||!/^[a-z]+(\\.[a-z]+)+$/.test(operation))return Promise.reject(Error("Name an operation, as in StillMade.models('image.generate')."));if(pendingModels.size>=8)return Promise.reject(Error("Wait for the model lists already loading."));return new Promise((resolve,reject)=>{const id=String(++modelSequence);pendingModels.set(id,{resolve,reject});send({channel,session,op:"models",id,operation},"*")})},nextRun(plan){if(plan===null||plan===undefined){send({channel,session,op:"next-run",plan:null},"*");return}let text="";try{text=JSON.stringify(plan)}catch{}if(!text||typeof plan!=="object"||Array.isArray(plan)||text.length>262144||!Object.keys(plan).every(key=>key==="items"||key==="hosted")||plan.items!==undefined&&!Array.isArray(plan.items)||plan.hosted!==undefined&&!Array.isArray(plan.hosted))throw TypeError("Describe the next run as {items} (the media.generate items it asks for) and {hosted} (the hosted operations it calls), or null, as in StillMade.nextRun({items:[{operation:'image',settings:{aspectRatio:'1:1'}}]}).");send({channel,session,op:"next-run",plan:JSON.parse(text)},"*")},download(media){if(!ready)return Promise.reject(Error("Preview is loading"));if(!media||typeof media!=="object"||!["image","video","audio"].includes(media.kind)||!["assetId","versionId","url"].every(key=>typeof media[key]==="string"&&media[key]))return Promise.reject(Error("Pass a picture, clip or sound StillMade gave this screen, as in StillMade.download(StillMade.getShared().made[0])."));if(assisted)return Promise.reject(Error("Only a person downloads. Chat cannot."));if(!gestureId||now()-gestureAt>5000||navigator.userActivation&&!navigator.userActivation.isActive)return Promise.reject(Error("Download from a click or key press in this screen."));if(pendingDownload)return Promise.reject(Error("A download is already starting."));return new Promise((resolve,reject)=>{const id=String(++downloadSequence);pendingDownload={id,resolve,reject};send({channel,session,op:"download",id,value:{kind:media.kind,assetId:media.assetId,versionId:media.versionId,url:media.url},gesture:{id:gestureId,age:now()-gestureAt}},"*")})},previewVoice(voice){if(!ready)return Promise.reject(Error("Preview is loading"));if(typeof voice!=="string"||!/^[a-z0-9_-]{1,64}$/.test(voice))return Promise.reject(Error("Name a StillMade voice, as in StillMade.previewVoice('asteria')."));if(voiceURLs.has(voice))return Promise.resolve({url:voiceURLs.get(voice)});if(pendingVoice.size>=4)return Promise.reject(Error("Wait for the voice samples already loading."));return new Promise((resolve,reject)=>{const id=String(++voiceSequence);pendingVoice.set(id,{voice,resolve,reject});send({channel,session,op:"preview-voice",id,voice},"*")})},run(values){controlEffects++;if(!ready)return Promise.reject(Error("Preview is loading"));if(pending)return Promise.reject(Error("A run is already in progress"));try{dynamicUI.assertCommitted();sharedControls.assertNoComposition();}catch(error){return Promise.reject(error);}let serialized;try{serialized=JSON.stringify(values);if(!values||Array.isArray(values)||typeof values!=="object"||serialized.length>4194304)throw Error("Expected bounded input values")}catch(error){return Promise.reject(error)}return track(new Promise((resolve,reject)=>{const id=String(++sequence),requested=JSON.parse(serialized),sourceRevision=inputRevision,localRevision=editRevision,call={id,resolve:value=>{idle();resolve(value)},reject:error=>{idle();reject(error)},sent:false};pending=call;document.documentElement?.setAttribute("data-stillmade-running","");Promise.resolve().then(()=>dynamicUI.flushAll()).then(()=>sharedControls.flushAll()).then(()=>sharedDocuments.flushAll()).then(()=>sharedLifecycle.flushSharedWrites()).then(()=>{dynamicUI.assertCommitted();sharedControls.assertNoComposition();if(pending!==call||!ready)throw Error("Preview was closed before its edits were saved.");if(inputRevision!==sourceRevision||editRevision!==localRevision)throw Error("The input changed while edits were saving. Review it before running again.");const savedText=textControls?.getValues?.()||{};for(const [key,value] of Object.entries(savedText)){const captured=typeof requested[key]==="string"?requested[key]:typeof requested[key]?.text==="string"?requested[key].text:null;if(captured!==null&&captured!==value)throw Error("The input changed while shared text was saving. Review it before running again.");}if(!sharedAPI.getShared().canEdit)throw Error("Shared editing is unavailable or read only.");call.sent=true;send({channel,session,op:"run",id,input:requested,...(gestureId?{gesture:{id:gestureId,age:now()-gestureAt}}:{})},"*");}).catch(error=>{if(pending===call){pending=null;call.reject(error);}});}))}});Object.defineProperty(globalThis,"StillMade",{value:api,writable:false,configurable:false});sharedAPI.onShared(shared=>document.documentElement?.toggleAttribute("data-stillmade-readonly",!shared.canEdit));if(addTypes)for(const node of document.querySelectorAll("[data-stillmade-add],[data-stillmade-remove],[data-stillmade-move]")){const tool=node.hasAttribute("data-stillmade-add")?"":node.hasAttribute("data-stillmade-remove")?"removeFile":"moveFile",problem=tool?filesPortProblem(node.getAttribute(tool==="removeFile"?"data-stillmade-remove":"data-stillmade-move"),tool):addPortProblem(node.getAttribute("data-stillmade-add"));if(problem){send({channel,session,op:"interface-error",error:problem},"*");break;}}addEventListener("click",event=>{const node=event.isTrusted&&event.target&&typeof event.target.closest==="function"?event.target.closest("[data-stillmade-add]"):null;if(!node||node.disabled||node.getAttribute("aria-disabled")==="true")return;event.preventDefault();if(pendingAdd)return;node.setAttribute("aria-busy","true");api.addFiles(node.getAttribute("data-stillmade-add")).catch(error=>{if(error.code==="ADD_FILES_PORT")send({channel,session,op:"interface-error",error:String(error.message).slice(0,1000)},"*")}).finally(()=>node.removeAttribute("aria-busy"))});const shownMedia=node=>{const stage=node.closest(".sm-stage")||document.querySelector(".sm-stage")||document.body;let best=null,most=-1;for(const element of stage.querySelectorAll("img,video,audio")){const value=issued.get(element.currentSrc||element.getAttribute("src")||"");if(!value)continue;const rect=element.getBoundingClientRect(),size=rect.width*rect.height;if(!element.getClientRects().length||size<=most)continue;most=size;best=value}return best};addEventListener("click",event=>{const node=event.isTrusted&&!event.defaultPrevented&&event.target&&typeof event.target.closest==="function"?event.target.closest('[data-stillmade-action="download"]'):null;if(!node||node.disabled||node.getAttribute("aria-disabled")==="true"||pendingDownload)return;const media=shownMedia(node);if(!media)return;event.preventDefault();node.setAttribute("aria-busy","true");api.download(media).catch(()=>{}).finally(()=>node.removeAttribute("aria-busy"))});addEventListener("click",event=>{const node=event.isTrusted&&event.target&&typeof event.target.closest==="function"?event.target.closest("[data-stillmade-remove],[data-stillmade-move]"):null;if(!node||node.disabled||node.getAttribute("aria-disabled")==="true")return;event.preventDefault();if(pendingChange)return;const remove=node.hasAttribute("data-stillmade-remove"),place=name=>{const text=node.getAttribute(name);return text!==null&&/^[0-9]{1,6}$/.test(text)?Number(text):NaN},port=node.getAttribute(remove?"data-stillmade-remove":"data-stillmade-move");node.setAttribute("aria-busy","true");(remove?api.removeFile(port,place("data-index")):api.moveFile(port,place("data-index"),place("data-to"))).catch(error=>{if(error.code==="FILES_PORT")send({channel,session,op:"interface-error",error:String(error.message).slice(0,1000)},"*")}).finally(()=>node.removeAttribute("aria-busy"))});addEventListener("message",event=>{if(event.source!==parent||!event.data||event.data.channel!==channel||event.data.session!==session)return;const data=event.data;if(liveBridge.receive(data))return;if(data.op==="inspect-view-controls"){controlSnapshot(data.offset,false);return;}if(data.op==="locate-view-control"&&typeof data.id==="string"){let rect=null;try{rect=dynamicUI.locateControl(data.control)}catch{}send({channel,session,op:"view-control-rect",id:data.id,rect},"*");return;}if(data.op==="dispatch-named-text"&&typeof data.id==="string"){Promise.resolve().then(()=>textControls.dispatchNative(data.control,data.id)).then(()=>send({channel,session,op:"named-text-result",token:${Dq(o)},id:data.id},"*"),error=>send({channel,session,op:"named-text-result",token:${Dq(o)},id:data.id,error:String(error.message).slice(0,1000)},"*")).finally(()=>send({channel,session,op:"named-text-controls",token:${Dq(o)},snapshot:textControls.inspectNative()},"*"));return;}if(data.op==="inspect-named-text"){if(textControls)send({channel,session,op:"named-text-controls",token:${Dq(o)},snapshot:textControls.inspectNative()},"*");return;}if(data.op==="dispatch-view-control"&&typeof data.id==="string"){if(assisted){send({channel,session,op:"view-control-result",id:data.id,error:"A declared control is already running"},"*");return;}assisted=true;trackedFailure=null;const controlDocumentSeal=sharedDocuments.captureControlSettlement(),controlSharedSeal=sharedLifecycle.captureControlState(),controlInputRevision=inputRevision,controlEffectRevision=controlEffects;const personalControlUnchanged=()=>controlDocumentSeal&&inputRevision===controlInputRevision&&controlEffects===controlEffectRevision&&JSON.stringify(sharedLifecycle.captureControlState())===JSON.stringify(controlSharedSeal)&&!controlSharedSeal.closed&&controlSharedSeal.ready&&!controlSharedSeal.pending&&!controlSharedSeal.queued&&!controlSharedSeal.failed&&sharedDocuments.unchangedControlSettlement(controlDocumentSeal);dynamicUI.dispatchControl(data.control,async()=>{for(let round=0;round<16;round++){await Promise.allSettled(Array.from(trackedCalls));await dynamicUI.flushAll();await sharedControls.flushAll();if(personalControlUnchanged())await sharedDocuments.settleControl(controlDocumentSeal);else await sharedDocuments.flushAll();await sharedLifecycle.flushSharedWrites();await new Promise(resolve=>setTimeout(resolve,0));if(trackedFailure)throw trackedFailure;if(!trackedCalls.size){if(controlDocumentSeal&&!personalControlUnchanged())await sharedDocuments.flushAll();dynamicUI.assertCommitted();sharedControls.assertNoComposition();return;}}throw Error("Declared action did not settle");}).then(()=>send({channel,session,op:"view-control-result",id:data.id},"*"),error=>send({channel,session,op:"view-control-result",id:data.id,error:String(error?.message||"Declared action failed").slice(0,1000)},"*")).finally(()=>{assisted=false;controlSnapshot()});return;}if(data.op==="flush-shared"&&typeof data.id==="string"){Promise.resolve().then(()=>dynamicUI.flushAll()).then(()=>sharedControls.flushAll()).then(()=>sharedDocuments.flushAll()).then(()=>sharedLifecycle.flushSharedWrites()).then(()=>dynamicUI.flushAll()).then(()=>sharedControls.assertNoComposition()).then(()=>send({channel,session,op:"flush-shared-result",id:data.id},"*"),error=>send({channel,session,op:"flush-shared-result",id:data.id,error:String(error?.message||"Pending edits could not be confirmed").slice(0,1000)},"*"));return;}if(data.op==="desktop-result"&&pendingDesktop&&data.id===pendingDesktop.id){const call=pendingDesktop;pendingDesktop=null;data.error?call.reject(Error(data.error)):call.resolve(data.result)}else if(data.op==="add-files-result"&&pendingAdd&&data.id===pendingAdd.id){const call=pendingAdd;pendingAdd=null;data.error?call.reject(Error(data.error)):call.resolve({added:Number.isInteger(data.added)&&data.added>=0?data.added:0})}else if(data.op==="change-files-result"&&pendingChange&&data.id===pendingChange.id){const call=pendingChange;pendingChange=null;data.error?call.reject(Error(data.error)):call.resolve({files:Number.isInteger(data.files)&&data.files>=0?data.files:0})}else if(data.op==="use-output-result"&&pendingAdopt&&data.id===pendingAdopt.id){const call=pendingAdopt;pendingAdopt=null;data.error?call.reject(Error(data.error)):call.resolve(data.outputs)}else if(data.op==="input"){inputRevision+=1;if(pending&&!pending.sent){pending.reject(Error("Preview input changed before its edits were saved."));pending=null;}clearMedia();previews.reset();if(pendingImage)pendingImage.reject(Error("Preview input changed"));pendingImage=null;if(pendingAdopt)pendingAdopt.reject(Error("Preview input changed"));pendingAdopt=null;input=data.input;ready=true;try{sharedControls.useInputDefaults(input)}catch{}for(const fn of listeners)try{fn(structuredClone(input))}catch(error){send({channel,session,op:"interface-error",error:String(error?.message||"The Block interface could not display its input").slice(0,1000)},"*")}}else if(data.op==="result"&&pending?.sent&&data.id===pending.id){const call=pending;pending=null;data.error?call.reject(Error(data.error)):call.resolve(data.outputs)}else if(data.op==="preview-media-result"&&pendingImage?.media&&data.id===pendingImage.id){const call=pendingImage;pendingImage=null;if(data.error)call.reject(Error(data.error));else{try{const url=URL.createObjectURL(data.preview.blob);mediaURLs.add(url);issue(url,call.value);call.resolve({kind:data.preview.kind,url,mimeType:data.preview.blob.type,bytes:data.preview.blob.size,blob:data.preview.blob})}catch(error){call.reject(error)}}}else if(data.op==="code-result"&&codeAPI&&codeAPI.result(data)){}else if(data.op==="download-result"&&pendingDownload&&data.id===pendingDownload.id){const call=pendingDownload;pendingDownload=null;data.error?call.reject(Error(data.error)):call.resolve()}else if(data.op==="run-price"&&document.documentElement){const root=document.documentElement,words=typeof data.words==="string"&&/^(?:[0-9][0-9,.\u00a0\u202f ]{0,20} credits?|your key)$/.test(data.words)?data.words:null;if(words){root.style.setProperty("--stillmade-price",JSON.stringify(words));root.setAttribute("data-stillmade-price","")}else{root.removeAttribute("data-stillmade-price");root.style.removeProperty("--stillmade-price")}}else if(data.op==="allow-spending-result"&&pendingAllow&&data.id===pendingAllow.id){const call=pendingAllow;pendingAllow=null;data.error?call.reject(Error(data.error)):call.resolve({allowed:data.allowed===true,credits:Number.isSafeInteger(data.credits)?data.credits:0})}else if(data.op==="models-result"&&pendingModels.has(data.id)){const call=pendingModels.get(data.id);pendingModels.delete(data.id);data.error?call.reject(Error(data.error)):call.resolve(data.value)}else if(data.op==="preview-voice-result"&&pendingVoice.has(data.id)){const call=pendingVoice.get(data.id);pendingVoice.delete(data.id);if(data.error)call.reject(Error(data.error));else{try{const url=voiceURLs.get(call.voice)||URL.createObjectURL(data.blob);voiceURLs.set(call.voice,url);call.resolve({url})}catch(error){call.reject(error)}}}else if(data.op==="preview-image-result"&&pendingImage&&data.id===pendingImage.id){const call=pendingImage;pendingImage=null;if(data.error){call.reject(Error(data.error));}else{const url=data.preview?.url;if(typeof url==="string"){mintedImages.delete(url);mintedImages.add(url);if(mintedImages.size>64)mintedImages.delete(mintedImages.values().next().value);issue(url,call.value)}call.resolve(data.preview)}}else if(data.op==="dispose"){liveBridge.dispose();clearMedia();for(const url of voiceURLs.values())URL.revokeObjectURL(url);voiceURLs.clear();for(const call of pendingVoice.values())call.reject(Error("Block was closed"));pendingVoice.clear();previews.reset("Preview was reset");dynamicUI.dispose();sharedControls.dispose();textControls?.dispose();sharedDocuments.dispose();if(pendingDesktop)pendingDesktop.reject(Error("Block was closed"));pendingDesktop=null;if(pendingAllow)pendingAllow.reject(Error("Block was closed"));pendingAllow=null;if(pendingDownload)pendingDownload.reject(Error("Block was closed"));pendingDownload=null;if(pendingAdd)pendingAdd.reject(Error("Block was closed"));pendingAdd=null;if(pendingChange)pendingChange.reject(Error("Block was closed"));pendingChange=null;if(pendingAdopt)pendingAdopt.reject(Error("Preview was reset"));pendingAdopt=null;if(pendingImage)pendingImage.reject(Error("Preview was reset"));pendingImage=null;if(pending)pending.reject(Error("Preview was reset"));pending=null;listeners.clear();ready=false}});addEventListener("input",()=>{editRevision+=1;},true);addEventListener("change",()=>{editRevision+=1;},true);addEventListener("compositionstart",()=>{editRevision+=1;},true);addEventListener("keydown",event=>{if(event.key==="Escape"&&!document.documentElement.hasAttribute("data-stillmade-stage"))send({channel,session,op:"escape"},"*")},true);addEventListener("click",event=>{if(event.target.closest?.("a,area"))event.preventDefault()},true);send({channel,session,op:"ready"},"*");})();`,S=`for(const node of document.querySelectorAll("[data-stillmade-share]")){if(!node.id||document.getElementById(node.id)!==node)throw Error("Each shared control needs a unique ID");const bind=()=>StillMade.bindShared(node.getAttribute("data-stillmade-share"),node.id);if(node.tagName==="FIELDSET"&&!node.querySelector('input[type="radio"]')){const wait=new MutationObserver(()=>{if(!node.querySelector('input[type="radio"]'))return;wait.disconnect();try{bind()}catch{}});wait.observe(node,{childList:true,subtree:true});continue}bind()}`,C=p?`document.currentScript.remove();${S}\n${IH(e.javascript||``,y)}`.replace(/<\/script/gi,`<\\/script`):`document.currentScript.remove();((${v})=>{"use strict";delete globalThis[${Dq(v)}];${S}\n${MH(e.javascript||``,v)}\n})(globalThis[${Dq(v)}]);`.replace(/<\/script/gi,`<\\/script`);return`<!doctype html><html data-mode="${[`dark`,`white`].includes(n)?n:`light`}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-${_}'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:;${p?` font-src data: blob:;`:``} connect-src 'none'; frame-src 'none'; worker-src ${p?`blob:`:`'none'`}; object-src 'none'; base-uri 'none'; form-action 'none';"><meta name="referrer" content="no-referrer"><style>${m?_q:`${tU.replace(/@font-face\s*\{[^}]*\}/g,``)}${p?gq:hq}${rU}`}${p?``:vq}${(g||``).replace(/<\/style/gi,`<\\/style`)}${m?``:`@media(pointer:coarse){input,textarea,select{font-size:16px!important}}`}${yq}${Cq(a)}${Sq}</style></head><body>${e.html}${u?`<script nonce="${_}">document.currentScript.remove();${u.replace(/<\/script/gi,`<\\/script`)}<\/script>`:``}<script nonce="${_}">${x.replace(/<\/script/gi,`<\\/script`)}<\/script><script nonce="${_}">document.currentScript.remove();${u?`(${WU.toString()})(${Dq(fq)},${Dq(t)},parent.postMessage.bind(parent));`:``}(${hU.toString()})(${Dq(fq)},${Dq(t)});(${gU.toString()})(${Dq(fq)},${Dq(t)});(${SU.toString()})(${Dq(fq)},${Dq(t)},(${bU.toString()}),"auto",(${xU.toString()}),${!p});(${CU.toString()})(${Dq(fq)},${Dq(t)},(${wU.toString().replace(/<\/script/gi,`<\\/script`)})(),${Dq(NU)},{minted:(()=>{const read=globalThis[${Dq(b)}];delete globalThis[${Dq(b)}];return typeof read==="function"?read:()=>false;})(),filming:${u?`true`:`false`}});(${oU.toString()})(${Dq(fq)},${Dq(t)},((validateCursorAnchor)=>(${aU.toString()}))(${iU.toString()}));(${sU.toString()})(${Dq(fq)},${Dq(t)},(${lU.toString()}));<\/script><script nonce="${_}">${C}<\/script></body></html>`}function Rq({activity:e,declaresFolders:t,session:n}){let[r,i]=(0,v.useState)(!1),a=e?.folders||[],o=e?.entries||[];if(!t&&!o.length)return null;let s=r=>{r.currentTarget.open&&t&&!e&&n.current?.call(`folder.shared`).catch(()=>{})},c=async e=>{i(!0);try{await n.current?.call(`folder.forget`,{folder:e.id})}catch{}finally{i(!1)}};return(0,V.jsxs)(`details`,{className:`bs-block-activity`,onToggle:s,children:[(0,V.jsx)(`summary`,{children:`What this Block did`}),a.length>0&&(0,V.jsx)(`ul`,{className:`bs-block-activity-folders`,children:a.map(e=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{children:`${e.write?`Reads and changes`:`Reads`} files in ${e.name}`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,disabled:r,onClick:()=>c(e),children:`Stop sharing`})]},e.id))}),o.length?(0,V.jsx)(`ul`,{children:o.map(e=>(0,V.jsxs)(`li`,{children:[e.text,e.count>1?` (${e.count} times)`:``]},`${e.at}:${e.text}`))}):(0,V.jsx)(`p`,{children:`Nothing yet.`})]})}function zq({view:e,input:t={},sharedView:n=null,presenceKey:r=null,peers:i=[],actorId:a=null,onSharedChange:o,sharedText:s=null,sharedWork:c=null,connectedApp:l=null,onRun:u,onUseOutput:d,onAddFiles:f,onChangeFiles:p,onPreviewImage:m,onPreviewMedia:h,onPreviewVoice:g,onModels:_,onAllowSpending:y,onRunPrice:b,onRunPriced:S,onDownload:D,runPriceKey:O=null,onError:k,policyContent:A,policyParent:j,currentAppViewPolicy:M=null,title:N=`Block preview`,height:P=480,fitContent:F=!1,resetKey:I=0,theme:ee,appearance:te=`package`,lockedInputKeys:L=[],agentContext:R=null,screenRunRef:ne=null,onGoalSpending:re}){let ie=Aq(e),ae=Aq(A),oe=Aq(j),se=ae?.manifest?.runtime===`module`&&ae.manifest.permissions?.actions||[],ce=[`comfyui`,`capability`].includes(ae?.manifest?.runtime)||!!ae?.manifest?.desktopTools?.length||ae?.manifest?.runtime===`module`&&(!!ae?.manifest?.permissions?.capabilities?.length||se.length>0),le=ae?.capability?.operation===`image.generate`||se.includes(`media.generate`)?9e5:36e4,ue=(0,v.useRef)(null),de=(0,v.useRef)({onSharedChange:o,onRun:u,onUseOutput:d,onAddFiles:f,onChangeFiles:p,onPreviewImage:m,onPreviewMedia:h,onPreviewVoice:g,onModels:_,onAllowSpending:y,onRunPrice:b,onRunPriced:S,onDownload:D,onError:k}),fe=(0,v.useRef)(t),[pe,me]=(0,v.useState)(``),[he,ge]=(0,v.useState)(!1),[_e,ve]=(0,v.useState)(0),ye=(0,v.useRef)(null),be=(0,v.useRef)(null),[z,xe]=(0,v.useState)(null),[Se,Ce]=(0,v.useState)(null),[we,Te]=(0,v.useState)(null),Ee=ae?.manifest?.id||null,[De,Oe]=(0,v.useState)(`auto`),[ke,Ae]=(0,v.useState)(null),je=(0,v.useRef)(De);je.current=De;let Me=e=>{Oe(e),FU(Ee,e)},Ne=(0,v.useRef)(1);Ne.current=De===`auto`?ke?.zoom||1:De;let Pe=(0,v.useRef)(Me);Pe.current=Me;let Fe=(0,v.useContext)(zU),Ie=(0,v.useRef)(Fe);Ie.current=Fe;let[Le,Re]=(0,v.useState)(null),[ze,Be]=(0,v.useState)(null),[Ve,He]=(0,v.useState)(()=>globalThis.document?.documentElement?.dataset.mode||`light`),Ue=(0,v.useRef)(`light`);Ue.current=[`dark`,`white`].includes(ee||Ve)?ee||Ve:`light`;let We=(0,v.useRef)(l);We.current=l;let Ge=(0,v.useRef)(c);Ge.current=c;let Ke=(0,v.useRef)(s);Ke.current=s;let qe=(0,v.useRef)(!1),[Je,Ye]=(0,v.useState)(()=>({enabled:!!s,projectId:s?.projectId??null,placementId:s?.placementId??null})),Xe=()=>{let e={enabled:!!Ke.current,projectId:Ke.current?.projectId??null,placementId:Ke.current?.placementId??null};Ye(t=>t.enabled===e.enabled&&t.projectId===e.projectId&&t.placementId===e.placementId?t:e)};(0,v.useEffect)(()=>{qe.current||Xe()},[!!s,s?.projectId,s?.placementId]);let Ze=Je.enabled,Qe=Je.projectId,$e=Je.placementId,et=!!ze?.count&&!!(ze.dirty||ze.pending||ze.error),tt=!!pe&&et&&pe===ze.error;(0,v.useEffect)(()=>{let e=globalThis.document.documentElement,t=new MutationObserver(()=>He(e.dataset.mode||`light`));return t.observe(e,{attributes:!0,attributeFilter:[`data-mode`]}),()=>t.disconnect()},[]);let nt=(0,v.useMemo)(()=>{try{let e=Oq(t);return{value:e,signature:ht(e)}}catch(e){return{error:e.message}}},[t]);de.current={onSharedChange:o,onRun:u,onUseOutput:d,onAddFiles:f,onChangeFiles:p,onPreviewImage:m,onPreviewMedia:h,onPreviewVoice:g,onModels:_,onAllowSpending:y,onRunPrice:b,onRunPriced:S,onDownload:D,onGoalSpending:re,onError:k},fe.current=nt;let[rt,it]=(0,v.useState)(null),at=M?rt?.handle===M&&rt.allowed:!ae||rt?.content===ae&&rt.parent===oe&&rt.allowed;(0,v.useEffect)(()=>{if(!ae&&!M)return;let e=!0,t=new AbortController;return it(null),(M?T(M,{signal:t.signal}):Promise.all([ae,...oe?[oe]:[]].map(e=>eW(e,{signal:t.signal})))).then(()=>{e&&it({handle:M,content:ae,parent:oe,allowed:!0})},t=>{t?.code===`BLOCK_REVOKED`&&ae&&xi(ae,`${a||`anonymous`}:${r||`preview`}`).catch(()=>{}),e&&(it({handle:M,content:ae,parent:oe,allowed:!1,error:t.message}),de.current.onError?.(t))}),()=>{e=!1,t.abort()}},[ae,oe,M,_e]);let ot=XH(ie)&&ie.files?ie.files:null,[st,ct]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!ot||!at){ct(null);return}let e=!0,t=new AbortController;return ct(null),Promise.resolve().then(()=>(jH(ie),Ti(()=>Promise.resolve().then(()=>(_W(),fW)),void 0))).then(({loadViewAssets:e})=>e(ot,{signal:t.signal})).then(t=>{e&&ct({files:ot,assets:t})},t=>{e&&ct({files:ot,error:String(t?.message||`The interface files could not be loaded.`)})}),()=>{e=!1,t.abort()}},[ie,ot,at]);let lt=ot?st?.files===ot?st:{loading:!0}:null,ut=JSON.stringify([...new Set(L.filter(e=>typeof e==`string`))].sort()),dt=vt(ae?.manifest?.inputs)?ht(Object.fromEntries(Object.entries(ae.manifest.inputs).map(([e,t])=>[e,String(t?.type||``)]))):``,ft=[ie,lt,I,te,_e,a,r,ce,le,F,Ze,Qe,$e,ut,dt,!!ae?.manifest?.sharedWork,ae?.capability?.operation],pt=(0,v.useRef)(null);if(!pt.current||ft.some((e,t)=>!Object.is(e,pt.current.inputs[t]))){let e;try{if(lt?.loading)throw Object.assign(Error(`Loading the interface files.`),{loading:!0});if(lt?.error)throw Error(lt.error);let t=mq(),n=mq(),r=HU(),i=Iq();e={session:t,nativeTextToken:n,codeGuard:i,filming:!!r,html:Lq(ie,t,Ue.current,te,Ze,JSON.parse(ut),n,!!ae?.manifest?.sharedWork,ae?.capability?.operation===`connection.execute`,{assets:lt?.assets||{},filming:r,inputTypes:dt?JSON.parse(dt):null,frameGuard:i}),locked:JSON.parse(ut)}}catch(t){e=t.loading?{loading:!0}:{error:t.message}}pt.current={inputs:ft,document:e}}let mt=pt.current.document,_t=mt?.session;(0,v.useEffect)(()=>{let e=ue.current?.contentWindow;e&&_t&&e.postMessage({channel:fq,session:_t,op:`zoom-mode`,mode:De},`*`)},[De,_t]);let B=/\bdata-stillmade-layout\s*=\s*["']?own\b/.test(typeof ie?.html==`string`?ie.html:``);(0,v.useEffect)(()=>{if(!F||!_t)return;let e=null,t=()=>{e=null;let t=ue.current?.contentWindow,n=IU(ue.current);t&&t.postMessage({channel:fq,session:_t,op:`zoom-space`,height:n},`*`),B&&ue.current&&Te(Math.min(3e4,LU(ue.current)))},n=()=>{clearTimeout(e),e=setTimeout(t,200)},r=null;if(B&&ue.current&&typeof ResizeObserver==`function`){r=new ResizeObserver(n);for(let e=ue.current.parentElement;e&&e!==mt.body;e=e.parentElement)r.observe(e)}let i=B&&!he?[300,1e3,2500].map(e=>setTimeout(t,e)):[];return addEventListener(`resize`,n),()=>{clearTimeout(e),i.forEach(clearTimeout),r?.disconnect(),removeEventListener(`resize`,n)}},[F,_t,B,he]);let yt=(0,v.useMemo)(()=>({state:{},outputs:{},memory:null,canEdit:!0,localOnly:!0}),[mt.session]),bt=(0,v.useRef)(n);bt.current=n??yt;let xt=(0,v.useRef)(null),St=(0,v.useRef)(n==null);St.current=n==null;let Ct=(0,v.useRef)({session:null,count:0}),wt=(0,v.useRef)(null),Tt=(0,v.useRef)(null),Et=(0,v.useRef)(null),Dt=(0,v.useRef)(null),kt=(0,v.useRef)(null),At=(0,v.useRef)(null),jt=(0,v.useRef)(null);At.current={key:r,peers:i,actorId:a};let Nt=(0,v.useRef)(null),Pt=(0,v.useRef)(null),Ft=(0,v.useRef)(O),It=(0,v.useRef)(null);Ft.current=O,It.current={input:nt.signature,error:nt.error,view:ie,policyContent:ae,policyParent:oe,resetKey:I,appearance:te,policyReady:at};let Lt=(0,v.useRef)(null);Lt.current=ht([R?.projectId,R?.placementId,R?.sourceDigest,a].map(e=>e??null));let[Rt,zt]=(0,v.useState)(null),Bt=ht([Mt(),a,Lt.current,mt.session,nt.signature,at].map(e=>e??null));(0,v.useEffect)(()=>{let e=!0;if(zt(null),!R?.projectId||!R?.placementId||!R?.sourceDigest||nt.error||!at||a!==Mt())return()=>{e=!1};let t=Bt;return gt(nt.value).then(n=>{e&&zt({basis:t,value:{version:1,actorId:a,projectId:R.projectId,placementId:R.placementId,sourceDigest:R.sourceDigest,inputDigest:n}})},()=>{e&&zt(null)}),()=>{e=!1}},[Bt]),Rt?.basis===Bt&&Rt.value;let[Vt,Ht]=(0,v.useState)(null),Ut=(0,v.useRef)(null),Wt=(0,v.useRef)(null),Gt=(0,v.useRef)(null),[Kt,qt]=(0,v.useState)(null),[Jt,Yt]=(0,v.useState)(!1),[Xt,Zt]=(0,v.useState)(!1),[Qt,$t]=(0,v.useState)(null);Qt&&Qt.actor===a&&Qt.runtimeActor===Mt()&&Qt.identity===Lt.current&&Qt.session===mt.session&&Object.keys(Qt.authority).every(e=>Qt.authority[e]===It.current[e])&&Qt.evidence,(0,v.useEffect)(()=>{if(!ne)return;let e={async find(e,t){for(let n=0,r=0;r<25;r++){if(!Wt.current)return null;Gt.current?.offset!==n&&await Wt.current.request(`inspect-view-controls`,{offset:n},t);let r=Gt.current;if(!r)return null;let i=e(r.controls||[]);if(i)return i;if(n+=r.controls.length,!r.controls.length||n>=r.total)return null}return null},press(e,t){if(!Wt.current)throw Error(`The declared interface is closed.`);return Wt.current.request(`dispatch-view-control`,{control:{id:e.id,revision:Gt.current?.revision,identity:e.identity}},t)}};return ne.current=e,()=>{ne.current===e&&(ne.current=null)}},[ne]),{...R},ae?.manifest?.id,ae?.manifest?.version,mt.session,nt.signature,bt.current?.canEdit,{...R},mt.session,nt.signature,bt.current?.canEdit,(0,v.useEffect)(()=>{if(Ht(null),qt(null),Zt(!1),Yt(!1),$t(null),me(``),Te(null),Re(null),Be(null),mt.error||mt.loading||!at)return;let e=!0,t=!1,n=!1,i=null,o=null,s=null,c=0,l=0,u=[],d=[],f=[],p=[],m=0,h=0,g=new Set,_=-1/0,v=-1/0,y=e=>{e.isTrusted&&(_=Date.now())};globalThis.document.addEventListener(`pointerdown`,y,!0),globalThis.document.addEventListener(`keydown`,y,!0);let b,x=0,S=null,T=[],D=null,O=0,k=!1,A=0,j=new Set,M=null,N=null,P=null,I=null,ee=null,te=[],L=[],ne=e=>{e!==ee&&(ee=e,Oe({op:`run-price`,words:e}),de.current.onRunPriced?.(e))},re=()=>{if(clearTimeout(N),N=null,!e||!t)return;let n=de.current.onRunPrice,r=M;if(!r||typeof n!=`function`||bt.current?.canEdit===!1){P=null,I?.abort(),I=null,ne(null);return}let i=ht([r,Ft.current]);if(i===P)return;let a=Date.now();if(te=te.filter(e=>a-e<6e4),te.length>=20){P=null,I?.abort(),I=null,ne(null);return}te.push(a),P=i,I?.abort();let o=new AbortController;I=o,Promise.resolve().then(()=>n(structuredClone(r),{signal:o.signal})).then(e=>Ti(async()=>{let{runPriceWords:e}=await Promise.resolve().then(()=>(mK(),tK));return{runPriceWords:e}},void 0).then(({runPriceWords:t})=>t(e))).then(t=>{e&&I===o&&ne(t)},()=>{e&&I===o&&(P=null,ne(null))}).finally(()=>{I===o&&(I=null)})};Pt.current=()=>{N||re()};let oe=0,se=null,pe=0,he=0,_e=null,ve=0,z=XH(ie),Se=null,we=()=>{Se&&globalThis.document.fullscreenElement!==Se&&(Se=null,Oe({op:`media-stage-end`}))};globalThis.document.addEventListener(`fullscreenchange`,we);let Ee=()=>{let t;return t=Rz(ae,{onStatus:n=>{e&&b===t&&xe(n)},onLive:(n,r)=>{e&&b===t?ue.current?.contentWindow?.postMessage({channel:fq,session:mt.session,op:`live`,...n},`*`,r):n.bitmap?.close?.()},onActivity:n=>{e&&b===t&&Ce(n)},storageScope:`${a||`anonymous`}:${r||`preview`}`}),t};b=Ee(),ye.current=b,xe(null),Ce(null);let De=()=>{if(!e||!bt.current?.canEdit)return;let t=b;b=Ee(),ye.current=b,S=null,xe(null),Promise.resolve(t.close()).catch(()=>{})};be.current=De;let Oe=t=>{e&&ue.current?.contentWindow?.postMessage({channel:fq,session:mt.session,...t},`*`)},ke=null,Me=0,Fe=(e,t)=>{let n=Tt.current,r=ue.current,i=n?.parentElement;if(!n||!r||!i)return;let a=Math.max(0,t?.x??0),o=Math.max(0,t?.y??0),s=Math.min(r.clientWidth,(t?.x??0)+(t?.width??0)),c=Math.min(r.clientHeight,(t?.y??0)+(t?.height??0));if(!t||s<=a||c<=o){n.hidden=!0,delete n.dataset.control;return}let l=r.getBoundingClientRect(),u=i.getBoundingClientRect();n.style.transform=`translate(${l.left+r.clientLeft-u.left-i.clientLeft+a}px,${l.top+r.clientTop-u.top-i.clientTop+o}px)`,n.style.width=`${s-a}px`,n.style.height=`${c-o}px`,n.dataset.control=e,n.hidden=!1};Fe(null,null),Et.current=n=>{!e||!t||typeof n!=`string`||ke&&Date.now()-ke.at<1e3||(ke={id:`locate-`+ ++Me,control:n,at:Date.now()},Oe({op:`locate-view-control`,id:ke.id,control:n}))};let Le=new Map,ze=new Set,Ve=0,He=!1,Je=(e,t)=>new Promise(n=>{let r=`film-`+ ++Ve,i=setTimeout(()=>{Le.delete(r),n(null)},6e3);Le.set(r,e=>{clearTimeout(i),Le.delete(r),n(e)}),Oe({op:e,id:r,...t})}),Ye=mt.filming&&ue.current?UU({element:ue.current,placementId:R?.placementId||null,capture:e=>Je(`capture-view`,e),locate:e=>Je(`locate-view-control`,{control:e}),get drawn(){return He},onChange:e=>(ze.add(e),()=>ze.delete(e))}):null,et=null,tt=null,nt=0,rt=!1,it=a,ot=It.current,st=Lt.current,ct=(t,n)=>{if(!e||rt||t?.signal?.aborted||Mt()!==it||Lt.current!==st||tt&&fe.current.signature!==tt.inputIdentity||et&&fe.current.signature!==et.inputIdentity&&fe.current.signature!==n||Object.keys(ot).filter(e=>e!==`input`).some(e=>ot[e]!==It.current[e]))throw rt=!0,Zt(!1),Error(`The declared interface source, account or task changed. Reload the preview before further assisted edits.`)},lt=e=>{if(!et)return;let t=et;et=null,clearTimeout(t.timer),t.context?.signal?.removeEventListener(`abort`,t.abort),Yt(!1),t.reject(e)};Wt.current={request:(e,n,r={})=>new Promise((a,o)=>{try{if(ct(r),!t||et)throw Error(`The declared interface is loading or busy.`);if(e===`dispatch-view-control`&&!r.taskFence)throw Error(`The declared interface requires its active project task.`);let s=String(++nt),c=()=>{rt=!0,Zt(!1),i?.abort(),lt(Error(`Declared action stopped; reload the preview before more assisted edits.`))},l=setTimeout(c,le);et={id:s,op:e,inputIdentity:fe.current.signature,offset:n.offset,context:r,resolve:a,reject:o,timer:l,abort:c},r.signal?.addEventListener(`abort`,c,{once:!0}),e===`dispatch-view-control`&&Yt(!0),Oe({op:e,id:s,...n})}catch(e){o(e)}})},Ut.current={request:(e,n)=>new Promise((r,i)=>{try{if(ct(n),!t||et||tt||!n.taskFence||n.signal?.aborted)throw Error(`The original text requires its idle current task.`);let a=String(++nt),o=()=>{rt=!0,Zt(!1),tt?.id===a&&(tt=null,Yt(!1),i(Error(`Original text stopped; retain its pending request.`)))},s=setTimeout(o,le);tt={id:a,field:e.field,inputIdentity:fe.current.signature,context:n,resolve:r,reject:i,timer:s,abort:o},n.signal?.addEventListener(`abort`,o,{once:!0}),Yt(!0),Oe({op:`dispatch-named-text`,id:a,control:e})}catch(e){i(e)}})};let ut=()=>{if(rt)throw Error(`This previous assisted interface is no longer writable. Reload it to recover.`);return et?.op===`dispatch-view-control`?(ct(et.context),et.context):null},dt=!1,ft=0,pt=[],gt=0,_t=!1,yt=0,Ct=[],Rt=0,zt=0,Bt=[],Vt=null,Kt=!1,Jt={projectId:Qe,placementId:$e,actorId:a},Xt=()=>e&&Ke.current?.projectId===Jt.projectId&&Ke.current?.placementId===Jt.placementId,Qt=e=>({message:String(e?.message||`Shared text failed.`).slice(0,1e3),...typeof e?.code==`string`&&/^[A-Z][A-Z0-9_]{0,79}$/.test(e.code)?{code:e.code}:{}}),en=Ke.current?.projectId&&a?rr({projectId:Ke.current.projectId,actorId:a,headers:ir,onChange:e=>{if(Xt()){if(e.kind===`revoked`){Kt=!0,Oe({op:`shared-view`,value:{...bt.current,canEdit:!1}});return}[`text`,`document`,`resync`].includes(e.kind)&&(e.scope&&e.scope!==`canvas`||Vt===null&&(Vt=setTimeout(()=>{Vt=null,t&&Xt()&&!Kt&&Oe({op:`text-refresh`})},100)))}}}):null,tn=Ge.current?.projectId&&a?rr({projectId:Ge.current.projectId,actorId:a,headers:ir,onChange:e=>{t&&[`document`,`resync`,`revoked`,`connection-access`].includes(e.kind)&&(gt++,Oe({op:`shared-work-refresh`}))}}):null,nn=()=>{t&&Oe({op:`theme`,mode:Ue.current})};jt.current=nn;let rn=`[]`,an=()=>{if(!t)return;let{key:e,peers:n,actorId:r}=At.current,i=!St.current&&e&&localStorage.getItem(`stillmade:show-shared-cursors`)!==`false`?n.filter(t=>t.user_id!==r&&t.selection?.cursor?.visible&&t.selection.cursor.surface===e).slice(0,50).flatMap(e=>{let t=iU(e.selection.cursor.anchor);return t?[{id:String(e.session_id).slice(0,200),label:String(e.label||`Teammate`).slice(0,120),anchor:t}]:[]}):[],a=JSON.stringify(i);a!==rn&&(rn=a,Oe({op:`peer-cursors`,peers:i}))};kt.current=an,window.addEventListener(`stillmade:cursor-preferences`,an),window.addEventListener(`storage`,an);let on=null,sn=()=>{let e=ue.current;if(!e)return null;let t=e.getBoundingClientRect();return{x:t.left+e.clientLeft,y:t.top+e.clientTop,right:t.right,bottom:t.bottom}},cn=()=>{on&&(on.bounds=sn())},ln=()=>{on&&(on=null,window.removeEventListener(`scroll`,cn,{capture:!0}),window.removeEventListener(`resize`,cn))},un=n=>{let r=n.detail;e&&r?.root?.contains?.(ue.current)&&(r.action===`start`&&t&&!on?(on={bounds:sn()},window.addEventListener(`scroll`,cn,{passive:!0,capture:!0}),window.addEventListener(`resize`,cn),Oe({op:`pick-start`})):r.action===`stop`&&on&&(ln(),Oe({op:`pick-stop`})))};window.addEventListener(cU.control,un);let dn=e=>{me(e),de.current.onError?.(Object.assign(Error(e),{shown:!0}))},fn=()=>{e&&(clearInterval(se),_e?.disconnect(),Promise.resolve(b?.call(`live.stop`)).catch(()=>{}),dn(`This interface stopped responding and was closed. Reload it to try again.`),e=!1,i?.abort(),ue.current&&(ue.current.src=`about:blank`))};wt.current=z?()=>{e&&(clearInterval(se),Promise.resolve(b?.call(`live.stop`)).catch(()=>{}),dn(`This interface tried to leave its frame and was closed. Reload it to try again.`),e=!1,i?.abort(),ue.current&&(ue.current.src=`about:blank`))}:null;let pn=()=>{if(typeof PerformanceObserver!=`function`||!PerformanceObserver.supportedEntryTypes?.includes(`longtask`))return;let e=[],t=e=>Array.from(e.attribution||[]).some(e=>e.containerType===`iframe`&&typeof e.containerSrc==`string`&&e.containerSrc.endsWith(`#${mt.session}`));_e=new PerformanceObserver(n=>{for(let r of n.getEntries()){if(!t(r))continue;let n=r.startTime+r.duration;if(e=e.filter(e=>e.end>n-5e3),e.push({end:n,duration:r.duration}),r.duration>=WH.longTaskMs||e.reduce((e,t)=>e+t.duration,0)>=3500)return fn()}});try{_e.observe({type:`longtask`})}catch{_e=null}},mn=()=>{pe=Date.now(),se=setInterval(()=>{if(!e)return clearInterval(se);if(globalThis.document.visibilityState!==`hidden`&&Date.now()-pe>8e3)return fn();Oe({op:`ping`,id:String(++he)})},2e3)};ge(!0);let hn=setTimeout(()=>{e&&!t&&(ge(!1),dn(C()?w():`This Block could not start. Reload it to try again.`),e=!1,i?.abort(),ue.current&&(ue.current.src=`about:blank`))},C()?5e3:15e3),gn=e=>{let t=o;t&&($t(null),o=null,t.controller.abort(),e&&Oe({op:t.media?`preview-media-result`:`preview-image-result`,id:t.id,error:e}))},_n=()=>{if(!t)return;let e=fe.current;if(e.error){gn(`Preview input is unavailable.`),dn(e.error);return}s!==e.signature&&(gn(`Preview input changed. Use its current image.`),s=e.signature,Oe({op:`input`,input:e.value}))};Nt.current=_n;let vn=null,yn=!1,bn=0,xn=[],Sn=null,Cn=0,wn=null,Tn=$n(()=>{if(St.current||!t)return Promise.resolve();if(!e)return Promise.reject(Error(`The Block interface is unavailable. Its latest edits could not be checked.`));if(Sn)return Sn.promise;let n=String(++Cn),r,i,a=new Promise((e,t)=>{r=e,i=t}),o=setTimeout(()=>{Sn?.id===n&&(Sn=null,i(Error(`The Block did not confirm its pending edits. Stay here to recover the draft.`)))},17e3);return Sn={id:n,promise:a,resolve:r,reject:i,timer:o},Oe({op:`flush-shared`,id:n}),a}),En=()=>{if(t&&bt.current)try{let e=Oq(bt.current),t=ht(e);if(t===vn)return;vn=t,Oe({op:`shared-view`,value:e})}catch(e){dn(e.message)}};Dt.current=En;let Dn=t=>{e&&St.current&&(bt.current.outputs=t,En())},On=r=>{let s=r.data;if(z&&e&&vt(s)&&s.op===`navigated`&&s.channel===fq&&s.session===mt.session&&(r.source===null||r.source===ue.current?.contentWindow)){wt.current?.();return}if(!e||r.source!==ue.current?.contentWindow||!vt(s)||s.channel!==fq||s.session!==mt.session)return;if(s.op===`document-ready`){n||(n=!0,Oe({op:`document`,html:mt.html}));return}if(s.op===`view-changed`){He=!0;let e=Array.isArray(s.rects)?s.rects.slice(0,40).filter(e=>vt(e)&&[`x`,`y`,`width`,`height`].every(t=>Number.isFinite(e[t]))):[];for(let t of ze)t(e);return}if(s.op===`capture-view-result`||s.op===`view-control-rect`&&Le.has(s.id)){let e=Le.get(s.id),t=s.rect;if(!e){s.bitmap?.close?.();return}e(s.op===`capture-view-result`?s.bitmap instanceof ImageBitmap?s.bitmap:null:vt(t)&&[`x`,`y`,`width`,`height`].every(e=>Number.isFinite(t[e]))&&t.width>0&&t.height>0?t:null);return}if(s.op===`zoom-key`){Pe.current(s.step===`auto`?`auto`:RU(Ne.current,s.step===`bigger`?yU:-yU));return}if(s.op===`media-stage`){let e=ue.current,t=globalThis.document;if(!e)return;if(s.on===!0){if(!t.fullscreenElement&&globalThis.navigator?.userActivation?.isActive&&t.activeElement===e&&typeof e.requestFullscreen==`function`){Se=e;try{Promise.resolve(e.requestFullscreen()).catch(()=>{Se=null})}catch{Se=null}}}else if(t.fullscreenElement===e){Se=null;try{Promise.resolve(t.exitFullscreen?.()).catch(()=>{})}catch{}}return}if(s.op===`zoom-state`){Ae(e=>{let t={supported:s.supported===!0,zoom:Number.isFinite(s.zoom)?s.zoom:1};return e&&e.supported===t.supported&&e.zoom===t.zoom?e:t});return}if(s.op===`ready`){t||(t=!0,ge(!1),clearTimeout(hn),Oe({op:`zoom-mode`,mode:je.current}),F&&Oe({op:`zoom-space`,height:IU(ue.current)}),z&&(mn(),pn()),nn(),_n(),En(),an(),Oe({op:`inspect-view-controls`,offset:0}),Oe({op:`inspect-named-text`}));return}if(s.op===`flush-shared-result`){if(!Sn||s.id!==Sn.id)return;let e=Sn;Sn=null,clearTimeout(e.timer);let t=s.error||wn;t?e.reject(Error(String(t).slice(0,1e3))):e.resolve({queued:!0});return}if(s.op===`escape`){let e=Date.now();globalThis.document.activeElement===ue.current&&e-oe>=300&&(oe=e,window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Escape`,bubbles:!0})));return}if(s.op===`pong`){z&&typeof s.id==`string`&&(pe=Date.now());return}if(s.op===`unresponsive`){z&&fn();return}if(s.op===`interface-error`){dn(String(s.error||`The Block interface could not display its input`).slice(0,1e3));return}if(s.op===`document-store-status`){let e=s.status;vt(e)&&[`count`,`dirty`,`pending`,`readonly`].every(t=>Number.isInteger(e[t])&&e[t]>=0&&e[t]<=8)&&[`dirty`,`pending`,`readonly`].every(t=>e[t]<=e.count)&&(e.error===null||typeof e.error==`string`&&e.error.length<=1e3)&&Re(e);return}if(s.op===`text-recovery-status`){let e=s.status;Ze&&vt(e)&&Object.keys(e).every(e=>[`count`,`dirty`,`pending`,`readonly`,`error`,`retryable`].includes(e))&&[`count`,`dirty`,`pending`,`readonly`].every(t=>Number.isInteger(e[t])&&e[t]>=0&&e[t]<=100)&&[`dirty`,`pending`,`readonly`].every(t=>e[t]<=e.count)&&(e.error===null||typeof e.error==`string`&&e.error.length<=1e3)&&typeof e.retryable==`boolean`&&Be(e);return}if(!t)return;if(s.op===`pick-hover`){if(!on)return;let e=pU(s.hover),t=on.bounds,n=null;if(e&&t){let r=Math.max(t.x,e.rect.x+t.x),i=Math.max(t.y,e.rect.y+t.y),a=Math.min(t.right,e.rect.x+t.x+e.rect.width),o=Math.min(t.bottom,e.rect.y+t.y+e.rect.height);a>r&&o>i&&(n={...e,rect:{x:r,y:i,width:a-r,height:o-i},cursor:{x:e.cursor.x+t.x,y:e.cursor.y+t.y}})}window.dispatchEvent(new CustomEvent(cU.hover,{detail:{hover:n}}));return}if(s.op===`pick-result`||s.op===`pick-cancel`){if(!on)return;ln();let e=s.op===`pick-result`?mU(s.target):null;e?window.dispatchEvent(new CustomEvent(cU.result,{detail:{target:e}})):window.dispatchEvent(new CustomEvent(cU.cancel));return}if(s.op===`named-text-controls`){if(s.token===mt.nativeTextToken&&Array.isArray(s.snapshot)&&s.snapshot.length<=50){let e=Oq(s.snapshot);e.every(e=>vt(e)&&typeof e.field==`string`&&typeof e.identity==`string`&&typeof e.value==`string`&&e.value.length<=1e4&&typeof e.partial==`boolean`&&typeof e.ready==`boolean`&&typeof e.disabled==`boolean`)&&Ht(e)}return}if(s.op===`named-text-result`){let e=tt;if(!e||s.id!==e.id||s.token!==mt.nativeTextToken)return;try{if(ct(e.context),s.error)throw Error(String(s.error).slice(0,1e3));e.resolve()}catch(t){e.reject(t)}finally{tt=null,clearTimeout(e.timer),e.context.signal?.removeEventListener(`abort`,e.abort),Yt(!1)}return}if(s.op===`view-controls`){try{let e=Oq(s.snapshot);if(!vt(e)||!Number.isSafeInteger(e.revision)||!Number.isSafeInteger(e.total)||e.total<0||e.total>1e4||!Number.isSafeInteger(e.offset)||!Array.isArray(e.controls)||e.controls.length>20||e.controls.some(e=>!vt(e)||typeof e.id!=`string`||typeof e.identity!=`string`||typeof e.action!=`string`||typeof e.disabled!=`boolean`||typeof e.hidden!=`boolean`))throw Error(`Invalid declared interface controls.`);if(Gt.current=e,qt(e),Zt(!rt),et?.op===`inspect-view-controls`&&e.offset===et.offset){let e=et;ct(e.context),et=null,clearTimeout(e.timer),e.context.signal?.removeEventListener(`abort`,e.abort),e.resolve()}}catch(e){lt(e)}return}if(s.op===`view-control-rect`){if(!ke||s.id!==ke.id)return;let{control:e}=ke,t=s.rect;ke=null,Fe(e,vt(t)&&[`x`,`y`,`width`,`height`].every(e=>Number.isFinite(t[e]))&&t.width>0&&t.height>0?t:null);return}if(s.op===`view-controls-error`){lt(Error(String(s.error||`Declared controls are unavailable.`).slice(0,1e3)));return}if(s.op===`view-control-result`){if(et?.op!==`dispatch-view-control`||s.id!==et.id)return;let e=et;try{if(ct(e.context),s.error)throw Error(String(s.error).slice(0,1e3));et=null,clearTimeout(e.timer),e.context.signal?.removeEventListener(`abort`,e.abort),Yt(!1),e.resolve()}catch(e){lt(e)}return}if(s.op===`connected-app-request`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=ft)return;ft=Number(s.id);let t=e=>Oe({op:`connected-app-result`,id:s.id,...e}),n=We.current,r=It.current;pt=pt.filter(e=>Date.now()-e<6e4);try{if(ae?.capability?.operation!==`connection.execute`||!n?.request)throw Error(`Open the saved connected Block to choose its task.`);let i=Ot(s.operation,Oq(s.args));if(i.operation!==`tasks`&&!bt.current?.canEdit)throw Error(`This workspace is read only.`);if(dt||pt.length>=30)throw Error(`Wait for the current task request.`);dt=!0,pt.push(Date.now()),Promise.resolve().then(()=>n.request(i.operation,i.args)).then(i=>{if(!e||n.projectId!==We.current?.projectId||n.placementId!==We.current?.placementId||Object.keys(r).some(e=>r[e]!==It.current[e]))throw Error(`The installed app changed. Open its current workspace.`);t({result:Oq(i)})},e=>t({error:String(e.message||`Task selection failed.`).slice(0,1e3)})).catch(e=>t({error:String(e.message).slice(0,1e3)})).finally(()=>{dt=!1})}catch(e){t({error:String(e.message).slice(0,1e3)})}return}if(s.op===`shared-work-media-request`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=yt)return;yt=Number(s.id);let t=Ge.current,n=It.current,r=gt,i=e=>Oe({op:`shared-work-result`,id:s.id,...e});try{if(!ae?.manifest?.sharedWork||!ae.manifest.permissions?.project?.includes(`work.shared`)||!t?.previewMedia||typeof s.contributionId!=`string`||!/^[0-9a-f-]{36}$/i.test(s.contributionId))throw Error(`Choose a permitted saved creative in this workspace.`);if(Ct=Ct.filter(e=>Date.now()-e<6e4),_t||Ct.length>=60)throw Error(`Wait for the current media preview.`);_t=!0,Ct.push(Date.now()),Promise.resolve().then(()=>t.previewMedia(s.contributionId,{signal:AbortSignal.timeout(3e4)})).then(t=>{if(!e||r!==gt||Object.keys(n).some(e=>n[e]!==It.current[e]))throw Error(`This workspace changed before the creative preview.`);if(!(t.media instanceof Blob)||!t.media.size||t.media.size>67108864||![`image`,`video`,`audio`].includes(t.kind)||!t.media.type.startsWith(t.kind+`/`))throw Error(`This preview exceeds the media limit.`);i(t)},e=>i({error:String(e.message||`Media preview failed.`).slice(0,1e3)})).catch(e=>i({error:String(e.message).slice(0,1e3)})).finally(()=>{_t=!1})}catch(e){i({error:String(e.message).slice(0,1e3)})}return}if(s.op===`shared-work-request`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=yt)return;yt=Number(s.id);let t=e=>Oe({op:`shared-work-result`,id:s.id,...e}),n=Ge.current,r=It.current,i=gt;Ct=Ct.filter(e=>Date.now()-e<6e4);try{if(!ae?.manifest?.permissions?.project?.includes(`work.shared`)||!ae.manifest.sharedWork||!n?.request)throw Error(`Shared work is unavailable in this preview. Open the saved Block in its project.`);let a=E(s.operation,Oq(s.args));if(![`read`,`list`,`accounts`,`grants`,`creatives`].includes(a.operation)&&!bt.current?.canEdit)throw Error(`This workspace is read only.`);if(_t||Ct.length>=60)throw Error(`Wait for the current shared-work request.`);_t=!0,Ct.push(Date.now()),Promise.resolve().then(()=>n.request(a.operation,a.args)).then(o=>{if(!e||n.projectId!==Ge.current?.projectId||n.placementId!==Ge.current?.placementId||Object.keys(r).some(e=>r[e]!==It.current[e]))throw Error(`This Block changed before the shared-work response. Reopen its current version.`);if(i!==gt){if([`read`,`list`,`accounts`,`grants`,`creatives`].includes(a.operation))throw Error(`Saved-work access changed. Read its current version.`);t({result:{saved:!0,refreshRequired:!0}});return}t({result:Oq(o)})},e=>t({error:String(e.message||`Shared work failed.`).slice(0,1e3)})).catch(e=>t({error:String(e.message).slice(0,1e3)})).finally(()=>{_t=!1})}catch(e){t({error:String(e.message).slice(0,1e3)})}return}if(s.op===`text-request`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=zt)return;zt=Number(s.id);let e=e=>Oe({op:`text-result`,id:s.id,...e}),t=Ke.current,n=fe.current.signature,r=It.current;if(Bt=Bt.filter(e=>Date.now()-e<6e4),!Ze||!Xt()||!t||typeof t.request!=`function`||![`read`,`initialize`,`update`,`reset`].includes(s.action)||typeof s.key!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/.test(s.key)||[`constructor`,`prototype`,`__proto__`].includes(s.key)){e({error:{message:`Shared text is unavailable for this field.`}});return}if(Rt>=16||Bt.length>=1200){e({error:{message:`Shared text requests are arriving too quickly. Your draft is retained.`}});return}let i=()=>{if(!Xt()||fe.current.error||fe.current.signature!==n||Object.keys(r).some(e=>r[e]!==It.current[e]))throw Error(`Shared text input or workspace changed. Your draft is retained.`);if(Kt||s.action!==`read`&&!bt.current?.canEdit)throw Object.assign(Error(`Shared text is read only.`),{code:`READ_ONLY`})},a;try{if(i(),a=Oq(s.body),!vt(a)||new TextEncoder().encode(JSON.stringify(a)).length>5e4||Object.keys(a).some(e=>![`protocol`,`requestId`,`sourceIdentity`,`epoch`,`textRevision`,`value`,`update`].includes(e)))throw Error(`Invalid shared text request.`)}catch(t){e({error:Qt(t)});return}Rt++,Bt.push(Date.now()),Promise.resolve().then(async()=>{if(i(),ut()&&s.action!==`read`)throw Error(`Assisted shared-text writes require a task-safe native commit interface; this control is unavailable.`);try{let e=tt,n;if(e&&s.action!==`read`){if(ct(e.context),s.action!==`update`||s.key!==e.field||s.nativeText?.token!==mt.nativeTextToken||s.nativeText?.callId!==e.id)throw Error(`Unrelated text events cannot use this native task.`);n=e.context}else if(s.nativeText)throw Error(`The original text invocation is no longer current; do not replay.`);return await t.request(s.action,{...a,placementId:t.placementId,fieldKey:s.key},n)}catch(e){if(s.action===`read`&&e.code===`SHARED_TEXT_FIELD_UNSUPPORTED`&&typeof bt.current?.state?.[s.key]!=`string`)return{unsupported:!0};throw e}}).then(t=>{i(),e({result:Oq(t)})}).catch(t=>e({error:Qt(t)})).finally(()=>{Rt--});return}if(s.op===`cursor`){let e=s.cursor;if(vt(e)&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1){let t=ue.current?.getBoundingClientRect(),n=iU(e.anchor),r=At.current.key;t&&window.dispatchEvent(new CustomEvent(`stillmade:sandbox-cursor`,{detail:{x:(t.left+e.x*t.width)/Math.max(1,window.innerWidth),y:(t.top+e.y*t.height)/Math.max(1,window.innerHeight),visible:e.visible!==!1,...n&&typeof r==`string`&&r.length>0&&r.length<=200&&!St.current?{anchor:n,surface:r}:{}}}))}return}if(s.op===`shared-view-update`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=bn)return;bn=Number(s.id);let t=e=>{wn=e.error?String(e.error):null,Oe({op:`shared-view-result`,id:s.id,...e})};if(xn=xn.filter(e=>Date.now()-e<6e4),yn||xn.length>=240){t({error:`Shared edits are arriving too quickly. Wait and retry.`});return}if(!bt.current?.canEdit||!St.current&&typeof de.current.onSharedChange!=`function`){t({error:`Shared editing is unavailable or read only.`});return}let n;try{if(n=Oq(s.request),new TextEncoder().encode(JSON.stringify(n)).length>ur.requestBytes)throw Error(`Shared edit exceeds the limit`)}catch(e){t({error:e.message});return}yn=!0,xn.push(Date.now()),Promise.resolve().then(()=>{if(!e||!bt.current?.canEdit)throw Error(`Shared editing is unavailable or read only.`);if(ut(),St.current){bt.current.state=dr(bt.current.state,n),En();return}let t=ut();return t&&xt.current&&xt.current.push(n),de.current.onSharedChange(n,t||void 0)}).then(()=>t({queued:!0}),e=>t({error:String(e.message).slice(0,1e3)})).finally(()=>{yn=!1});return}if(s.op===`content-size`){Number.isInteger(s.height)&&s.height>0&&s.height<=1e5&&Ie.current?.(s.height),F&&Number.isInteger(s.height)&&s.height>0&&s.height<=1e5&&Te(Math.max(280,Math.min(3e4,B?LU(ue.current):s.height)));return}if(s.op===`live-ack`){b?.liveAck?.();return}if(s.op===`desktop`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=x)return;x=Number(s.id);let t=e=>Oe({op:`desktop-result`,id:s.id,...e});if(T=T.filter(e=>Date.now()-e<6e4),S||T.length>=120){t({error:`Too many desktop requests. Wait before trying again.`});return}let n;try{if(n=Oq(s.args||{}),JSON.stringify(n).length>131072||!vt(n))throw Error(`Desktop arguments exceed the limit`)}catch(e){t({error:e.message});return}let r=![`tool.status`,`storage.info`,`storage.list`,`storage.read`,`record.status`,`device.info`,`record.cancel`,`session.close`,`live.status`,`live.stop`,`folder.shared`,`folder.forget`,`folder.list`,`folder.read`].includes(s.operation)&&(s.operation!==`folder.pick`||s.args?.write===!0);if(r&&!bt.current?.canEdit){t({error:`Desktop changes are unavailable while this workspace is read only.`});return}if(s.operation===`record.cut`){let e=n?.source,r=kq(e),i=[];try{i=jq(fe.current?.value).map(kq)}catch{}if(!r||!(b.authorizesMedia(e)||i.includes(r))){t({error:`Cut a video this Block received or recorded in this session.`});return}}let i={native:b};T.push(Date.now()),S=i,Promise.resolve().then(()=>{if(!e||i.native!==b||r&&!bt.current?.canEdit)throw Error(`Desktop access or edit permission changed before this request.`);if(ut()&&r)throw Error(`Assisted desktop mutations require a task-safe native interface; this control is unavailable.`);return i.native.call(s.operation,n,[`record.cut`,`folder.write`].includes(s.operation)?{received:(()=>{try{return jq(fe.current?.value)}catch{return[]}})()}:void 0)}).then(n=>{if(!e||i.native!==b||r&&!bt.current?.canEdit)throw Error(`Desktop access or edit permission changed before this result could be used.`);t({result:Oq(n)})},e=>t({error:String(e.message).slice(0,1e3)})).catch(e=>t({error:String(e.message).slice(0,1e3)})).finally(()=>{S===i&&(S=null)});return}if(s.op===`add-files`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=O)return;O=Number(s.id);let t=e=>Oe({op:`add-files-result`,id:s.id,...e});try{let n=wq(ae?.manifest,s.port);if(!bt.current?.canEdit)throw Error(`You can view this project but not add files to it.`);if(mt.locked.includes(n.name))throw Error(`This input comes from an earlier Step, so files cannot be added to it here.`);if(ut())throw Error(`Only a person adds files. Chat cannot open a file picker.`);if(typeof de.current.onAddFiles!=`function`)throw Error(`Adding files is unavailable here.`);if(D)throw Error(`Files are already being added.`);let r=s.gesture,i=globalThis.navigator?.userActivation;if(!vt(r)||!Number.isInteger(r.id)||r.id<=0||j.has(r.id)||!Number.isFinite(r.age)||r.age<0||r.age>pq||i&&!i.isActive||globalThis.document.activeElement!==ue.current)throw Error(`Add files from a click or key press in this screen.`);j.add(r.id);let a={picker:Eq(n)};D=a,a.picker.then(t=>{if(!e||D!==a)throw Error(`This Block closed before the files were added.`);if(!t.length)return{added:0};if(!bt.current?.canEdit)throw Error(`You can view this project but not add files to it.`);return de.current.onAddFiles(n.name,t,n.port)}).then(e=>t({added:Number.isInteger(e?.added)&&e.added>=0?e.added:0}),e=>t({error:String(e?.message||`The files could not be added.`).slice(0,1e3)})).finally(()=>{D===a&&(D=null)})}catch(e){t({error:String(e.message).slice(0,1e3)})}return}if(s.op===`change-files`){if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=A)return;A=Number(s.id);let e=e=>Oe({op:`change-files-result`,id:s.id,...e});try{let t=wq(ae?.manifest,s.port);if(!t.multiple)throw Error(`${JSON.stringify(t.name)} holds one file. Only a list input's files are removed or moved.`);if(!bt.current?.canEdit)throw Error(`You can view this project but not change its files.`);if(mt.locked.includes(t.name))throw Error(`This input comes from an earlier Step, so its files cannot be changed here.`);if(ut())throw Error(`Only a person changes files. Chat cannot remove or move them.`);if(typeof de.current.onChangeFiles!=`function`)throw Error(`Changing files is unavailable here.`);if(k)throw Error(`Files are already being changed.`);let n=s.gesture,r=globalThis.navigator?.userActivation;if(!vt(n)||!Number.isInteger(n.id)||n.id<=0||j.has(n.id)||!Number.isFinite(n.age)||n.age<0||n.age>pq||r&&!r.isActive||globalThis.document.activeElement!==ue.current)throw Error(`Remove or move files from a click or key press in this screen.`);let i=vt(s.edit)&&s.edit.op===`remove`?{op:`remove`,index:s.edit.index}:vt(s.edit)&&s.edit.op===`move`?{op:`move`,from:s.edit.from,to:s.edit.to}:null;if(!i)throw Error(`Remove or move one file.`);let a=fe.current.value?.[t.name];if(Tq(a,i),ht(Oq(s.item??null))!==ht(a[i.op===`move`?i.from:i.index]))throw Error(`These files changed. Look at them again, then try again.`);j.add(n.id),k=!0,Promise.resolve().then(()=>de.current.onChangeFiles(t.name,i,t.port)).then(t=>e({files:Number.isInteger(t?.files)&&t.files>=0?t.files:0}),t=>e({error:String(t?.message||`The files could not be changed.`).slice(0,1e3)})).finally(()=>{k=!1})}catch(t){e({error:String(t.message).slice(0,1e3)})}return}if(s.op===`use-output`){if(typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let e=e=>Oe({op:`use-output-result`,id:s.id,...e});try{if(ut())throw Error(`Assisted media adoption requires a task-safe native commit interface; this control is unavailable.`);if(z&&!bt.current?.canEdit)throw Error(`This workspace is read only.`);let t=Oq(s.outputs),n=de.current.onUseOutput;if(typeof n!=`function`)throw Error(`Choosing an existing media output is unavailable in this workspace.`);Nq(t,fe.current.value,b),Promise.resolve(n(t)).then(t=>{let n=Oq(t);Dn(n),e({outputs:n})},t=>e({error:String(t?.message||`The media output could not be saved`).slice(0,1e3)}))}catch(t){e({error:String(t.message).slice(0,1e3)})}return}if(s.op===`code`){if(!z||typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let t=e=>Oe({op:`code-result`,id:s.id,...e});if(++ve>WH.codeFiles*4){t({error:`This interface asked for its code files too many times.`});return}Promise.resolve().then(()=>Ti(()=>Promise.resolve().then(()=>(_W(),fW)),void 0)).then(({loadViewCode:e})=>e(ie.files,s.path,{guard:mt.codeGuard})).then(n=>{e&&t({source:n})},n=>{e&&t({error:String(n?.message||`This code file could not be loaded.`).slice(0,1e3)})});return}if(s.op===`allow-spending`){if(typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let t=e=>Oe({op:`allow-spending-result`,id:s.id,...e}),n=vt(s.gesture)&&Number.isInteger(s.gesture.id)&&s.gesture.id>0&&Number.isFinite(s.gesture.age)&&s.gesture.age>=0&&s.gesture.age<=pq&&!g.has(s.gesture.id)&&!!globalThis.navigator?.userActivation?.isActive&&globalThis.document.activeElement===ue.current&&Date.now()-_>pq,r=de.current.onAllowSpending;if(typeof r!=`function`){t({error:`Spending approvals are for Steps in a project.`});return}if(!Number.isSafeInteger(s.credits)||s.credits<1||s.credits>LH.allowanceCredits||typeof s.label!=`string`||!s.label.trim()||s.label.length>120){t({error:`Name the total in whole credits and what it is for.`});return}let i=!n&&typeof de.current.onGoalSpending==`function`&&de.current.onGoalSpending()===!0;if(!n&&!i){t({error:`Ask from a click or key press in this screen.`});return}n&&g.add(s.gesture.id),Promise.resolve().then(()=>r({credits:s.credits,label:s.label.trim(),...i?{goal:!0}:{}})).then(n=>{e&&t({allowed:Number.isSafeInteger(n)&&n>0,credits:Number.isSafeInteger(n)?n:0})},n=>{e&&t({error:String(n?.message||`The approval did not open.`).slice(0,1e3)})});return}if(s.op===`next-run`){let e=null;try{e=s.plan==null?null:Oq(s.plan)}catch{e=null}M=vt(e)?e:null,clearTimeout(N),M?N=setTimeout(re,400):re();return}if(s.op===`download`){if(typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let t=e=>Oe({op:`download-result`,id:s.id,...e});if(!(vt(s.gesture)&&Number.isInteger(s.gesture.id)&&s.gesture.id>0&&Number.isFinite(s.gesture.age)&&s.gesture.age>=0&&s.gesture.age<=pq&&!g.has(s.gesture.id)&&globalThis.navigator?.userActivation?.isActive&&globalThis.document.activeElement===ue.current&&Date.now()-_>pq)){t({error:`Download from a click or key press in this screen.`});return}let n=de.current.onDownload;if(typeof n!=`function`){t({error:`Downloads are for Steps in a project.`});return}let r=Date.now();if(L=L.filter(e=>r-e<6e4),L.length>=10){t({error:`Download limit reached. Wait a minute before trying again.`});return}let i=null;try{i=Oq(s.value)}catch{}let a=kq(i),o=[];try{o=jq([fe.current?.value,bt.current?.outputs,bt.current?.made]).map(kq)}catch{}if(!a||!(o.includes(a)||b?.authorizesMedia?.(i))){t({error:`Download a picture, clip or sound this screen was given or made.`});return}g.add(s.gesture.id),L.push(r),Promise.resolve().then(()=>n({kind:i.kind,assetId:i.assetId,versionId:i.versionId,url:i.url})).then(()=>{e&&t({})},n=>{e&&t({error:String(n?.message||`The download did not start.`).slice(0,1e3)})});return}if(s.op===`models`){if(typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let t=e=>Oe({op:`models-result`,id:s.id,...e}),n=Date.now();if(p=p.filter(e=>n-e<6e4),p.length>=30){t({error:`Model list limit reached. Wait a minute before asking again.`});return}p.push(n),Promise.resolve().then(()=>Ti(()=>Promise.resolve().then(()=>(dq(),lq)),void 0)).then(({blockModelList:e})=>e(ae?.manifest,s.operation,de.current.onModels)).then(n=>{e&&t({value:n})},n=>{e&&t({error:String(n?.message||`The model list could not be loaded.`).slice(0,1e3)})});return}if(s.op===`preview-voice`){if(typeof s.id!=`string`||!/^[0-9]{1,9}$/.test(s.id))return;let t=e=>Oe({op:`preview-voice-result`,id:s.id,...e}),n=Date.now();if(f=f.filter(e=>n-e<6e4),f.length>=LH.voicePreviewsPerMinute){t({error:`Voice sample limit reached. Wait a minute before trying again.`});return}f.push(n);let r=de.current.onPreviewVoice;if(typeof r!=`function`||!(ae?.manifest?.permissions?.capabilities||[]).includes(`audio.speech`)){t({error:`Voice samples are for Blocks that make speech (audio.speech).`});return}if(typeof s.voice!=`string`||!/^[a-z0-9_-]{1,64}$/.test(s.voice)){t({error:`Name a StillMade voice.`});return}Promise.resolve().then(()=>r(s.voice)).then(n=>{if(e){if(!(n instanceof Blob)||!/^audio\//.test(n.type))throw Error(`The voice sample could not be loaded.`);t({blob:n})}},n=>{e&&t({error:String(n?.message||`The voice sample could not be loaded.`).slice(0,1e3)})});return}if(s.op===`preview-image`||s.op===`preview-media`){let t=s.op===`preview-media`;if(typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=l)return;$t(null),l=Number(s.id);let n=e=>Oe({op:t?`preview-media-result`:`preview-image-result`,id:s.id,...e}),r=Date.now();if(d=d.filter(e=>r-e<6e4),o&&gn(),d.length>=LH.imagePreviewsPerMinute){++h<=3&&n({error:`Image preview limit reached. Wait a minute before trying again.`}),h===4&&(dn(`Preview paused after too many image requests. Reset it to continue.`),e=!1,gn(),i?.abort(),ue.current&&(ue.current.src=`about:blank`));return}d.push(r);let c=t||s.edge===void 0?void 0:s.edge;if(c!==void 0&&!(Number.isInteger(c)&&c>=64&&c<=LH.imagePreviewMaxEdge)){n({error:`Ask for an image preview edge from 64 to ${LH.imagePreviewMaxEdge} pixels.`});return}let u;try{if(u=t?Oq(s.value):Pq(s.value),t&&(!vt(u)||![`image`,`video`,`audio`].includes(u.kind)||![`assetId`,`versionId`,`url`].every(e=>typeof u[e]==`string`&&u[e].length>0&&u[e].length<=32768)))throw Error(`Keep the complete picture, audio or video reference supplied by this workspace.`)}catch(e){n({error:e.message});return}let f=t&&Zn(u),p=f?(e,t)=>Jn({kind:`audio`,url:e.url},t):t&&b?.authorizesMedia?.(u)?(e,t)=>Jn(e,t):t?de.current.onPreviewMedia:de.current.onPreviewImage;if(typeof p!=`function`){n({error:t?`Audio/video preview is unavailable in this workspace.`:`Image preview is unavailable in this workspace. Choose an image with the host controls.`});return}let m=new AbortController,g=It.current,_={controller:m,id:s.id,media:t};o=_;let v=Lt.current,y=a,x=Mt(),S=()=>{if(m.signal.aborted||x!==Mt()||v!==Lt.current||Object.keys(g).some(e=>g[e]!==It.current[e]))throw Error(`Image preview input or workspace changed.`)},C=setTimeout(()=>{e&&o===_&&gn(`Image preview timed out. Try a smaller image.`)},LH.imagePreviewMs);m.signal.addEventListener(`abort`,()=>clearTimeout(C),{once:!0}),Promise.resolve().then(()=>(S(),p(u,{signal:m.signal,...c?{edge:c}:{}}))).then(r=>{if(e&&!m.signal.aborted&&o===_){if(S(),t&&r?.kind!==u.kind)throw Error(`The host returned a different media kind.`);let e=t?Kn(r):Fq(r,c);S(),!f&&typeof u.assetId==`string`&&u.assetId.length<=512&&typeof u.versionId==`string`&&u.versionId.length<=512&&$t({actor:y,runtimeActor:x,identity:v,session:mt.session,authority:g,evidence:{assetId:u.assetId,versionId:u.versionId,kind:t?e.kind:`image`,mime:t?e.blob.type:e.url.startsWith(`data:image/jpeg`)?`image/jpeg`:`image/png`,...t?{byteLength:e.blob.size}:{width:e.width,height:e.height},status:`broker-loaded`}}),n({preview:e})}},t=>{e&&!m.signal.aborted&&o===_&&n({error:String(t?.message||`This image could not be previewed`).slice(0,1e3)})}).catch(t=>{e&&!m.signal.aborted&&o===_&&n({error:String(t?.message||`This image could not be previewed`).slice(0,1e3)})}).finally(()=>{clearTimeout(C),o===_&&(o=null)});return}if(s.op!==`run`||typeof s.id!=`string`||!/^\d{1,9}$/.test(s.id)||Number(s.id)<=c)return;c=Number(s.id);let y=e=>Oe({op:`result`,id:s.id,...e});if(z&&!bt.current?.canEdit){y({error:`Shared editing is unavailable or read only.`});return}let C=Date.now();if(u=u.filter(e=>C-e<6e4),i||u.length>=LH.runsPerMinute){++m<=3&&y({error:i?`A run is already in progress`:`Preview run limit reached. Wait a minute before trying again.`}),m===4&&(dn(`Preview paused after too many requests. Reset it to continue.`),e=!1,gn(),i?.abort(),ue.current&&(ue.current.src=`about:blank`));return}let w;try{if(!vt(s.input))throw Error(`Expected input values`);w=Oq(s.input)}catch(e){y({error:e.message});return}u.push(C),me(``);let P=new AbortController;i=P,qe.current=!0,et?.context.signal?.addEventListener(`abort`,()=>P.abort(),{once:!0});let I=setTimeout(()=>{e&&i===P&&(P.abort(),i=null,y({error:ce?`Preview confirmation or execution timed out. Cancellation was requested; the backend may still be finishing.`:`Preview execution timed out. Try a smaller input.`}))},ce?le:15e3);P.signal.addEventListener(`abort`,()=>clearTimeout(I),{once:!0});let ee=et?.op===`dispatch-view-control`?et:null,te=ee?async e=>{if(et!==ee||i!==P||P.signal.aborted||!vt(e)||e.receipt?.status!==`completed`||e.receipt.saved!==!0||ht(e.taskFence)!==ht(ee.context.taskFence)||ht([e.projectId,e.placementId,e.sourceDigest,e.actorId])!==st||ht(Oq(e.beforeInput))!==ee.inputIdentity)throw Error(`The native input commit does not match this active declared action.`);let t=ht(Oq(e.input));for(let e=0;e<25&&fe.current.signature!==t;e++)if(ct(ee.context,t),await new Promise(e=>setTimeout(e,10)),et!==ee||i!==P||P.signal.aborted)throw Error(`The native input commit was stopped before its render.`);if(ct(ee.context,t),fe.current.signature!==t)throw Error(`The native input commit does not match the current rendered inputs.`);ee.inputIdentity=t}:void 0,R=vt(s.gesture)&&Number.isInteger(s.gesture.id)&&s.gesture.id>0&&Number.isFinite(s.gesture.age)&&s.gesture.age>=0&&s.gesture.age<=pq&&!g.has(s.gesture.id)&&!!globalThis.navigator?.userActivation?.isActive&&globalThis.document.activeElement===ue.current&&Date.now()-_>pq&&Date.now()-v>pq;R&&(g.add(s.gesture.id),v=Date.now()),Promise.resolve().then(()=>de.current.onRun(w,{...ut(),signal:P.signal,userActivated:R,...te?{onInputCommitted:te}:{},...ae?.manifest?.desktopTools?.length?{nativeDesktopSession:b}:{}})).then(t=>{if(e&&!P.signal.aborted){if(!vt(t))throw Error(`Block execution must return named outputs`);let e=Oq(t);Dn(e),y({outputs:e})}},t=>{e&&!P.signal.aborted&&y({error:String(t?.message||`The Block could not run`).slice(0,1e3)})}).catch(t=>{e&&!P.signal.aborted&&y({error:String(t.message).slice(0,1e3)})}).finally(()=>{clearTimeout(I),i===P&&(i=null),qe.current=!1,setTimeout(()=>{e&&!qe.current&&Xe()},250)})};return window.addEventListener(`message`,On),()=>{clearTimeout(N),I?.abort(),ee&&de.current.onRunPriced?.(null),Pt.current=null,D?.picker.cancel(),globalThis.document.removeEventListener(`fullscreenchange`,we),Se&&globalThis.document.fullscreenElement===Se&&Promise.resolve(globalThis.document.exitFullscreen?.()).catch(()=>{}),Se=null,Et.current=null,Fe(null,null),Ye?.();for(let e of[...Le.values()])e(null);tt&&=(clearTimeout(tt.timer),tt.context.signal?.removeEventListener(`abort`,tt.abort),tt.reject(Error(`Original text closed; retain its pending request.`)),null),globalThis.document.removeEventListener(`pointerdown`,y,!0),globalThis.document.removeEventListener(`keydown`,y,!0),Ut.current=null,lt(Error(`The declared interface was closed.`)),Wt.current=null,en?.(),tn?.(),clearTimeout(Vt),Tn(),Sn&&=(clearTimeout(Sn.timer),Sn.reject(Error(`Block closed before pending edits were confirmed.`)),null),clearTimeout(hn),clearInterval(se),_e?.disconnect(),Oe({op:`dispose`}),e=!1,b.close(),ye.current===b&&(ye.current=null),be.current===De&&(be.current=null),gn(),i?.abort(),qe.current=!1,window.removeEventListener(`message`,On),window.removeEventListener(`stillmade:cursor-preferences`,an),window.removeEventListener(`storage`,an),window.removeEventListener(cU.control,un),ln(),kt.current=null,Nt.current=null,Dt.current=null}},[mt,at,ce,le,F,r,a,Qe,$e]),(0,v.useEffect)(()=>{Nt.current?.()},[t]),(0,v.useEffect)(()=>{Pt.current?.()},[O]),(0,v.useEffect)(()=>{Dt.current?.(),Pt.current?.(),n?.canEdit===!1&&Promise.resolve(ye.current?.close()).catch(()=>{})},[n,at]),(0,v.useEffect)(()=>{kt.current?.()},[i,r,a,n]),(0,v.useEffect)(()=>{jt.current?.()},[ee,Ve]);let en=!!globalThis.stillmadeDesktop?.blockDesktop,tn=z?.camera&&z?.microphone?`camera and microphone`:z?.camera?`camera`:`microphone`;return(0,V.jsxs)(`div`,{className:`bs-sandbox-ui`,style:{position:`relative`},children:[z?.kind===`live`&&z.awaitingStart&&(0,V.jsxs)(`div`,{className:`bs-notice`,role:`status`,children:[(0,V.jsx)(`p`,{children:`Ready to share your ${tn} live with this Block. It receives nothing until you press Start, and nothing is saved.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:z.start,children:`Start ${tn}`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ye.current?.close(),children:`Cancel`})]}),z?.kind===`live`&&z.active&&(0,V.jsxs)(`div`,{role:`status`,className:`bs-notice`,children:[(0,V.jsx)(`strong`,{children:`${tn[0].toUpperCase()}${tn.slice(1)} on`}),(0,V.jsx)(`span`,{children:` · Shared live with this Block. Nothing is saved.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:z.stop,children:`Turn off ${tn}`})]}),z?.awaitingStart&&(z.kind===`folder`||z.kind===`folder-access`)&&(0,V.jsxs)(`div`,{className:`bs-notice`,role:`status`,children:[(0,V.jsx)(`p`,{children:z.kind===`folder`?`This Block asks for a folder to ${z.write?`read and change`:`read`}. It reaches only the folder you choose.`:`Allow StillMade to use ${z.folder} again for this Block.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:z.start,children:z.kind===`folder`?`Choose folder`:`Allow`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>z.cancel?z.cancel():ye.current?.close(),children:`Cancel`})]}),z?.awaitingStart&&![`live`,`folder`,`folder-access`].includes(z.kind)&&(0,V.jsxs)(`div`,{className:`bs-notice`,role:`status`,children:[(0,V.jsx)(`p`,{children:z.kind===`camera`?`Ready to record your camera. This Block records only after you press Start.`:z.kind===`microphone`?`Ready to record your microphone. This Block records only after you press Start.`:z.microphone?`Ready to record your screen with your microphone. Choose your screen or window after pressing Start.`:`Ready to record. Choose your screen or window after pressing Start.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:z.start,children:z.kind===`camera`?`Start camera recording`:z.kind===`microphone`?`Start microphone recording`:`Start screen recording`}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ye.current?.close(),children:`Cancel`})]}),z?.active&&z.kind!==`live`&&(0,V.jsxs)(`div`,{role:`status`,className:`bs-notice`,children:[(0,V.jsxs)(`strong`,{children:[z.ended?`Recording stopped`:`Recording`,` `,z.kind||`media`]}),(0,V.jsxs)(`span`,{children:[` · `,z.ended?z.message:en?`This Block has temporary desktop access.`:`Recording runs in StillMade, outside the Block.`]}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ye.current?.close(),children:en?`Cancel recording and revoke access`:`Discard recording`})]}),en&&z?.closed&&ae?.manifest?.permissions?.desktop?.length>0&&(0,V.jsx)(`button`,{type:`button`,className:`btn`,disabled:!at||!bt.current?.canEdit,onClick:()=>be.current?.(),children:`Reopen desktop access`}),en&&!z?.closed&&!z?.active&&ae?.manifest?.permissions?.desktop?.length>0&&(0,V.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ye.current?.close(),children:`Revoke this Block’s desktop access`}),mt.loading?(0,V.jsx)(Sr,{label:`Loading the interface…`}):mt.error?(0,V.jsxs)(`p`,{role:`alert`,children:[`This interface cannot be previewed: `,mt.error]}):at?(0,V.jsxs)(V.Fragment,{children:[he&&!pe&&(0,V.jsx)(`p`,{className:`sm-status`,"data-state":`loading`,role:`status`,children:`Opening this Block…`}),(0,V.jsx)(`iframe`,{ref:ue,onLoad:()=>{Ct.current.session!==mt.session&&(Ct.current={session:mt.session,count:0}),++Ct.current.count>2&&wt.current?.()},title:N,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,src:`${x(`/block-ui-sandbox.html`)}#${mt.session}`,style:{width:`100%`,height:F&&we||P,minHeight:280,border:`1px solid var(--border-tok)`,borderRadius:`var(--r-3)`,background:`var(--bg)`,...pe&&!tt?{display:`none`}:{}}},mt.session),(0,V.jsx)(`span`,{ref:Tt,hidden:!0,"aria-hidden":`true`,"data-agent-control-anchor":``,style:{position:`absolute`,left:0,top:0,pointerEvents:`none`}})]}):(0,V.jsx)(`p`,{role:rt?.error?`alert`:`status`,children:rt?.error||`Checking Block safety…`}),Le?.count>0&&(Le.error?(0,V.jsx)(`p`,{role:`alert`,className:`bs-notice`,children:Le.error}):Le.dirty||Le.pending?(0,V.jsx)(`p`,{role:`status`,className:`bs-notice`,children:`Sharing changes…`}):null),ze?.count>0&&(ze.error||ze.dirty||ze.pending)?(0,V.jsxs)(`div`,{className:`bs-notice`,role:ze.error?`alert`:`status`,children:[(0,V.jsx)(`p`,{children:ze.error||`Saving shared text…`}),ze.error&&(0,V.jsx)(`p`,{children:`Your text is retained here. Copy it before leaving; reloading cannot safely recover an unacknowledged draft.`}),ze.retryable&&(0,V.jsx)(`button`,{type:`button`,className:`btn`,disabled:ze.pending>0||!bt.current?.canEdit,onClick:()=>ue.current?.contentWindow?.postMessage({channel:fq,session:mt.session,op:`text-retry`},`*`),children:`Retry save`})]}):null,(pe||rt?.error)&&(0,V.jsxs)(V.Fragment,{children:[pe&&!tt&&(0,V.jsx)(`p`,{role:`alert`,children:pe}),(0,V.jsx)(`button`,{type:`button`,className:`btn`,disabled:et,onClick:()=>{et||ve(e=>e+1)},children:`Reload`})]}),(0,V.jsx)(Rq,{activity:Se,declaresFolders:(ae?.manifest?.permissions?.desktop||[]).includes(`folder.read`),session:ye})]})}ut();var Bq=50,Vq=new Intl.NumberFormat(void 0,{maximumFractionDigits:4});new Intl.NumberFormat(void 0,{maximumFractionDigits:1});var Hq=e=>e==null?``:typeof e==`number`?Vq.format(e):String(e);function Uq(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}function Wq({value:e,label:t=`Table`}){let[n,r]=(0,v.useState)(0);if(!Ye(e))return(0,V.jsx)(`p`,{role:`alert`,children:`This result is not a valid table.`});let i=Math.max(1,Math.ceil(e.rows.length/Bq)),a=Math.min(n,i-1),o=e.rows.slice(a*Bq,a*Bq+Bq),s=e.columns.map(t=>e.rows.length>0&&e.rows.every(e=>e[t]===void 0||e[t]===null||typeof e[t]==`number`));return(0,V.jsxs)(`div`,{className:`bd-table`,children:[(0,V.jsx)(`div`,{className:`bd-table-scroll`,tabIndex:0,role:`region`,"aria-label":`${t}, ${e.rows.length} rows`,children:(0,V.jsxs)(`table`,{children:[(0,V.jsx)(`thead`,{children:(0,V.jsx)(`tr`,{children:e.columns.map(e=>(0,V.jsx)(`th`,{scope:`col`,children:e},e))})}),(0,V.jsx)(`tbody`,{children:o.map((t,n)=>(0,V.jsx)(`tr`,{children:e.columns.map((e,n)=>(0,V.jsx)(`td`,{className:s[n]?`bd-number`:void 0,children:Hq(t[e])},e))},a*Bq+n))})]})}),(0,V.jsxs)(`div`,{className:`bd-bar`,children:[(0,V.jsxs)(`span`,{children:[e.rows.length,` `,e.rows.length===1?`row`:`rows`,i>1?` · page ${a+1} of ${i}`:``]}),i>1&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:a===0,onClick:()=>r(a-1),children:`Previous`}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:a>=i-1,onClick:()=>r(a+1),children:`Next`})]}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>Uq(new Blob([$e(e)],{type:`text/csv`}),`${t.replace(/[^\w-]+/g,`-`).toLowerCase()||`table`}.csv`),children:`Download CSV`})]})]})}Et(),ut();var Gq=new Set([`image`,`audio`,`video`]),Kq=e=>Gq.has(e?.kind)&&typeof e.url==`string`,qq=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,Jq=e=>{let t=String(e).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)},Yq=50,Xq=e=>Object.keys(e).filter(t=>t!==`schemaVersion`&&e[t]!==void 0&&e[t]!==null&&e[t]!==``),Zq=e=>{if(!vt(e))return e;let t=Xq(e);return t.length===1&&(Array.isArray(e[t[0]])||vt(e[t[0]]))?Zq(e[t[0]]):e},Qq=e=>e===null||[`string`,`number`,`boolean`].includes(typeof e),$q=e=>typeof e==`boolean`?e?`Yes`:`No`:String(e??``),eJ=e=>{let t=t=>/^start/i.test(t)?e.find(e=>/^end/i.test(e)&&e.slice(3).toLowerCase()===t.slice(5).toLowerCase()):void 0,n=new Set(e.map(t).filter(Boolean));return e.filter(e=>!n.has(e)).flatMap(e=>t(e)?[e,t(e)]:[e])};function tJ(e){if(e.length<2||!e.every(e=>vt(e)&&Xq(e).every(t=>Qq(e[t]))))return null;let t=eJ([...new Set(e.flatMap(Xq))]);if(!t.length||t.length>6)return null;let n={columns:t.map(Jq),rows:e.map(e=>Object.fromEntries(Xq(e).map(t=>[Jq(t),typeof e[t]==`boolean`?$q(e[t]):e[t]])))};return Ye(n)?n:null}function nJ({value:e,renderMedia:t,depth:n=0}){let r=Zq(e);if(Qq(r))return(0,V.jsx)(`span`,{children:$q(r)});if(Kq(r))return t?.(r)??null;if(Ye(r))return(0,V.jsx)(Wq,{value:r,label:`Results`});if(Array.isArray(r)){if(!r.length)return(0,V.jsx)(`span`,{className:`sm-data-none`,children:`None`});let e=n<2&&!r.some(Kq)&&tJ(r);return e?(0,V.jsx)(Wq,{value:e,label:`Results`}):n>=3?(0,V.jsx)(`span`,{children:qq(r.length,`item`)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`ul`,{className:`sm-data-list`,children:r.slice(0,Yq).map((e,r)=>(0,V.jsx)(`li`,{children:(0,V.jsx)(nJ,{value:e,renderMedia:t,depth:n+1})},r))}),r.length>Yq&&(0,V.jsxs)(`p`,{className:`sm-data-none`,children:[`And `,r.length-Yq,` more.`]})]})}if(!vt(r))return null;let i=Xq(r);return i.length?n>=3?(0,V.jsx)(`span`,{children:qq(i.length,`detail`)}):(0,V.jsx)(`dl`,{className:`sm-data-record`,children:i.map(e=>(0,V.jsxs)(v.Fragment,{children:[(0,V.jsx)(`dt`,{children:Jq(e)}),(0,V.jsx)(`dd`,{children:(0,V.jsx)(nJ,{value:r[e],renderMedia:t,depth:n+1})})]},e))}):(0,V.jsx)(`span`,{className:`sm-data-none`,children:`None`})}var rJ=[`M3 8V5a2 2 0 0 1 2-2h3M16 3h3a2 2 0 0 1 2 2v3M21 16v3a2 2 0 0 1-2 2h-3M8 21H5a2 2 0 0 1-2-2v-3`,`M6.5 12s2.2-3.8 5.5-3.8 5.5 3.8 5.5 3.8-2.2 3.8-5.5 3.8S6.5 12 6.5 12Z`],iJ={cx:12,cy:12,r:1.8},aJ=[`M10.3 17.5H4.5a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2h13a2 2 0 0 1 2 2v7.7`,`M2.5 7h17M6 5.25h10`,`M6 9.5h4a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1Z`,`M5.3 14.2l2.2-2.4 1.6 1.5 1.1-1M13.5 10h3.5M13.5 12.3h2`,`M12 18s2-3.2 5.5-3.2S23 18 23 18s-2 3.2-5.5 3.2S12 18 12 18Z`],oJ={cx:17.5,cy:18,r:1.3};function sJ(e){switch(e){case`minus`:return(0,V.jsx)(`path`,{d:`M5 12h14`});case`messageCircle`:return(0,V.jsx)(`path`,{d:`M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8z`});case`arrowLeft`:return(0,V.jsx)(`path`,{d:`M20 12H4M11 5l-7 7 7 7`});case`link`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M10 13a5 5 0 0 0 7 .5l3-3a5 5 0 0 0-7-7l-2 2`}),(0,V.jsx)(`path`,{d:`M14 11a5 5 0 0 0-7-.5l-3 3a5 5 0 0 0 7 7l2-2`})]});case`unlink`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`m18.8 12.3 1.7-1.7a5 5 0 0 0-7.1-7.1l-1.7 1.7`}),(0,V.jsx)(`path`,{d:`m5.2 11.7-1.7 1.7a5 5 0 0 0 7.1 7.1l1.7-1.7`}),(0,V.jsx)(`path`,{d:`M8 2v3M2 8h3M16 19v3M19 16h3`})]});case`copy`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`9`,y:`9`,width:`12`,height:`12`,rx:`2`}),(0,V.jsx)(`path`,{d:`M15 9V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4`})]});case`arrowUp`:return(0,V.jsx)(`path`,{d:`M12 20V4M5 11l7-7 7 7`});case`star`:return(0,V.jsx)(`path`,{d:`M12 3.5l2.6 5.3 5.9.9-4.25 4.15 1 5.85L12 16.95 6.75 19.7l1-5.85L3.5 9.7l5.9-.9z`});case`arrowUpRight`:return(0,V.jsx)(`path`,{d:`M7 17 17 7M8 7h9v9`});case`arrowDown`:return(0,V.jsx)(`path`,{d:`M12 4v16M5 13l7 7 7-7`});case`thumbsUp`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M7 10v11H3V10Z`}),(0,V.jsx)(`path`,{d:`M7 18c2 0 3 3 7 3h2.5a2 2 0 0 0 1.9-1.4l2.4-7A2 2 0 0 0 18.9 10H14l.7-3.5A3 3 0 0 0 11.8 3L7 10Z`})]});case`thumbsDown`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M7 14V3H3v11Z`}),(0,V.jsx)(`path`,{d:`M7 6c2 0 3-3 7-3h2.5a2 2 0 0 1 1.9 1.4l2.4 7a2 2 0 0 1-1.9 2.6H14l.7 3.5a3 3 0 0 1-2.9 3.5L7 14Z`})]});case`undo`:return(0,V.jsx)(`path`,{d:`M3 10h11a7 7 0 0 1 0 14M3 10l5-5M3 10l5 5`,transform:`translate(0 -3)`});case`redo`:return(0,V.jsx)(`path`,{d:`M21 7H10a7 7 0 0 0 0 14M21 7l-5-5M21 7l-5 5`});case`remix`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M5 5h5a5 5 0 0 1 5 5v9`}),(0,V.jsx)(`path`,{d:`m11 15 4 4 4-4`}),(0,V.jsx)(`path`,{d:`M5 19h2`}),(0,V.jsx)(`circle`,{cx:`5`,cy:`5`,r:`2`}),(0,V.jsx)(`circle`,{cx:`5`,cy:`19`,r:`2`})]});case`more`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,V.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1`})]});case`palette`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`13.5`,cy:`6.5`,r:`.6`,fill:`currentColor`,stroke:`none`}),(0,V.jsx)(`circle`,{cx:`17`,cy:`11`,r:`.6`,fill:`currentColor`,stroke:`none`}),(0,V.jsx)(`circle`,{cx:`8.5`,cy:`7.5`,r:`.6`,fill:`currentColor`,stroke:`none`}),(0,V.jsx)(`circle`,{cx:`6.5`,cy:`12.5`,r:`.6`,fill:`currentColor`,stroke:`none`}),(0,V.jsx)(`path`,{d:`M12 3a9 9 0 0 0 0 18c1 0 1.6-.8 1.6-1.6 0-.5-.2-.8-.4-1.1-.3-.3-.4-.6-.4-1.1A1.6 1.6 0 0 1 14.3 15h1.9A4.8 4.8 0 0 0 21 10.2C21 6 16.9 3 12 3Z`})]});case`lock`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`5`,y:`11`,width:`14`,height:`10`,rx:`2`}),(0,V.jsx)(`path`,{d:`M8 11V7a4 4 0 0 1 8 0v4`})]});case`unlock`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`5`,y:`11`,width:`14`,height:`10`,rx:`2`}),(0,V.jsx)(`path`,{d:`M8 11V7a4 4 0 0 1 7.9-1`})]});case`pushpin`:return(0,V.jsxs)(`g`,{transform:`rotate(35 12 12)`,children:[(0,V.jsx)(`path`,{d:`M8 3h8l-1 6 3 3v2H6v-2l3-3Z`}),(0,V.jsx)(`path`,{d:`M12 14v7`})]});case`pushpinFilled`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M8 3h8l-1 6 3 3v2H6v-2l3-3Z`,fill:`currentColor`}),(0,V.jsx)(`path`,{d:`M12 14v7`})]});case`pin`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 21s7-5.7 7-11a7 7 0 0 0-14 0c0 5.3 7 11 7 11Z`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`10`,r:`2.5`})]});case`user`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`8`,r:`4`}),(0,V.jsx)(`path`,{d:`M5 21a7 7 0 0 1 14 0`})]});case`image`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),(0,V.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`1.5`}),(0,V.jsx)(`path`,{d:`m21 15-5-5L5 21`})]});case`imageOff`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M2 2l20 20`}),(0,V.jsx)(`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`}),(0,V.jsx)(`path`,{d:`M13.5 13.5 6 21`}),(0,V.jsx)(`path`,{d:`m18 12 3 3`}),(0,V.jsx)(`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`}),(0,V.jsx)(`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`})]});case`film`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),(0,V.jsx)(`path`,{d:`M7 3v18M17 3v18M3 8h4M3 16h4M17 8h4M17 16h4`})]});case`folder`:return(0,V.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`});case`list`:return(0,V.jsx)(`path`,{d:`M9 6h12M9 12h12M9 18h12M4 6h.01M4 12h.01M4 18h.01`});case`grid`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,V.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,V.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,V.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]});case`zap`:return(0,V.jsx)(`path`,{d:`M13 2 4 14h7l-1 8 9-12h-7Z`});case`plug`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 22v-5M9 8V2M15 8V2`}),(0,V.jsx)(`path`,{d:`M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z`})]});case`book`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,V.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2Z`})]});case`bookOpen`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 7v14`}),(0,V.jsx)(`path`,{d:`M3 5v14h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6V5h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3Z`})]});case`input`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`}),(0,V.jsx)(`path`,{d:`m10 17 5-5-5-5`}),(0,V.jsx)(`path`,{d:`M15 12H3`})]});case`upload`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 16V4M7 9l5-5 5 5`}),(0,V.jsx)(`path`,{d:`M5 20h14`})]});case`download`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 4v12M7 11l5 5 5-5`}),(0,V.jsx)(`path`,{d:`M5 20h14`})]});case`save`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M5 3h11l3 3v15H5Z`}),(0,V.jsx)(`path`,{d:`M8 3v5h7M8 21v-7h8v7`})]});case`search`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,V.jsx)(`path`,{d:`m20 20-3.5-3.5`})]});case`magnet`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M6 4h4v8a2 2 0 0 0 4 0V4h4v8a6 6 0 0 1-12 0Z`}),(0,V.jsx)(`path`,{d:`M6 8h4M14 8h4`})]});case`bot`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`4`,y:`8`,width:`16`,height:`11`,rx:`2`}),(0,V.jsx)(`path`,{d:`M12 8V4M9 13h.01M15 13h.01M9 16h6`})]});case`note`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`4`,y:`3`,width:`16`,height:`18`,rx:`2`}),(0,V.jsx)(`path`,{d:`M8 8h8M8 12h8M8 16h5`})]});case`clock`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`path`,{d:`M12 7v5l3 2`})]});case`calendar`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,V.jsx)(`path`,{d:`M16 3v4M8 3v4M3 10h18`})]});case`hourglass`:return(0,V.jsx)(`path`,{d:`M6 3h12M6 21h12M7 3c0 5 5 6 5 9s-5 4-5 9M17 3c0 5-5 6-5 9s5 4 5 9`});case`edit`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 20h9`}),(0,V.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]});case`music`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M9 18V5l12-2v13`}),(0,V.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,V.jsx)(`circle`,{cx:`18`,cy:`16`,r:`3`})]});case`mic`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`}),(0,V.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),(0,V.jsx)(`path`,{d:`M12 19v3`})]});case`target`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`5`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`})]});case`pointer`:return(0,V.jsx)(`path`,{d:`M4.5 3.5 20 10.4l-6.5 1.9a1.9 1.9 0 0 0-1.3 1.3L10.3 20z`,strokeLinejoin:`round`});case`sprout`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M12 21V9`}),(0,V.jsx)(`path`,{d:`M12 9C9 9 6 7 6 4c3 0 6 2 6 5ZM12 12c3 0 6-2 6-5-3 0-6 2-6 5Z`})]});case`hand`:return(0,V.jsx)(`path`,{d:`M8 13V5a1.5 1.5 0 0 1 3 0v6M11 11V4a1.5 1.5 0 0 1 3 0v7M14 11V6a1.5 1.5 0 0 1 3 0v8a6 6 0 0 1-6 6h-1a6 6 0 0 1-5.2-3l-2-3.5a1.5 1.5 0 0 1 2.6-1.5L8 14`});case`scissors`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2.5`}),(0,V.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2.5`}),(0,V.jsx)(`path`,{d:`M8 8l12 8M8 16 20 8`})]});case`maximize`:return(0,V.jsx)(`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M21 16v3a2 2 0 0 1-2 2h-3M3 16v3a2 2 0 0 0 2 2h3`});case`settings`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,V.jsx)(`path`,{d:`M19.4 15a1.6 1.6 0 0 0 .3 1.8 2 2 0 1 1-2.8 2.8 1.6 1.6 0 0 0-1.8-.3 1.6 1.6 0 0 0-1 1.5 2 2 0 1 1-4 0 1.6 1.6 0 0 0-1-1.5 1.6 1.6 0 0 0-1.8.3 2 2 0 1 1-2.8-2.8 1.6 1.6 0 0 0 .3-1.8 1.6 1.6 0 0 0-1.5-1 2 2 0 1 1 0-4 1.6 1.6 0 0 0 1.5-1 1.6 1.6 0 0 0-.3-1.8 2 2 0 1 1 2.8-2.8 1.6 1.6 0 0 0 1.8.3H9a1.6 1.6 0 0 0 1-1.5 2 2 0 1 1 4 0 1.6 1.6 0 0 0 1 1.5 1.6 1.6 0 0 0 1.8-.3 2 2 0 1 1 2.8 2.8 1.6 1.6 0 0 0-.3 1.8V9a1.6 1.6 0 0 0 1.5 1 2 2 0 1 1 0 4 1.6 1.6 0 0 0-1.5 1Z`})]});case`scale`:return(0,V.jsx)(`path`,{d:`M12 3v18M7 21h10M6 7h12M6 7 3 14h6ZM18 7l-3 7h6ZM3 14a3 3 0 0 0 6 0M15 14a3 3 0 0 0 6 0`});case`checkbox`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),(0,V.jsx)(`path`,{d:`m8 12 3 3 5-6`})]});case`warning`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M10.3 4 2.6 17a2 2 0 0 0 1.7 3h15.4a2 2 0 0 0 1.7-3L13.7 4a2 2 0 0 0-3.4 0Z`}),(0,V.jsx)(`path`,{d:`M12 9v4M12 17h.01`})]});case`sparkle`:return(0,V.jsx)(`path`,{d:`M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8Z`});case`check`:return(0,V.jsx)(`path`,{d:`m5 12 5 5 9-10`});case`x`:return(0,V.jsx)(`path`,{d:`M6 6 18 18M18 6 6 18`});case`plus`:return(0,V.jsx)(`path`,{d:`M12 5v14M5 12h14`});case`refresh`:return(0,V.jsx)(`path`,{d:`M3 12a9 9 0 0 1 15-6.7L21 8M21 3v5h-5M21 12a9 9 0 0 1-15 6.7L3 16M3 21v-5h5`});case`play`:return(0,V.jsx)(`path`,{d:`M7 4v16l13-8Z`});case`preview`:return(0,V.jsxs)(V.Fragment,{children:[rJ.map(e=>(0,V.jsx)(`path`,{d:e},e)),(0,V.jsx)(`circle`,{...iJ})]});case`listingPreview`:return(0,V.jsxs)(V.Fragment,{children:[aJ.map(e=>(0,V.jsx)(`path`,{d:e},e)),(0,V.jsx)(`circle`,{...oJ})]});case`pause`:return(0,V.jsx)(`path`,{d:`M9 5v14M15 5v14`});case`playFilled`:return(0,V.jsx)(`path`,{d:`M7 4.6v14.8c0 .8.9 1.2 1.5.8l11.4-7.4a1 1 0 0 0 0-1.6L8.5 3.8C7.9 3.4 7 3.8 7 4.6Z`,fill:`currentColor`,stroke:`none`});case`pauseFilled`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`6`,y:`4.5`,width:`4`,height:`15`,rx:`1`,fill:`currentColor`,stroke:`none`}),(0,V.jsx)(`rect`,{x:`14`,y:`4.5`,width:`4`,height:`15`,rx:`1`,fill:`currentColor`,stroke:`none`})]});case`volume2`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4V5Z`,fill:`currentColor`}),(0,V.jsx)(`path`,{d:`M15.5 8.5a5 5 0 0 1 0 7M19 5a10 10 0 0 1 0 14`})]});case`volumeX`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4V5Z`,fill:`currentColor`}),(0,V.jsx)(`path`,{d:`m22 9-6 6M16 9l6 6`})]});case`minimize`:return(0,V.jsx)(`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3M21 8h-3a2 2 0 0 1-2-2V3M3 16h3a2 2 0 0 1 2 2v3M16 21v-3a2 2 0 0 1 2-2h3`});case`stop`:return(0,V.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`});case`chevronRight`:return(0,V.jsx)(`path`,{d:`m9 6 6 6-6 6`});case`chevronLeft`:return(0,V.jsx)(`path`,{d:`m15 6-6 6 6 6`});case`chevronDown`:return(0,V.jsx)(`path`,{d:`m6 9 6 6 6-6`});case`trash`:return(0,V.jsx)(`path`,{d:`M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13`});case`layers`:return(0,V.jsx)(`path`,{d:`m12 3 9 5-9 5-9-5Zm9 9-9 5-9-5m18 4-9 5-9-5`});case`type`:return(0,V.jsx)(`path`,{d:`M4 6V4h16v2M12 4v16M9 20h6`});case`home`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M3 10.5 12 3l9 7.5`}),(0,V.jsx)(`path`,{d:`M5 9.5V20a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9.5`}),(0,V.jsx)(`path`,{d:`M9 21v-6h6v6`})]});case`menu`:return(0,V.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h16`});case`logout`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,V.jsx)(`path`,{d:`M16 17l5-5-5-5`}),(0,V.jsx)(`path`,{d:`M21 12H9`})]});case`help`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`path`,{d:`M9.1 9a3 3 0 0 1 5.8 1c0 2-3 3-3 3`}),(0,V.jsx)(`path`,{d:`M12 17h.01`})]});case`bug`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`m8 2 1.9 1.9M14.1 3.9 16 2`}),(0,V.jsx)(`path`,{d:`M9 7.1v-1a3 3 0 1 1 6 0v1`}),(0,V.jsx)(`path`,{d:`M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6`}),(0,V.jsx)(`path`,{d:`M12 20v-9`}),(0,V.jsx)(`path`,{d:`M6.5 9C4.6 8.8 3 7.1 3 5M6 13H2M3 21c0-2.1 1.7-3.9 3.8-4M21 5c0 2.1-1.6 3.8-3.5 4M22 13h-4M17.2 17c2.1.1 3.8 1.9 3.8 4`})]});default:return null}}function cJ({name:e,size:t=`1em`,style:n,className:r,strokeWidth:i=1.5}){let a=sJ(e);return a?(0,V.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:i,strokeLinecap:`round`,strokeLinejoin:`round`,className:r,style:{display:`inline-block`,verticalAlign:`-0.14em`,flexShrink:0,...n||{}},"aria-hidden":`true`,children:a}):null}function lJ(e,t){let n=(0,v.useRef)(t),r=DU(e),[i,a]=(0,v.useState)(null);return n.current=t,(0,v.useEffect)(()=>{if(!r)return;let t=!0;return Promise.resolve().then(()=>n.current?.(e)).then(n=>{t&&a({src:e,url:n||null})},()=>{t&&a({src:e,url:null})}),()=>{t=!1}},[e,r]),r?i?.src===e?{url:i.url,missing:!i.url}:{url:null,missing:!1}:{url:e||null,missing:!1}}function uJ({src:e,resolveUrl:t,label:n,"aria-label":r,fill:i=!1,className:a,style:o,onMissing:s,controls:c,playsInline:l,preload:u=`metadata`,...d}){let{url:f,missing:p}=lJ(e,t),m=(0,v.useRef)(null),h=(0,v.useRef)(null),g=(0,v.useRef)(null),_=(0,v.useRef)(s);return _.current=s,(0,v.useEffect)(()=>{if(p){_.current?.(e);return}let t=kU(g.current,{root:m.current,ui:h.current});return()=>t?.destroy()},[p]),p?(0,V.jsx)(`span`,{role:`img`,className:a?`sm-player-off ${a}`:`sm-player-off`,"aria-label":`On another device`,title:`On another device`,children:(0,V.jsx)(cJ,{name:`imageOff`,size:24})}):(0,V.jsxs)(`div`,{ref:m,className:a?`sm-player ${a}`:`sm-player`,style:o,"data-mode":`dark`,"data-fill":i?``:void 0,tabIndex:0,role:`group`,"aria-label":n||r||`Video`,children:[(0,V.jsx)(`video`,{ref:g,src:f||void 0,preload:u,playsInline:!0,...d}),(0,V.jsx)(`div`,{ref:h,className:`sm-player-ui`})]})}var dJ=e=>String(e).padStart(2,`0`),fJ=/^(\d{4})-(\d{2})-(\d{2})$/,pJ=/^([01]\d|2[0-3]):([0-5]\d)$/,mJ=e=>{let t=fJ.exec(e||``);return t?{year:+t[1],month:+t[2],day:+t[3]}:null},hJ=e=>{let t=mJ(e);return!!t&&new Date(Date.UTC(t.year,t.month-1,t.day)).toISOString().slice(0,10)===e},gJ=e=>{let{year:t,month:n,day:r}=mJ(e);return new Date(Date.UTC(t,n-1,r))},_J=(e,t)=>{let n=gJ(e);return n.setUTCDate(n.getUTCDate()+t),n.toISOString().slice(0,10)},vJ=(e,t)=>{let{year:n,month:r,day:i}=mJ(e),a=new Date(Date.UTC(n,r-1+t,1)),o=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth()+1,0)).getUTCDate();return`${a.getUTCFullYear()}-${dJ(a.getUTCMonth()+1)}-${dJ(Math.min(i,o))}`},yJ=/(?:time|when|start|schedule|post|send|publish|remind)/i,bJ=(e,t,n)=>typeof n==`string`&&n.includes(`T`)||yJ.test(e||``)||/(?:At|_at)$/.test(e||``)||/\b(?:time|when|starts?|at)\b/i.test(t||``),xJ=e=>`${CJ(e.slice(0,10))}${e[10]===`T`?` · ${wJ(e.slice(11,16))}`:``}`;function SJ({utc:e=!1,now:t=new Date}={}){return e?t.toISOString().slice(0,10):`${t.getFullYear()}-${dJ(t.getMonth()+1)}-${dJ(t.getDate())}`}function CJ(e,t=SJ()){return gJ(e).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,...e.slice(0,4)===t.slice(0,4)?{}:{year:`numeric`},timeZone:`UTC`})}function wJ(e){let[t,n]=e.split(`:`).map(Number);return new Date(Date.UTC(2e3,0,1,t,n)).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,timeZone:`UTC`})}function TJ(e=30){return Array.from({length:Math.floor(1440/e)},(t,n)=>`${dJ(Math.floor(n*e/60))}:${dJ(n*e%60)}`)}function EJ(e,t,n,r){return(0,v.useEffect)(()=>{if(!e)return;let r=e=>{n.current?.contains(e.target)||t(!1)};return document.addEventListener(`pointerdown`,r),()=>document.removeEventListener(`pointerdown`,r)},[e]),n=>{n.key===`Escape`&&e&&(n.stopPropagation(),n.preventDefault(),t(!1),r.current?.focus())}}function DJ({value:e,onChange:t,min:n,max:r,utc:i=!1,disabled:a=!1,label:o=`Day`,placeholder:s=`Pick a day`,clearable:c=!1}){let[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=(0,v.useRef)(null),g=EJ(l,u,p,m),_=SJ({utc:i}),y=hJ(e)?e:null,b=e=>(!n||e>=n)&&(!r||e<=r),x=e=>n&&e<n?n:r&&e>r?r:e;(0,v.useEffect)(()=>{l&&d&&h.current?.querySelector(`[data-day="${d}"]`)?.focus()},[l,d]);let S=()=>{if(l){u(!1);return}f(x(y||_)),u(!0)},C=e=>{b(e)&&(t?.(e),u(!1),m.current?.focus())},w={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7},T=e=>{let t=null;if(w[e.key])t=_J(d,w[e.key]);else if(e.key===`PageUp`||e.key===`PageDown`)t=vJ(d,e.key===`PageUp`?-1:1);else if(e.key===`Home`||e.key===`End`){let n=gJ(d).getUTCDay();t=_J(d,e.key===`Home`?-n:6-n)}t!==null&&(e.preventDefault(),f(x(t)))},E=d||y||_,{year:D,month:O}=mJ(E),k=`${D}-${dJ(O)}-01`,A=new Date(Date.UTC(D,O,0)).getUTCDate(),j=gJ(k).getUTCDay(),M=gJ(k).toLocaleDateString(void 0,{month:`long`,year:`numeric`,timeZone:`UTC`}),N=_J(k,-1),P=vJ(k,1),F=Array.from({length:A},(e,t)=>`${D}-${dJ(O)}-${dJ(t+1)}`);return(0,V.jsxs)(`span`,{className:`sm-when-pick`,ref:p,onKeyDown:g,children:[(0,V.jsxs)(`button`,{type:`button`,ref:m,className:`sm-when-button`,"aria-haspopup":`dialog`,"aria-expanded":l,"aria-label":`${o}: ${y?CJ(y,_):`not chosen`}`,disabled:a,onClick:S,children:[(0,V.jsx)(cJ,{name:`calendar`,size:16}),(0,V.jsx)(`span`,{children:y?CJ(y,_):s}),(0,V.jsx)(cJ,{name:`chevronDown`,size:13})]}),l&&(0,V.jsxs)(`div`,{className:`sm-when-pop sm-when-calendar`,role:`dialog`,"aria-label":`Pick a ${o.toLowerCase()}`,children:[(0,V.jsxs)(`div`,{className:`sm-when-cal-head`,children:[(0,V.jsx)(`b`,{children:M}),(0,V.jsxs)(`span`,{className:`sm-when-cal-nav`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":`Previous month`,title:`Previous month`,disabled:!!n&&N<n,onClick:()=>f(x(vJ(E,-1))),children:(0,V.jsx)(cJ,{name:`chevronLeft`,size:16})}),(0,V.jsx)(`button`,{type:`button`,"aria-label":`Next month`,title:`Next month`,disabled:!!r&&P>r,onClick:()=>f(x(vJ(E,1))),children:(0,V.jsx)(cJ,{name:`chevronRight`,size:16})})]})]}),(0,V.jsxs)(`div`,{className:`sm-when-cal-grid`,ref:h,onKeyDown:T,children:[[`S`,`M`,`T`,`W`,`T`,`F`,`S`].map((e,t)=>(0,V.jsx)(`i`,{"aria-hidden":`true`,children:e},t)),j>0&&(0,V.jsx)(`span`,{style:{gridColumn:`span ${j}`},"aria-hidden":`true`}),F.map(e=>(0,V.jsx)(`button`,{type:`button`,"data-day":e,tabIndex:e===d?0:-1,disabled:!b(e),"aria-pressed":e===y,"aria-current":e===_?`date`:void 0,"aria-label":gJ(e).toLocaleDateString(void 0,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`,timeZone:`UTC`}),onClick:()=>C(e),children:Number(e.slice(8))},e))]}),c&&y&&(0,V.jsx)(`button`,{type:`button`,className:`sm-quiet sm-when-clear`,onClick:()=>{t?.(``),u(!1),m.current?.focus()},children:`Clear`})]})]})}function OJ({value:e,onChange:t,min:n,step:r=30,disabled:i=!1,label:a=`Time`,placeholder:o=`Pick a time`}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(-1),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(null),m=(0,v.useId)(),h=EJ(s,c,d,f),g=pJ.test(e||``)?e:null,_=g&&!TJ(r).includes(g)?[...TJ(r),g].sort():TJ(r),y=e=>!n||e>=n;(0,v.useEffect)(()=>{s&&(p.current?.focus(),p.current?.querySelector(`[data-active="true"]`)?.scrollIntoView?.({block:`nearest`}))},[s,l]);let b=()=>{if(s){c(!1);return}let e=_.indexOf(g);u(e>=0?e:Math.max(0,_.findIndex(y))),c(!0)},x=e=>{y(e)&&(t?.(e),c(!1),f.current?.focus())};return(0,V.jsxs)(`span`,{className:`sm-when-pick`,ref:d,onKeyDown:h,children:[(0,V.jsxs)(`button`,{type:`button`,ref:f,className:`sm-when-button`,"aria-haspopup":`listbox`,"aria-expanded":s,"aria-label":`${a}: ${g?wJ(g):`not chosen`}`,disabled:i,onClick:b,children:[(0,V.jsx)(cJ,{name:`clock`,size:16}),(0,V.jsx)(`span`,{children:g?wJ(g):o}),(0,V.jsx)(cJ,{name:`chevronDown`,size:13})]}),s&&(0,V.jsx)(`ul`,{className:`sm-when-pop sm-when-times`,role:`listbox`,ref:p,tabIndex:-1,"aria-label":`Pick a ${a.toLowerCase()}`,"aria-activedescendant":l>=0?`${m}-${l}`:void 0,onKeyDown:e=>{let t=t=>{let n=t,r=e.key===`ArrowUp`||e.key===`End`?-1:1;for(;n>=0&&n<_.length&&!y(_[n]);)n+=r;return n>=0&&n<_.length?n:l};if(e.key===`ArrowDown`)u(t(l+1));else if(e.key===`ArrowUp`)u(t(l-1));else if(e.key===`Home`)u(t(0));else if(e.key===`End`)u(t(_.length-1));else if(e.key===`Enter`||e.key===` `)_[l]&&x(_[l]);else return;e.preventDefault()},children:_.map((e,t)=>(0,V.jsx)(`li`,{id:`${m}-${t}`,role:`option`,"aria-selected":e===g,"aria-disabled":!y(e)||void 0,"data-active":t===l||void 0,onPointerDown:e=>e.preventDefault(),onClick:()=>x(e),children:wJ(e)},e))})]})}function kJ({value:e,onChange:t,min:n,max:r,utc:i=!1,disabled:a=!1,label:o=`Date`,clearable:s=!1,defaultTime:c=`09:00`,step:l=30}){let u=hJ(e?.slice(0,10))?e.slice(0,10):``,d=pJ.test(e?.slice(11,16)||``)?e.slice(11,16):``,f=n?.slice(0,10)||void 0,p=f?n.slice(11,16):``,m=e=>e===f&&p?TJ(l).find(e=>e>=p)||p:null;return(0,V.jsxs)(`span`,{className:`sm-when-pickers`,children:[(0,V.jsx)(DJ,{value:u,onChange:e=>{if(!e){t?.(``);return}let n=m(e),r=d||c;n&&r<n&&(r=n),t?.(`${e}T${r}`)},min:f,max:r?.slice(0,10),utc:i,disabled:a,label:`${o} day`,clearable:s}),(0,V.jsx)(OJ,{value:d,onChange:e=>t?.(`${u||f||SJ({utc:i})}T${e}`),min:(u||f||SJ({utc:i}))===f&&p||void 0,step:l,disabled:a,label:`${o} time`})]})}var AJ=new Set([`image`,`image[]`,`video`,`video[]`,`audio`,`audio[]`,`asset`,`asset[]`,`file`]),jJ=3,MJ=e=>String(e||``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();function NJ(e){let t=String(e||``).trim();if(!t)return``;let n=(t.match(/^.+?[.!?](?=\s|$)/)||[t])[0].trim();return n.length<=160?n:``}function PJ(e,{inputs:t,labels:n={},groups:r=[]}={}){let i=t||Object.entries(e?.inputs||{}).filter(([,e])=>!e?.context),a=i.length>0&&i.length<=jJ&&!r.length,o=i.find(([,e])=>e?.required!==!1&&e?.primary)||i.find(([,e])=>e?.required!==!1)||i[0],s=o?MJ(n[o[0]]||o[1]?.label||o[0]):``;return{focused:a,heading:s?`Add your ${s}`:String(e?.action?.label||e?.name||``).trim(),line:NJ(e?.description),media:!!o&&AJ.has(o[1]?.type)}}var FJ=new Set([`text`,`script`,`transcript`,`brief`,`json`,`metadata`,`research`,`document`,`table`]),IJ=e=>{let t=String(e||``).replace(/\[\]$/,``);return FJ.has(t)?`text`:[`video`,`image`,`audio`].includes(t)?t:void 0},LJ=/^\s*(\d+(?:\.\d+)?)\s*[:/x]\s*(\d+(?:\.\d+)?)\s*$/;function RJ(e,{inputs:t={},aspectRatio:n}={}){let r=Object.entries(e?.outputs||{}).filter(([,e])=>!e?.context),i=(r.find(([,e])=>e?.primary)||r[0]||[])[1],a=IJ(i?.type);if(a!==`video`&&a!==`image`)return{kind:a};let o=Object.keys(e?.inputs||{}).find(e=>/aspect/i.test(e)),s=[o&&t[o],o&&e.inputs[o]?.default,n].find(e=>LJ.test(String(e||``))),c=LJ.exec(String(s||``));return{kind:a,ratio:c?`${c[1]}/${c[2]}`:a===`video`?`16/9`:`1/1`}}function zJ({kind:e,ratio:t,words:n=`Your result shows up here`}){return(0,V.jsxs)(`div`,{className:`sm-result-place`,"data-kind":e||`other`,children:[e===`text`&&(0,V.jsxs)(`span`,{className:`sm-result-lines`,"aria-hidden":`true`,children:[(0,V.jsx)(`i`,{}),(0,V.jsx)(`i`,{}),(0,V.jsx)(`i`,{}),(0,V.jsx)(`i`,{}),(0,V.jsx)(`i`,{}),(0,V.jsx)(`i`,{})]}),(e===`video`||e===`image`)&&(0,V.jsx)(`span`,{className:`sm-result-frame`,style:{aspectRatio:t},"aria-hidden":`true`,children:(0,V.jsx)(`span`,{className:`sm-glyph`,"data-glyph":e})}),e===`audio`&&(0,V.jsxs)(`span`,{className:`sm-result-audio`,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{className:`sm-glyph`,"data-glyph":`audio`}),(0,V.jsx)(`span`,{className:`sm-result-wave`,children:Array.from({length:24},(e,t)=>(0,V.jsx)(`i`,{},t))})]}),!e&&(0,V.jsx)(`span`,{className:`sm-glyph`,"data-glyph":`spark`,"aria-hidden":`true`}),(0,V.jsx)(`p`,{children:n})]})}var BJ=Object.freeze({video:`video`,image:`image`,audio:`audio file`,file:`file`,asset:`file`}),VJ=new Set([`video`,`videos`,`image`,`images`,`photo`,`photos`,`picture`,`audio`,`sound`,`file`,`files`,`media`,`asset`,`input`,`upload`,`source`]),HJ=Object.freeze({video:[`video`],image:[`image`],audio:[`audio`],file:[`file`],asset:[`image`,`video`,`audio`]}),UJ=e=>/^[aeiou]/i.test(e)?`an`:`a`;function WJ(e,t={},{label:n}={}){let r=String(n||e||``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_\-.]+/g,` `).trim(),i=BJ[t.type]||`file`,a=r.split(/\s+/).map(e=>/^[A-Z0-9]{2,}$/.test(e)?e:e.toLowerCase()).join(` `),o=!a||VJ.has(a)||a===i,s=oW(HJ[t.type]||[`file`]);return{title:o?i.charAt(0).toUpperCase()+i.slice(1):a.charAt(0).toUpperCase()+a.slice(1),drop:o?`Drop ${UJ(i)} ${i} here`:`Drop your ${a} here`,choose:`Choose ${UJ(i)} ${i}`,formats:t.type===`audio`?`${s}, or a video for its sound`:s}}var GJ=160,KJ=/\blines\b|\b(?:per|each|every|own|by)\s+line\b|\bline\s+(?:per|for each)\b|\bparagraphs?\b|\bbullet(?:s|ed)?\b/i,qJ=/\blists?\b/i,JJ=/\bcomma/i;function YJ(e,t,n){if(e?.type!==`text`)return!1;if(n?.multiline===!0||[t,e.default].some(e=>typeof e==`string`&&e.includes(`
2104
+ `)))return!0;let r=String(e.description||``);return KJ.test(r)||qJ.test(r)&&!JJ.test(r)}function XJ(e,t,n){if(e?.type!==`text`||YJ(e,t,n)||t!=null&&(typeof t!=`string`||t.length>GJ))return!1;let r=String(e.description||``),i=Number(/\bup to (\d+) characters\b/i.exec(r)?.[1]),a=Number.isSafeInteger(e.maxLength)?e.maxLength:i;return Number.isFinite(a)&&a>0&&a<=GJ}mK(),CK();var ZJ=[[`light`,`Light`],[`dark`,`Dark`],[`white`,`White`]],QJ=[[`full`,`Full width`,null],[`tablet`,`Tablet`,768],[`phone`,`Phone`,390]],$J=new Set([`image`,`video`,`audio`,`file`]),eY={image:`image`,video:`film`,audio:`music`,file:`image`},tY=e=>{let t;try{t=JSON.parse(e)}catch{return String(e)}return Array.isArray(t)?t.map(e=>e?.message===`Unknown manifest field`?`This SDK does not know the Block’s “${e.path}” setting. Update the SDK, then restart the preview.`:`${e?.path?`${e.path}: `:``}${e?.message||`Something is wrong with the Block.`}`).join(` `):String(e)},nY={pdf:`application/pdf`,txt:`text/plain`,csv:`text/csv`,md:`text/markdown`,json:`application/json`,zip:`application/zip`},rY={image:`image/*`,video:`video/*`,audio:`audio/*`,file:Object.keys(nY).map(e=>`.${e}`).join(`,`)};async function iY(e,t){if(t===`image`){let t=await createImageBitmap(e),n={width:t.width,height:t.height};return t.close?.(),n}if(t!==`video`&&t!==`audio`)return{};let n=URL.createObjectURL(e),r=document.createElement(t);try{r.preload=`metadata`,r.src=n,await new Promise((e,t)=>{r.onloadedmetadata=e,r.onerror=()=>t(Error(`This file does not play in the browser.`)),setTimeout(e,8e3)});let e=Number.isFinite(r.duration)&&r.duration>0?Math.round(r.duration*1e3)/1e3:void 0;return t===`video`?{...r.videoWidth?{width:r.videoWidth,height:r.videoHeight}:{},...e?{duration:e}:{}}:e?{duration:e}:{}}finally{URL.revokeObjectURL(n)}}async function aY(e,t){let n=e.name.split(`.`).pop().toLowerCase(),r=t===`file`?nY[n]||e.type:e.type||`application/octet-stream`,i=await iY(e,t).catch(()=>({})),a=await fetch(`/__dev/files`,{method:`POST`,headers:{"Content-Type":r,"X-File-Name":encodeURIComponent(e.name)},body:e}),o=await a.json().catch(()=>({}));if(!a.ok||!o.url)throw Error(o.error||`The preview could not keep this file.`);return{kind:t,assetId:`picked-${o.url.split(`/`)[4]}`,versionId:`v1`,url:o.url,mimeType:r,bytes:e.size,name:e.name,...i}}async function oY(e,t,n,{pick:r=aY}={}){if(!t)throw Error(`This Block has no input named ${e}.`);let i=t.type.endsWith(`[]`),a=i?t.type.slice(0,-2):t.type,o=[];for(let e of i?n:n.slice(0,1))o.push(await r(e,a===`asset`?String(e.type).split(`/`)[0]:a));return{refs:o,apply:t=>({...t||{},[e]:i?[...Array.isArray(t?.[e])?t[e]:[],...o]:o[0]})}}function sY(e,t,n){for(let t of Object.keys(n||{}))if(!Object.hasOwn(e||{},t))throw Error(`Unknown input: ${t}`);return{...t||{},...n}}function cY({name:e,port:t,value:n,own:r,disabled:i,onPick:a,title:o=Jq(e)}){let s=(0,v.useRef)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),m=async e=>{if(e){l(!0),d(``);try{a(await aY(e,t.type))}catch(e){d(e.message)}finally{l(!1)}}},h=e=>{let t=e.target.files?.[0];e.target.value=``,m(t)},g=WJ(e,t),_=(0,V.jsx)(`input`,{ref:s,type:`file`,hidden:!0,accept:rY[t.type],onChange:h});return r&&!n?(0,V.jsxs)(`div`,{className:`dh-media dh-media-empty`,children:[(0,V.jsx)(`span`,{className:`dh-media-label`,children:o}),(0,V.jsxs)(`div`,{className:`dh-media-drop`,"data-over":f||void 0,onDragOver:e=>{e.preventDefault(),f||p(!0)},onDragLeave:()=>p(!1),onDrop:e=>{e.preventDefault(),p(!1),!i&&!c&&m(e.dataTransfer.files?.[0])},children:[(0,V.jsx)(`strong`,{children:c?`Adding…`:g.drop}),t.description&&(0,V.jsx)(`span`,{children:t.description}),(0,V.jsx)(`small`,{children:g.formats}),(0,V.jsx)(`button`,{type:`button`,className:`dh-media-tile dh-media-pick`,disabled:i||c,onClick:()=>s.current?.click(),children:g.choose}),_,u&&(0,V.jsx)(`span`,{className:`dh-media-problem`,role:`alert`,children:u})]})]}):(0,V.jsxs)(`div`,{className:`dh-media`,children:[(0,V.jsx)(`span`,{className:`dh-media-label`,children:o}),r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{type:`button`,className:`dh-media-tile dh-media-pick`,disabled:i||c,onClick:()=>s.current?.click(),children:[(0,V.jsx)(cJ,{name:n?eY[t.type]:`plus`,size:16}),(0,V.jsx)(`span`,{children:c?`Adding…`:uY(n)||g.choose})]}),_,u&&(0,V.jsx)(`span`,{className:`dh-media-problem`,role:`alert`,children:u})]}):n&&typeof n==`object`?(0,V.jsxs)(`span`,{className:`dh-media-tiles`,title:`The example from the Block's tests`,children:[(0,V.jsx)(lY,{item:n,title:o}),(0,V.jsx)(`small`,{className:`dh-media-note`,children:`Example`})]}):(0,V.jsxs)(`span`,{className:`dh-media-tile`,title:`The example from the Block's tests`,children:[(0,V.jsx)(cJ,{name:eY[t.type],size:16}),(0,V.jsx)(`span`,{children:`Add one in the example`}),(0,V.jsx)(`small`,{children:`Example`})]})]})}function lY({item:e,title:t}){let n=(0,v.useRef)(null),[r,i]=(0,v.useState)(!1),a=uY(e)||t;if(!(typeof e?.url==`string`&&e.url.startsWith(`/api/media/`))||![`image`,`video`,`audio`].includes(e.kind))return(0,V.jsxs)(`span`,{className:`dh-media-tile`,title:a,children:[(0,V.jsx)(cJ,{name:eY[e?.kind]||`image`,size:16}),(0,V.jsx)(`span`,{children:a})]});if(e.kind===`image`)return(0,V.jsx)(`span`,{className:`dh-thumb`,title:a,children:(0,V.jsx)(`img`,{src:e.url,alt:a,loading:`lazy`,decoding:`async`})});let o=()=>{let e=n.current;e&&(e.paused?e.play()?.catch?.(()=>{}):e.pause())},s={onPlay:()=>i(!0),onPause:()=>i(!1),onEnded:()=>i(!1)},c=(0,V.jsx)(`button`,{type:`button`,className:`dh-thumb-play`,"aria-label":`${r?`Pause`:`Play`} ${a}`,onClick:o,children:(0,V.jsx)(cJ,{name:r?`pauseFilled`:`playFilled`,size:14})});return e.kind===`video`?(0,V.jsxs)(`span`,{className:`dh-thumb`,title:a,"data-playing":r||void 0,children:[(0,V.jsx)(`video`,{ref:n,src:e.url,preload:`metadata`,muted:!0,playsInline:!0,...s}),c]}):(0,V.jsxs)(`span`,{className:`dh-media-tile dh-media-sound`,title:a,children:[c,(0,V.jsx)(cJ,{name:`music`,size:16}),(0,V.jsx)(`span`,{children:a}),(0,V.jsx)(`audio`,{ref:n,src:e.url,preload:`none`,...s})]})}var uY=e=>{let t=(typeof e?.url==`string`?e.url:``).split(/[?#]/)[0].split(`/`).pop();return e?.name||(t?decodeURIComponent(t):``)},dY=(e,t)=>{try{return localStorage.getItem(e)||t}catch{return t}},fY=(e,t)=>{try{localStorage.setItem(e,t)}catch{}};async function pY(e,t=``){return(await fetch(`/__dev/run${t}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({input:e})})).json()}async function mY(e,{signal:t,edge:n}={}){if(typeof e?.url!=`string`||!e.url.startsWith(`/api/media/`))throw Error(`The local preview shows stand-in media and files mapped in tests/mocks.json.`);let r=await fetch(e.url,{signal:t});if(!r.ok)throw Error(`This image is not available in the local preview. Map it to a file under files in tests/mocks.json.`);let i=await createImageBitmap(await r.blob()),a=n??512,o=Math.min(1,a/Math.max(i.width,i.height)),s=document.createElement(`canvas`);s.width=Math.max(1,Math.round(i.width*o)),s.height=Math.max(1,Math.round(i.height*o));let c=s.getContext(`2d`);c.drawImage(i,0,0,s.width,s.height),i.close?.();let l=s.toDataURL(`image/png`);return l.length>3145728&&a>512&&c.getImageData(0,0,s.width,s.height).data.every((e,t)=>t%4!=3||e===255)&&(l=s.toDataURL(`image/jpeg`,.92)),{url:l,width:s.width,height:s.height}}function hY(e,{signal:t}={}){return typeof e?.url!=`string`||!e.url.startsWith(`/api/media/`)?Promise.reject(Error(`The local preview plays stand-in media and files mapped in tests/mocks.json.`)):Jn(e,{signal:t})}async function gY(e,{signal:t}={}){let n=await fetch(`/api/media/example/kitchen.wav`,{signal:t});if(!n.ok)throw Error(`The stand-in voice sample is not available.`);return new Blob([await n.arrayBuffer()],{type:`audio/wav`})}function _Y({value:e}){let t=uY(e);if(!e.url.startsWith(`/api/media/`))return(0,V.jsxs)(`span`,{className:`dh-media-tile`,children:[(0,V.jsx)(cJ,{name:eY[e.kind],size:16}),(0,V.jsx)(`span`,{children:t||`Result`})]});let n=e.width>0&&e.height>0?`${e.width}/${e.height}`:null,r=n?{aspectRatio:n}:void 0;return(0,V.jsxs)(`figure`,{className:`dh-result-media`,children:[e.kind===`image`?(0,V.jsx)(`img`,{src:e.url,alt:t,style:r}):e.kind===`video`?(0,V.jsx)(uJ,{src:e.url,preload:`metadata`,style:n?{"--dh-shape":n}:void 0}):(0,V.jsx)(`audio`,{src:e.url,controls:!0,preload:`metadata`}),t&&(0,V.jsx)(`figcaption`,{children:t})]})}var vY=e=>(0,V.jsx)(_Y,{value:e}),yY=new Set([`image[]`,`video[]`,`audio[]`,`asset`,`asset[]`,`file[]`]);function bY({name:e,port:t,control:n,value:r,onCommit:i,disabled:a}){let o=r??t.default??(t.type!==`boolean`&&``),s=n?.label||Jq(e),[c,l]=(0,v.useState)(o);(0,v.useEffect)(()=>{l(o)},[o]);let u=`dh-input-${e}`,d=t.description||void 0,f=n?.control===`select`&&Array.isArray(n.options)?n.options:null,p=f?(0,V.jsx)(`select`,{id:u,value:c,disabled:a,onChange:e=>{l(e.target.value),i(e.target.value)},children:f.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))}):n?.control===`slider`&&[`number`,`integer`].includes(t.type)&&Number.isFinite(t.min)&&Number.isFinite(t.max)?(0,V.jsxs)(`span`,{className:`dh-slider`,children:[(0,V.jsx)(`input`,{id:u,type:`range`,min:t.min,max:t.max,step:t.type===`integer`?1:`any`,value:c,disabled:a,onChange:e=>l(Number(e.target.value)),onPointerUp:()=>i(Number(c)),onKeyUp:()=>i(Number(c)),onBlur:()=>i(Number(c))}),(0,V.jsx)(`output`,{htmlFor:u,children:c})]}):t.type===`boolean`?(0,V.jsx)(`input`,{id:u,type:`checkbox`,checked:!!c,disabled:a,onChange:e=>{l(e.target.checked),i(e.target.checked)}}):[`number`,`integer`].includes(t.type)?(0,V.jsx)(`input`,{id:u,type:`number`,step:t.type===`integer`?1:`any`,value:c,disabled:a,onChange:e=>l(e.target.value),onBlur:()=>{if(c===``)return i(void 0);let e=Number(c);Number.isFinite(e)&&i(e)}}):[`text`,`string`].includes(t.type)?!n?.control&&XJ(t,o,n)?(0,V.jsx)(`input`,{id:u,type:`text`,value:c,disabled:a,onChange:e=>l(e.target.value),onBlur:()=>{c!==o&&i(c)}}):(0,V.jsx)(`textarea`,{id:u,className:`dh-text`,rows:Math.min(16,Math.max(3,String(c).split(`
2105
+ `).length)),value:c,disabled:a,onChange:e=>l(e.target.value),onBlur:()=>{c!==o&&i(c)}}):t.type===`date`?(0,V.jsx)(`span`,{id:u,role:`group`,"aria-label":s,children:bJ(e,s,typeof o==`string`?o:``)?(0,V.jsx)(kJ,{value:typeof o==`string`?o:``,onChange:e=>i(e||void 0),disabled:a,label:s}):(0,V.jsx)(DJ,{value:typeof o==`string`?o.slice(0,10):``,onChange:e=>i(e||void 0),disabled:a,label:s,clearable:!t.required})}):yY.has(t.type)?(0,V.jsxs)(`span`,{className:`dh-media-tiles`,children:[(Array.isArray(o)?o:o?[o]:[]).filter(e=>e&&typeof e==`object`).map((e,t)=>(0,V.jsx)(lY,{item:e,title:`${s} ${t+1}`},t)),!(Array.isArray(o)?o.length:o)&&(0,V.jsx)(`span`,{className:`dh-muted`,children:`None in this example`})]}):(0,V.jsx)(`span`,{className:`dh-muted`,children:`Set in the example input`});return(0,V.jsxs)(`div`,{className:`dh-row`,children:[(0,V.jsx)(`label`,{htmlFor:u,title:d,children:s}),p]})}function xY({value:e,onCommit:t,disabled:n}){let r=(0,v.useMemo)(()=>JSON.stringify(e,null,2),[e]),[i,a]=(0,v.useState)(r),[o,s]=(0,v.useState)(``);return(0,v.useEffect)(()=>{a(r),s(``)},[r]),(0,V.jsxs)(`div`,{className:`dh-input`,children:[(0,V.jsx)(`textarea`,{"aria-label":`Input JSON`,spellCheck:!1,rows:8,value:i,disabled:n,onChange:e=>a(e.target.value),onBlur:()=>{if(i!==r)try{let e=JSON.parse(i||`{}`);if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`The input is one JSON object, keyed by input port.`);s(``),t(e)}catch(e){s(e.message)}}}),o&&(0,V.jsx)(`p`,{role:`alert`,children:o})]})}var SY=(0,v.memo)(function({entries:e,onClear:t}){let n=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight)},[e]),(0,V.jsxs)(`section`,{className:`dh-console`,"aria-label":`Console`,children:[(0,V.jsxs)(`div`,{className:`dh-section-head`,children:[(0,V.jsx)(`span`,{className:`dh-muted`,children:`Reloads, runs, logs, stand-ins and errors, newest last.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:t,disabled:!e.length,children:`Clear`})]}),(0,V.jsx)(`ol`,{ref:n,children:e.map(e=>(0,V.jsxs)(`li`,{className:`dh-entry dh-${e.kind}`,children:[(0,V.jsx)(`time`,{children:e.time}),(0,V.jsx)(`span`,{className:`dh-kind`,children:e.label}),(0,V.jsx)(`pre`,{children:e.text})]},e.id))}),!e.length&&(0,V.jsx)(`p`,{className:`dh-muted`,children:`Runs, logs, stand-ins, reloads and errors appear here.`})]})}),CY={run:`Run`,log:`Log`,"stand-in":`Stand-in`,reload:`Reload`,build:`Build`,error:`Error`,view:`View`},wY={full:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,V.jsx)(`path`,{d:`M8 20h8M12 16v4`})]}),tablet:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`5`,y:`2`,width:`14`,height:`20`,rx:`2`}),(0,V.jsx)(`path`,{d:`M11 18h2`})]}),phone:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`rect`,{x:`7`,y:`2`,width:`10`,height:`20`,rx:`2`}),(0,V.jsx)(`path`,{d:`M11 18h2`})]}),light:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,V.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}),dark:(0,V.jsx)(`path`,{d:`M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5z`}),white:(0,V.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`3`}),example:(0,V.jsx)(`path`,{d:`M9 3h6M10 3v6l-5 9a2 2 0 0 0 1.7 3h10.6a2 2 0 0 0 1.7-3l-5-9V3`}),done:(0,V.jsx)(`path`,{d:`M5 12.5l4.5 4.5L19 7`}),todo:(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`,strokeDasharray:`3 3`}),problem:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`}),(0,V.jsx)(`path`,{d:`M12 7.5v5.5M12 16.4v.1`})]}),focus:(0,V.jsx)(`path`,{d:`M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5`}),unfocus:(0,V.jsx)(`path`,{d:`M9 4v5H4M20 9h-5V4M15 20v-5h5M4 15h5v5`})},TY=({name:e})=>(0,V.jsx)(`svg`,{className:`dh-glyph`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:wY[e]});function EY(){let[e,t]=(0,v.useState)(()=>dY(`stillmade.dev.focus`,``)===`1`);(0,v.useEffect)(()=>{e?document.documentElement.dataset.focus=`true`:delete document.documentElement.dataset.focus,fY(`stillmade.dev.focus`,e?`1`:``)},[e]);let n=e?`Show the bars`:`Hide the bars`;return(0,V.jsx)(`button`,{type:`button`,className:`dh-focus-toggle`,"aria-pressed":e,"aria-label":n,title:n,onClick:()=>t(e=>!e),children:(0,V.jsx)(TY,{name:e?`unfocus`:`focus`})})}function DY(e,t){(0,v.useLayoutEffect)(()=>{let t=e.current,n=t?.closest(`.dh-main`);if(!t||!n)return;let r=0,i=()=>{r=0;let e=parseFloat(getComputedStyle(n).paddingTop)+parseFloat(getComputedStyle(n).paddingBottom),i=bU({width:t.parentElement.clientWidth,available:n.clientHeight-e,heightAt:e=>{t.style.zoom=e===1?``:String(e),t.style.flex=`none`,t.style.minHeight=`0`;let n=Math.ceil(t.getBoundingClientRect().height);return t.style.flex=``,t.style.minHeight=``,n},mode:`auto`});t.style.zoom=i===1?``:String(i)},a=()=>{r||=requestAnimationFrame(i)};i(),addEventListener(`resize`,a);let o=e=>{[`IMG`,`VIDEO`,`AUDIO`].includes(e.target?.tagName)&&a()};return t.addEventListener(`load`,o,!0),t.addEventListener(`loadedmetadata`,o,!0),()=>{cancelAnimationFrame(r),removeEventListener(`resize`,a),t.removeEventListener(`load`,o,!0),t.removeEventListener(`loadedmetadata`,o,!0),t.style.zoom=``}},t)}function OY({label:e,value:t,options:n,onChange:r}){return(0,V.jsx)(`div`,{className:`dh-seg`,role:`radiogroup`,"aria-label":e,children:n.map(([e,n])=>(0,V.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e,"aria-label":n,title:n,onClick:()=>r(e),children:(0,V.jsx)(TY,{name:e})},e))})}var kY=140,AY=260,jY={"text.generate":`Write`,"image.generate":`Generate a picture`,"video.generate":`Generate a video`,"audio.speech":`Speak`,"audio.music":`Make music`,"audio.sfx":`Make a sound effect`,"audio.transcribe":`Transcribe`,"image.describe":`Describe a picture`,"media.analyze":`Look at the media`,"web.fetch":`Read a web page`,"web.research":`Research the web`,"timeline.render":`Render`,"audio.decode":`Decode audio`,"audio.extract":`Take out the audio`,"audio.normalize":`Even out the loudness`,"video.cut":`Cut the video`,"video.concat":`Join videos`,"video.resize":`Resize the video`,"image.thumbnail":`Take a still`,"image.compose":`Join pictures`,"document.text":`Read a document`,"files.read":`Read a file`,"files.write":`Save a file`,"net.fetch":`Call a web service`,"connections.call":`Use a connected app`,"actions.run":`Run an action`,"assets.create":`Add to the project`},MY=e=>jY[e.name]||jY[e.api]||e.name;function NY({on:e,label:t,onChange:n}){return(0,V.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e,className:`dh-switch`,onClick:()=>n(!e),children:[(0,V.jsx)(`span`,{className:`dh-switch-track`,children:(0,V.jsx)(`span`,{className:`dh-switch-knob`})}),(0,V.jsx)(`span`,{children:t})]})}function PY({tabs:e,status:t,control:n,children:r,initial:i=null}){let[a,o]=(0,v.useState)(i),[s,c]=(0,v.useState)(()=>Number(dY(`stillmade.dev.dock`,``))||AY),l=(0,v.useRef)(null),u=e=>o(t=>t===e?null:e),d=e=>{a&&(l.current={y:e.clientY,height:s},e.currentTarget.setPointerCapture(e.pointerId))},f=e=>{let t=l.current;t&&c(Math.round(Math.max(kY,Math.min(window.innerHeight*.75,t.height+t.y-e.clientY))))},p=()=>{l.current&&(l.current=null,fY(`stillmade.dev.dock`,String(s)))},m=e.find(e=>e.key===a);return(0,V.jsxs)(`section`,{className:`dh-dock`,"data-open":m?`true`:`false`,style:m?{height:s}:void 0,"aria-label":`Run details`,children:[m&&(0,V.jsx)(`div`,{className:`dh-dock-grip`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Drag to resize`,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p}),(0,V.jsxs)(`div`,{className:`dh-tabs`,role:`tablist`,"aria-label":`Run details`,children:[e.map(e=>(0,V.jsxs)(`button`,{type:`button`,role:`tab`,id:`dh-tab-${e.key}`,"aria-selected":a===e.key,"aria-controls":`dh-tabpanel-${e.key}`,onClick:()=>u(e.key),children:[e.label,e.alert&&(0,V.jsx)(`span`,{className:`dh-alert`,"aria-label":`has a problem`})]},e.key)),(0,V.jsx)(`span`,{className:`dh-tabs-status`,role:`status`,children:t}),n,(0,V.jsx)(`button`,{type:`button`,className:`dh-icon dh-fold`,"aria-label":m?`Fold the panel`:`Open the panel`,title:m?`Fold the panel`:`Open the panel`,"aria-expanded":!!m,onClick:()=>o(t=>t?null:e[0].key),children:(0,V.jsx)(cJ,{name:`chevronRight`,size:16})})]}),m&&(0,V.jsx)(`div`,{className:`dh-tabpanel`,role:`tabpanel`,id:`dh-tabpanel-${m.key}`,"aria-labelledby":`dh-tab-${m.key}`,children:r(m.key)})]})}function FY({item:e=null,extraTabs:t=[],badges:n=null,dockOpen:r=null}={}){let i=e?`?item=${encodeURIComponent(e)}`:``,[a,o]=(0,v.useState)({revision:0,content:null,problem:null,folder:``}),[s,c]=(0,v.useState)(0),[l,u]=(0,v.useState)(()=>dY(`stillmade.dev.theme`,`light`)),[d,f]=(0,v.useState)(()=>dY(`stillmade.dev.width`,`full`)),[p,m]=(0,v.useState)(0),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)({}),[A,j]=(0,v.useState)([]),[M,N]=(0,v.useState)({}),P=(0,v.useRef)({}),F=(0,v.useRef)(0),I=(0,v.useCallback)((e,t)=>j(n=>[...n.slice(-299),{id:++F.current,kind:e,label:CY[e]||e,time:new Date().toLocaleTimeString(),text:String(t)}]),[]),ee=(0,v.useCallback)(async()=>{let e=await(await fetch(`/__dev/package${i}`,{cache:`no-store`})).json();return o(e),e},[i]);(0,v.useEffect)(()=>{let t=!0;ee().then(e=>{t&&(g(t=>t??(e.content?.tests?.[0]?.input||{})),I(`reload`,`Previewing ${e.folder}`),e.problem&&I(`error`,tY(e.problem)))}).catch(e=>I(`error`,e.message));let n=new EventSource(`/__dev/events`);return n.addEventListener(`package`,async n=>{let r=JSON.parse(n.data);if(!(e&&r.item!==e))try{if(await ee(),!t)return;c(e=>e+1),I(r.problem?`error`:`reload`,r.problem?`Reloaded with a problem: ${tY(r.problem)}`:`Reloaded after a change`)}catch(e){I(`error`,e.message)}}),n.addEventListener(`build`,t=>{let n=JSON.parse(t.data);e&&n.items&&!n.items.includes(e.slice(e.indexOf(`/`)+1))||(n.state===`running`?I(`build`,`Building: ${n.command||n.items.join(`, `)}`):n.state===`done`?I(`build`,`Build finished`):I(`error`,`Build failed${n.output?`\n${n.output}`:``}`))}),()=>{t=!1,n.close()}},[]),(0,v.useEffect)(()=>{document.documentElement.dataset.mode=l,fY(`stillmade.dev.theme`,l)},[l]),(0,v.useEffect)(()=>{fY(`stillmade.dev.width`,d)},[d]);let te=a.content,L=te?.manifest,R=te?.tests||[],ne=e=>{m(e),g(R[e]?.input||{})},re=(0,v.useCallback)(async(e,{signal:t}={})=>{I(`run`,`Run started`),x(!0),C(``);try{let n=await pY(e,i);if(t?.aborted)throw Object.assign(Error(`Run cancelled`),{code:`CANCELLED`});for(let e of n.logs||[])I(`log`,e);for(let e of n.standIns||[])I(`stand-in`,`${e.api} ${e.name} (${e.source===`picked`?`your file`:e.source===`example`?`example file`:/mocks/.test(e.source)?`the Block's tests`:`recorded stand-in`})`);if(T({ms:n.ms,calls:n.standIns||[],failed:!!n.error}),n.error)throw I(`error`,`${n.error}${n.code?` (${n.code})`:``}`),Object.assign(Error(n.error),{code:n.code});return y(n.outputs),I(`run`,`Finished in ${n.ms} ms`),n.outputs}catch(e){throw e?.code!==`CANCELLED`&&(y(null),C(e?.message||`The run did not finish.`)),e}finally{x(!1)}},[I,i]),ie=(0,v.useCallback)(async e=>{let t=dr(P.current,e);P.current=t,N(t)},[]),ae=()=>{P.current={},N({}),c(e=>e+1),I(`view`,`Shared state cleared`)},[oe,se]=(0,v.useState)([]),ce=(0,v.useMemo)(()=>({state:M,outputs:{},made:oe,memory:null,canEdit:!0}),[M,oe]),le=(0,v.useCallback)(async e=>{y(e),I(`view`,`The view chose its outputs`)},[I]),ue=(0,v.useCallback)(async(e,t)=>{let n=a.content?.manifest?.inputs?.[e],{refs:r,apply:i}=await oY(e,n,t);return E&&$J.has(n.type)?k(t=>({...t,[e]:r[0]})):g(i),I(`view`,`Added ${r.length} ${r.length===1?`file`:`files`} to ${Jq(e)}`),{added:r.length}},[a.content,E,I]),de=(0,v.useCallback)(async(e,t)=>{let n=Tq(h?.[e],t);return g(t=>({...t,[e]:n})),I(`view`,`${t.op===`remove`?`Removed a file from`:`Moved a file in`} ${Jq(e)}`),{files:n.length}},[h,I]),fe=(0,v.useCallback)(e=>I(`error`,String(e?.message||e)),[I]),pe=(0,v.useCallback)(async e=>{let t=Array.isArray(e?.items)?e.items.length:0,n=Array.isArray(e?.hosted)?e.hosted.length:0;return I(`view`,`StillMade would price the next run: ${[t&&`${t} generated ${t===1?`item`:`items`}`,n&&`${n} hosted ${n===1?`call`:`calls`}`].filter(Boolean).join(` and `)||`nothing`}. The preview shows 0 credits.`),{credits:0}},[I]),me=(0,v.useCallback)(async e=>{let t=document.createElement(`a`);t.href=e.url,t.download=String(e.url).split(/[?#]/)[0].split(`/`).pop()||e.kind,document.body.append(t),t.click(),t.remove(),I(`view`,`Downloaded the ${e.kind===`image`?`picture`:e.kind===`video`?`clip`:`sound`}`)},[I]),he=(0,v.useMemo)(()=>{let e={...h||{}};if(E)for(let[t,n]of Object.entries(a.content?.manifest?.inputs||{}))$J.has(n.type)&&(O[t]?e[t]=O[t]:delete e[t]);return e},[h,E,O,a.content]),ge=(0,v.useCallback)(e=>g(t=>{if(!E)return e;let n={...e};for(let[e,r]of Object.entries(a.content?.manifest?.inputs||{}))$J.has(r.type)&&(t&&Object.hasOwn(t,e)?n[e]=t[e]:delete n[e]);return n}),[E,a.content]),_e=(0,v.useCallback)(async(e,t)=>{let n=sY(a.content?.manifest?.inputs,he,e);Object.keys(e).length&&ge({...h||{},...e});let r=await re(n,t),i=Object.values(r||{}).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>e&&[`image`,`video`,`audio`].includes(e.kind)&&typeof e.url==`string`&&typeof e.assetId==`string`).map(({kind:e,assetId:t,versionId:n,url:r})=>({kind:e,assetId:t,versionId:n,url:r}));return i.length&&se(e=>[...i,...e.filter(e=>!i.some(t=>t.url===e.url))].slice(0,400)),r},[a.content,he,h,ge,re]),ve=QJ.find(([e])=>e===d)?.[2],ye=te?.capability?.operation?[te.capability.operation]:(L?.permissions?.capabilities||[]).filter(e=>![`connection.execute`,`comfyui.execute`].includes(e)),be=b?rK(ye.length===1?ye[0]:void 0,te)[1]:aK(ye.length===1?ye[0]:void 0,{credits:0},{connector:te}),z=(0,v.useMemo)(()=>PJ(L,{labels:Object.fromEntries((L?.ui||[]).filter(e=>e?.label).map(e=>[e.port,e.label])),groups:L?.uiLayout?.groups||[]}),[L]),xe=(0,v.useRef)(null);DY(xe,[te,d,_,S,b]);let Se=_?Object.entries(L?.outputs||{}).filter(([e])=>_[e]!==void 0).map(([e,t])=>t?.type===`date`&&typeof _[e]==`string`&&/^\d{4}-\d{2}-\d{2}/.test(_[e])?(0,V.jsx)(`p`,{className:`dh-date`,children:(0,V.jsx)(`time`,{dateTime:_[e],children:xJ(_[e])})},e):(0,V.jsx)(nJ,{value:_[e],renderMedia:vY},e)):null,Ce=b?`Running…`:w?w.failed?`Last run failed`:`Ran in ${w.ms} ms${w.calls.length?` · ${w.calls.length} ${w.calls.length===1?`call`:`calls`} answered by stand-ins`:``}`:`Reloads when you save`,we=[...t,{key:`activity`,label:`Activity`,alert:A.some(e=>e.kind===`error`)},{key:`calls`,label:`Calls${w?.calls.length?` · ${w.calls.length}`:``}`},...te?.view?[{key:`result`,label:`Result`}]:[],{key:`input`,label:`Input data`}];return(0,V.jsxs)(`div`,{className:`dh-page`,children:[(0,V.jsxs)(`header`,{className:`dh-bar`,children:[(0,V.jsxs)(`div`,{className:`dh-title`,children:[(0,V.jsx)(`h1`,{children:L?.name||`Block preview`}),L&&(0,V.jsx)(`span`,{className:`dh-meta`,children:L.version}),n]}),(0,V.jsx)(`span`,{className:`dh-spacer`}),R.length>1&&(0,V.jsxs)(`label`,{className:`dh-picker`,title:`Example input`,children:[(0,V.jsx)(TY,{name:`example`}),(0,V.jsx)(`select`,{"aria-label":`Example`,value:p,onChange:e=>ne(Number(e.target.value)),children:R.map((e,t)=>(0,V.jsx)(`option`,{value:t,children:e.name},t))})]}),(0,V.jsx)(OY,{label:`Width`,value:d,options:QJ,onChange:f}),(0,V.jsx)(OY,{label:`Appearance`,value:l,options:ZJ,onChange:u}),(0,V.jsx)(`button`,{type:`button`,className:`dh-icon`,"aria-label":`Reload the Block`,title:`Reload the Block`,onClick:()=>c(e=>e+1),children:(0,V.jsx)(cJ,{name:`refresh`,size:16})})]}),a.problem&&(0,V.jsx)(`p`,{className:`dh-problem`,role:`alert`,children:tY(a.problem)}),(0,V.jsx)(`main`,{className:`dh-main`,"aria-label":`Preview`,children:(0,V.jsx)(`div`,{className:`dh-frame`,style:ve?{maxWidth:ve}:void 0,children:te?te.view?(0,V.jsx)(zq,{fitContent:!0,view:te.view,policyContent:te,input:he,sharedView:ce,onSharedChange:ie,onRun:_e,onUseOutput:le,onAddFiles:ue,onChangeFiles:de,onPreviewImage:mY,onPreviewMedia:hY,onPreviewVoice:gY,onModels:vK,onRunPrice:pe,onDownload:me,onAllowSpending:async({credits:e,label:t})=>(console.info(`StillMade would ask to approve up to ${e} credits for "${t}". The SDK preview spends none.`),e),onError:fe,actorId:`dev-preview`,title:`${L.name} preview`,height:560,fitContent:!0},s):(0,V.jsxs)(`div`,{className:z.focused?`dh-noview dh-focus`:`dh-noview`,ref:xe,children:[z.focused&&(0,V.jsxs)(`header`,{className:`dh-intro`,children:[(0,V.jsx)(`h2`,{children:z.heading}),z.line&&(0,V.jsx)(`p`,{children:z.line})]}),(0,V.jsx)(`div`,{className:`dh-form`,children:Object.entries(L.inputs||{}).map(([e,t])=>$J.has(t.type)?(0,V.jsx)(cY,{name:e,port:t,title:(L.ui||[]).find(t=>t?.port===e)?.label||Jq(e),value:he[e],own:E,disabled:b,onPick:t=>k(n=>({...n,[e]:t}))},e):(0,V.jsx)(bY,{name:e,port:t,control:(L.ui||[]).find(t=>t?.port===e),value:he[e],disabled:b,onCommit:t=>g(n=>({...n,[e]:t}))},e))}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:b,onClick:()=>re(he).catch(()=>{}),children:be}),S&&(0,V.jsx)(`p`,{className:`dh-run-problem`,role:`alert`,children:S}),Se?(0,V.jsxs)(`div`,{className:`dh-results`,children:[(0,V.jsx)(`h2`,{children:`Result`}),Se]}):!S&&(0,V.jsx)(`div`,{className:`dh-results dh-results-empty`,children:(0,V.jsx)(zJ,{...RJ(L,{inputs:he})})})]}):(0,V.jsx)(`p`,{className:`dh-muted`,role:`status`,children:`Loading the Block`})})}),(0,V.jsx)(PY,{tabs:we,status:Ce,initial:r,control:(0,V.jsx)(NY,{on:!E,label:`Example media`,onChange:e=>D(!e)}),children:e=>t.find(t=>t.key===e)?.render()??(e===`activity`?(0,V.jsx)(SY,{entries:A,onClear:()=>j([])}):e===`calls`?w?.calls.length?(0,V.jsx)(`ol`,{className:`dh-calls`,children:w.calls.map((e,t)=>(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`strong`,{children:MY(e)}),(0,V.jsx)(`span`,{children:e.name}),(0,V.jsx)(`small`,{children:e.source===`picked`?`read from your file`:e.source===`example`?`read from a StillMade example file`:/mocks/.test(e.source)?`answered from the Block's tests`:`answered by a recorded stand-in`})]},t))}):(0,V.jsx)(`p`,{className:`dh-muted`,children:w?`The last run made no hosted or media calls.`:`Run the Block to see the calls it makes and what answered each one.`}):e===`result`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`dh-section-head`,children:[(0,V.jsx)(`span`,{className:`dh-muted`,children:`What the Block's view returned.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:ae,children:`Clear shared state`})]}),S&&(0,V.jsx)(`p`,{className:`dh-run-problem`,role:`alert`,children:S}),Se||!S&&(0,V.jsx)(`p`,{className:`dh-muted`,children:`Nothing has run yet.`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`dh-section-head`,children:[(0,V.jsx)(`span`,{className:`dh-muted`,children:`The exact input the Block runs with, for values the controls cannot set.`}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:b||!te,onClick:()=>re(he).catch(()=>{}),children:be})]}),h&&(0,V.jsx)(xY,{value:he,onCommit:ge,disabled:!te}),_&&(0,V.jsx)(`pre`,{className:`dh-json`,children:JSON.stringify(_,null,2)})]}))})]})}var IY={block:`layers`,connector:`plug`,automation:`clock`,workflow:`list`},LY={block:`Block`,connector:`Connector`,automation:`Automation`,workflow:`Project Type`},RY={module:`Module`,javascript:`JavaScript`,recipe:`Recipe`,capability:`Hosted`,comfyui:`ComfyUI`,desktop:`Desktop`,"browser-application":`Application`},zY={ready:`Gate passed`,"needs-fix":`Needs a fix`,unchecked:`Not checked since it changed`,building:`Being built`},BY=e=>e.kind===`workflow`?`workflow`:e.blockKind||`block`,VY=e=>e.kind===`workflow`?`${e.automation?`Automation`:`Project Type`} · ${e.steps} ${e.steps===1?`Step`:`Steps`}`:[BY(e)===`block`?RY[e.runtime]||`Block`:LY[BY(e)],e.version].filter(Boolean).join(` · `);function HY({status:e}){return(0,V.jsx)(`span`,{className:`ws-dot ws-dot-${e}`,role:`img`,"aria-label":zY[e]||e,title:zY[e]||e})}function UY({templates:e,onAdded:t,onCancel:n}){let[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(`module`),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``);return(0,V.jsxs)(`form`,{className:`ws-new`,onSubmit:async e=>{if(e.preventDefault(),r.trim()){c(!0),u(``);try{let e=await fetch(`/__dev/new`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:r,template:a})}),n=await e.json();if(!e.ok)throw Error(n.error||`The Block could not be added.`);t(n.key)}catch(e){u(e.message)}finally{c(!1)}}},children:[(0,V.jsxs)(`label`,{className:`ws-field`,children:[(0,V.jsx)(`span`,{children:`Name`}),(0,V.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`price-drop-alert`,autoFocus:!0,disabled:s})]}),(0,V.jsxs)(`label`,{className:`ws-field`,children:[(0,V.jsx)(`span`,{children:`Start from`}),(0,V.jsx)(`select`,{value:a,onChange:e=>o(e.target.value),disabled:s,children:e.map(e=>(0,V.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),l&&(0,V.jsx)(`p`,{className:`ws-problem`,role:`alert`,children:l}),(0,V.jsxs)(`div`,{className:`ws-new-actions`,children:[(0,V.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,disabled:s||!r.trim(),children:s?`Adding`:`Add Block`}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:n,children:`Cancel`})]})]})}function WY({data:e,selected:t,onSelect:n,folded:r,onFold:i,follow:a,onFollow:o}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)([]),d=()=>{r&&i(!1),c(!0),l.length||fetch(`/__dev/templates`).then(e=>e.json()).then(u).catch(()=>{})},f=e.items.filter(e=>e.kind===`block`),p=e.items.filter(e=>e.kind===`workflow`),m=e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`ws-item`,"aria-current":t===e.key?`true`:void 0,onClick:()=>n(e.key),title:r?`${e.name}: ${zY[e.status]||``}`:void 0,children:[(0,V.jsx)(`span`,{className:`ws-kind`,children:(0,V.jsx)(cJ,{name:IY[BY(e)],size:14})}),(0,V.jsxs)(`span`,{className:`ws-text`,children:[(0,V.jsx)(`b`,{children:e.name}),(0,V.jsx)(`small`,{children:VY(e)})]}),(0,V.jsx)(HY,{status:e.status})]})},e.key),h=`${f.length} ${f.length===1?`Block`:`Blocks`} · ${p.length} ${p.length===1?`workflow`:`workflows`}`;return(0,V.jsxs)(`aside`,{className:`ws-side`,"aria-label":`Workspace`,children:[(0,V.jsxs)(`div`,{className:`ws-head`,children:[(0,V.jsx)(`button`,{type:`button`,className:`dh-icon ws-fold`,"aria-label":r?`Open the list`:`Fold the list`,title:r?`Open the list`:`Fold the list`,"aria-expanded":!r,onClick:()=>i(!r),children:(0,V.jsx)(cJ,{name:r?`chevronRight`:`chevronLeft`,size:16})}),(0,V.jsxs)(`div`,{className:`ws-title`,children:[(0,V.jsx)(`h1`,{children:e.name}),(0,V.jsx)(`small`,{children:h})]})]}),(0,V.jsxs)(`nav`,{className:`ws-list`,children:[(0,V.jsx)(`h2`,{className:`ws-group`,children:`Blocks`}),f.length?(0,V.jsx)(`ul`,{children:f.map(m)}):(0,V.jsx)(`p`,{className:`ws-empty`,children:`No Blocks yet. Add one below, or ask your agent.`}),p.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`ws-group`,children:`Workflows`}),(0,V.jsx)(`ul`,{children:p.map(m)})]}),e.shared.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`ws-group`,children:`Shared code`}),(0,V.jsx)(`ul`,{children:(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`ws-item`,"aria-current":t===`shared`?`true`:void 0,onClick:()=>n(`shared`),title:r?`Shared code`:void 0,children:[(0,V.jsx)(`span`,{className:`ws-kind`,children:(0,V.jsx)(cJ,{name:`folder`,size:14})}),(0,V.jsxs)(`span`,{className:`ws-text`,children:[(0,V.jsx)(`b`,{children:`shared/`}),(0,V.jsxs)(`small`,{children:[e.shared.length,` `,e.shared.length===1?`file`:`files`]})]}),(0,V.jsx)(`span`,{})]})})})]})]}),(0,V.jsxs)(`div`,{className:`ws-foot`,children:[s?(0,V.jsx)(UY,{templates:l.length?l:[{name:`module`}],onAdded:e=>{c(!1),n(e)},onCancel:()=>c(!1)}):(0,V.jsxs)(`button`,{type:`button`,className:`btn btn-ghost ws-add`,onClick:d,title:r?`New Block`:void 0,children:[(0,V.jsx)(cJ,{name:`plus`,size:14}),(0,V.jsx)(`span`,{className:`ws-text`,children:`New Block`})]}),!s&&(0,V.jsxs)(`div`,{className:`ws-text ws-follow`,children:[(0,V.jsx)(NY,{on:a,label:`Follow the agent`,onChange:o}),(0,V.jsx)(`small`,{children:`Opens the Block your agent last saved.`})]})]})]})}function GY({item:e,onCheck:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(``),o=async()=>{r(!0),a(``);try{await t()}catch(e){a(e.message)}finally{r(!1)}},s=e.gate,c=s?.current;return(0,V.jsxs)(`div`,{className:`ws-checks`,children:[(0,V.jsxs)(`div`,{className:`dh-section-head`,children:[(0,V.jsxs)(`span`,{className:`dh-muted`,children:[zY[e.status],`. The gate runs StillMade's readiness check on every Block that changed.`]}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:n,onClick:o,children:n?`Running the gate`:`Run the gate`})]}),(0,V.jsxs)(`ul`,{className:`ws-checklist`,children:[e.problem&&(0,V.jsxs)(`li`,{"data-state":`failed`,children:[(0,V.jsx)(TY,{name:`problem`}),(0,V.jsx)(`span`,{children:e.problem})]}),e.buildProblem&&(0,V.jsxs)(`li`,{"data-state":`failed`,children:[(0,V.jsx)(TY,{name:`problem`}),(0,V.jsxs)(`span`,{children:[`Build from `,e.source,` failed: `,e.buildProblem]})]}),e.source&&!e.buildProblem&&(0,V.jsxs)(`li`,{"data-state":`done`,children:[(0,V.jsx)(TY,{name:`done`}),(0,V.jsxs)(`span`,{children:[`Built from `,e.source,e.shared.length?`, with shared/${e.shared.join(`, shared/`)}`:``]})]}),e.triggers?.length>0&&(0,V.jsxs)(`li`,{"data-state":`done`,children:[(0,V.jsx)(TY,{name:`done`}),(0,V.jsxs)(`span`,{children:[`Runs on its own: `,e.triggers.join(`; `),`. Its owner turns it on for a Step in a project; here it runs when you press its button.`]})]}),e.apps?.length>0&&(0,V.jsxs)(`li`,{"data-state":`done`,children:[(0,V.jsx)(TY,{name:`done`}),(0,V.jsxs)(`span`,{children:[`Uses `,e.apps.map(e=>e.replace(/^app:(openapi:)?/,``)).join(`, `),` with the account each person connects. Here `,e.apps.length===1?`it answers`:`they answer`,` from tests/mocks.json.`]})]}),e.checklist?.map(e=>(0,V.jsxs)(`li`,{"data-state":e.done?`done`:`todo`,children:[(0,V.jsx)(TY,{name:e.done?`done`:`todo`}),(0,V.jsx)(`span`,{children:e.label}),(0,V.jsx)(`small`,{children:e.done?`done`:`to do`})]},e.id)),(0,V.jsxs)(`li`,{"data-state":c?s.ok?`done`:`failed`:`waiting`,children:[(0,V.jsx)(TY,{name:c?s.ok?`done`:`problem`:`todo`}),(0,V.jsxs)(`span`,{children:[`Readiness gate`,c?`: ${s.status}`:s?`: changed since it last ran`:`: not run yet`]}),(0,V.jsx)(`small`,{children:s?.checkedAt?new Date(s.checkedAt).toLocaleTimeString():``})]}),c&&!s.ok&&s.failures.map((e,t)=>(0,V.jsx)(`li`,{className:`ws-failure`,children:e},t))]}),i&&(0,V.jsx)(`p`,{className:`ws-problem`,role:`alert`,children:i})]})}var KY={completed:`Done`,skipped:`Skipped`,disabled:`Off in this workflow`,failed:`Failed`,blocked:`Waiting on an earlier Step`,"needs-project":`Runs only in a StillMade project`,"needs-context":`Needs project context`,"needs-sample":`Needs a sample input`,"needs-hosted-run":`Runs on credits in StillMade`,deferred:`Runs in StillMade`},qY=e=>e===`completed`?`done`:e===`failed`?`failed`:e===`running`?`running`:e?`waiting`:`idle`;function JY({itemKey:e,revision:t,theme:n,setTheme:r}){let[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{let t=!0;return fetch(`/__dev/workflow?item=${encodeURIComponent(e)}`,{cache:`no-store`}).then(e=>e.json()).then(e=>{t&&(a(e),p(t=>t??e.samples??{}))}).catch(e=>t&&a({problem:e.message})),()=>{t=!1}},[e,t]),(0,v.useEffect)(()=>{let t=new EventSource(`/__dev/events`);return t.addEventListener(`step`,t=>{let n=JSON.parse(t.data);n.item===e&&s(e=>({...e,[n.step.id]:n.step}))}),()=>t.close()},[e]);let m=async()=>{d(!0),s({}),l(null);try{let t=await(await fetch(`/__dev/workflow/run?item=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({inputs:f})})).json();l(t),t.results&&s(Object.fromEntries(t.results.map(e=>[e.id,e])))}catch(e){l({error:e.message})}finally{d(!1)}};if(!i)return(0,V.jsx)(`div`,{className:`dh-page`,children:(0,V.jsx)(`p`,{className:`dh-muted ws-pad`,role:`status`,children:`Loading the workflow`})});if(i.problem)return(0,V.jsx)(`div`,{className:`dh-page`,children:(0,V.jsx)(`p`,{className:`dh-problem`,role:`alert`,children:i.problem})});let h=[...i.steps].reverse().find(e=>o[e.id]?.outputs),g=h&&o[h.id],_=c?.standIns||[],y=u?`Running the Steps…`:c?.error?`The run did not finish`:c?`Ran in ${c.ms} ms${_.length?` · ${_.length} ${_.length===1?`call`:`calls`} answered by stand-ins`:``}`:`Runs on this computer with stand-ins`,b=[{key:`steps`,label:`Steps`},{key:`samples`,label:`Sample inputs`},{key:`connections`,label:`Connections · ${i.connections.length}`}],x=e=>i.steps.find(t=>t.id===e)?.label||e;return(0,V.jsxs)(`div`,{className:`dh-page`,children:[(0,V.jsxs)(`header`,{className:`dh-bar`,children:[(0,V.jsxs)(`div`,{className:`dh-title`,children:[(0,V.jsx)(`h1`,{children:i.name}),(0,V.jsxs)(`span`,{className:`dh-meta`,children:[i.automation?`Automation`:`Project Type`,` · `,i.version]})]}),(0,V.jsx)(`span`,{className:`dh-spacer`}),(0,V.jsx)(OY,{label:`Appearance`,value:n,options:ZJ,onChange:r}),(0,V.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:u,onClick:m,children:u?`Running the workflow`:i.automation?`Run once now · 0 credits`:`Run the workflow · 0 credits`})]}),(0,V.jsxs)(`main`,{className:`dh-main ws-flow`,"aria-label":`Workflow`,children:[(0,V.jsx)(`ol`,{className:`ws-steps`,children:i.steps.map((e,t)=>{let n=o[e.id],r=u&&!n?`running`:qY(n?.status);return(0,V.jsxs)(`li`,{className:`ws-step`,"data-tone":r,children:[(0,V.jsxs)(`span`,{className:`ws-step-n`,children:[`Step `,t+1]}),(0,V.jsx)(`b`,{children:e.label}),(0,V.jsxs)(`span`,{className:`ws-ports`,children:[(0,V.jsxs)(`span`,{children:[`In: `,e.inputs.map(e=>e.name).join(`, `)||`nothing`]}),(0,V.jsxs)(`span`,{children:[`Out: `,e.outputs.map(e=>e.name).join(`, `)||`nothing`]})]}),(0,V.jsx)(`span`,{className:`ws-step-state`,children:r===`running`?`Waiting to run`:n?`${KY[n.status]||n.status}${n.status===`failed`&&n.message?`: ${n.message}`:``}`:`Not run yet`})]},e.id)})}),(0,V.jsxs)(`section`,{className:`ws-outcome`,"aria-label":`Result`,children:[(0,V.jsx)(`div`,{className:`ws-outcome-main`,children:c?.error?(0,V.jsx)(`p`,{className:`dh-run-problem`,role:`alert`,children:c.error}):g?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{children:h.label}),Object.entries(g.outputs).map(([e,t])=>(0,V.jsxs)(`div`,{className:`ws-output`,children:[(0,V.jsx)(`span`,{children:Jq(e)}),(0,V.jsx)(nJ,{value:t,renderMedia:vY})]},e))]}):(0,V.jsx)(`p`,{className:`dh-muted`,children:u?`Running…`:`Run the workflow to see what its last Step makes.`})}),(0,V.jsxs)(`aside`,{className:`ws-outcome-side`,children:[(0,V.jsx)(`h2`,{children:`What this run used`}),_.length?(0,V.jsx)(`ul`,{children:_.map((e,t)=>(0,V.jsxs)(`li`,{children:[e.api,` `,e.name,`: `,/mocks/.test(e.source)?`answered from the Block's tests`:`a recorded stand-in`]},t))}):(0,V.jsx)(`p`,{className:`dh-muted`,children:c?`No hosted calls.`:`Nothing yet.`}),(0,V.jsx)(`p`,{className:`ws-note`,children:`A stand-in run proves the Steps fit together. Real voices, pictures and video run only in StillMade, on credits.`}),i.automation&&(0,V.jsx)(`p`,{className:`ws-note`,children:`An automation. In a project its first Step waits for what is turned on on the Automation page: a schedule, an app event or a webhook. Here it runs once, as if started by hand.`})]})]})]}),(0,V.jsx)(PY,{tabs:b,status:y,children:t=>t===`steps`?(0,V.jsx)(`ol`,{className:`dh-calls`,children:i.steps.map(e=>{let t=o[e.id];return(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`strong`,{children:e.label}),(0,V.jsx)(`span`,{children:e.folder?`blocks/${e.folder}`:`${e.blockId}@${e.version}`}),(0,V.jsxs)(`small`,{children:[t?KY[t.status]||t.status:`Not run yet`,t?.message&&t.status!==`completed`?`: ${t.message}`:``]})]},e.id)})}):t===`samples`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`dh-section-head`,children:(0,V.jsxs)(`span`,{className:`dh-muted`,children:[`What each Step starts with, by Step id. Saved in workflows/`,e.split(`/`).pop(),`.samples.json, the run uses that file instead.`]})}),(0,V.jsx)(xY,{value:f||{},onCommit:p,disabled:u})]}):(0,V.jsxs)(`ol`,{className:`dh-calls`,children:[i.connections.map((e,t)=>(0,V.jsxs)(`li`,{children:[(0,V.jsxs)(`strong`,{children:[x(e.from.stage),`: `,e.from.port]}),(0,V.jsxs)(`span`,{children:[`to `,x(e.to.stage),`: `,e.to.port]})]},t)),!i.connections.length&&(0,V.jsx)(`li`,{children:`No connections. Each Step takes only its own inputs.`})]})})]})}function YY({data:e}){return(0,V.jsxs)(`div`,{className:`dh-page`,children:[(0,V.jsx)(`header`,{className:`dh-bar`,children:(0,V.jsxs)(`div`,{className:`dh-title`,children:[(0,V.jsx)(`h1`,{children:`Shared code`}),(0,V.jsx)(`span`,{className:`dh-meta`,children:`shared/`})]})}),(0,V.jsx)(`main`,{className:`dh-main`,children:(0,V.jsxs)(`div`,{className:`ws-shared`,children:[(0,V.jsx)(`p`,{className:`dh-muted`,children:`Module Blocks import these files from src/main.js. Building joins them into each Block, so every packed Block still stands alone.`}),(0,V.jsx)(`ul`,{className:`dh-calls`,children:e.shared.map(e=>(0,V.jsxs)(`li`,{children:[(0,V.jsxs)(`strong`,{children:[`shared/`,e.file]}),(0,V.jsx)(`small`,{children:e.usedBy.length?`Used by ${e.usedBy.join(`, `)}`:`Not used yet`})]},e.file))})]})})]})}var XY=()=>{try{return decodeURIComponent(location.hash.slice(1))}catch{return``}};function ZY({initial:e}){let[t,n]=(0,v.useState)(e),[r,i]=(0,v.useState)(()=>{let t=XY();return e.items.some(e=>e.key===t)||t===`shared`?t:e.items[0]?.key||``}),[a,o]=(0,v.useState)(()=>dY(`stillmade.dev.workspace.folded`,``)===`1`),[s,c]=(0,v.useState)(()=>dY(`stillmade.dev.workspace.follow`,`1`)===`1`),[l,u]=(0,v.useState)(()=>dY(`stillmade.dev.theme`,`light`)),[d,f]=(0,v.useState)(0),p=(0,v.useRef)(s);p.current=s;let m=(0,v.useCallback)(()=>fetch(`/__dev/workspace`,{cache:`no-store`}).then(e=>e.json()).then(e=>(n(e),e)),[]),h=(0,v.useCallback)(e=>{i(e);try{history.replaceState(null,``,`#${encodeURIComponent(e)}`)}catch{}},[]);(0,v.useEffect)(()=>{let e=new EventSource(`/__dev/events`);return e.addEventListener(`workspace`,e=>{let t=JSON.parse(e.data);m().then(e=>{t.focus&&p.current&&e.items.some(e=>e.key===t.focus)&&h(t.focus),f(e=>e+1)}).catch(()=>{})}),()=>e.close()},[m,h]),(0,v.useEffect)(()=>{document.documentElement.dataset.mode=l,fY(`stillmade.dev.theme`,l)},[l]),(0,v.useEffect)(()=>{fY(`stillmade.dev.workspace.folded`,a?`1`:``)},[a]),(0,v.useEffect)(()=>{fY(`stillmade.dev.workspace.follow`,s?`1`:``)},[s]);let g=t.items.find(e=>e.key===r),_=(0,v.useCallback)(async()=>{if(!(await fetch(`/__dev/check`,{method:`POST`})).ok)throw Error(`The gate could not run.`);await m()},[m]),y=(0,v.useMemo)(()=>g?.kind===`block`?[{key:`checks`,label:`Checks`,alert:g.status===`needs-fix`,render:()=>(0,V.jsx)(GY,{item:g,onCheck:_})}]:[],[g,_]),b=g?.kind===`block`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`ws-chip`,children:LY[BY(g)]}),g.status!==`ready`&&(0,V.jsx)(`span`,{className:`ws-chip`,"data-status":g.status,children:zY[g.status]})]}):null;return(0,V.jsxs)(`div`,{className:`ws-page`,"data-folded":a?`true`:`false`,children:[(0,V.jsx)(WY,{data:t,selected:r,onSelect:h,folded:a,onFold:o,follow:s,onFollow:c}),(0,V.jsx)(`div`,{className:`ws-content`,children:!g&&r!==`shared`?(0,V.jsx)(`div`,{className:`dh-page`,children:(0,V.jsxs)(`div`,{className:`ws-pad`,children:[(0,V.jsx)(`h2`,{className:`ws-hello`,children:t.name}),(0,V.jsxs)(`p`,{className:`dh-muted`,children:[`Add a Block from the list, or ask your agent to run `,(0,V.jsx)(`code`,{children:`stillmade-block add <name>`}),`. It shows up here by itself.`]})]})}):r===`shared`?(0,V.jsx)(YY,{data:t}):g.kind===`workflow`?(0,V.jsx)(JY,{itemKey:g.key,revision:d,theme:l,setTheme:u},g.key):(0,V.jsx)(FY,{item:g.key,extraTabs:y,badges:b,dockOpen:g.status===`ready`?null:`checks`},g.key)})]})}var QY=(0,y.createRoot)(document.getElementById(`root`));fetch(`/__dev/workspace`,{cache:`no-store`}).then(e=>e.ok?e.json():null).catch(()=>null).then(e=>QY.render((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(EY,{}),e?(0,V.jsx)(ZY,{initial:e}):(0,V.jsx)(FY,{})]})));