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

@agility/app-sdk

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agility/app-sdk - npm Package Compare versions

Comparing version 2.0.0-rc16 to 2.0.0-rc17

2

dist/cjs/index.js

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

"use strict";var e=require("react"),t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};function r(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function n(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function i(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function a(e){return"function"==typeof e}function s(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var u=s((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function c(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var p=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,s,c;if(!this.closed){this.closed=!0;var p=this._parentage;if(p)if(this._parentage=null,Array.isArray(p))try{for(var l=n(p),f=l.next();!f.done;f=l.next()){f.value.remove(this)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}else p.remove(this);var d=this.initialTeardown;if(a(d))try{d()}catch(e){c=e instanceof u?e.errors:[e]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var h=n(b),y=h.next();!y.done;y=h.next()){var I=y.value;try{v(I)}catch(e){c=null!=c?c:[],e instanceof u?c=i(i([],o(c)),o(e.errors)):c.push(e)}}}catch(e){r={error:e}}finally{try{y&&!y.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(c)throw new u(c)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)v(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&c(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&c(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),l=p.EMPTY;function f(e){return e instanceof p||e&&"closed"in e&&a(e.remove)&&a(e.add)&&a(e.unsubscribe)}function v(e){a(e)?e():e.unsubscribe()}var d={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},b={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var a=b.delegate;return(null==a?void 0:a.setTimeout)?a.setTimeout.apply(a,i([e,t],o(r))):setTimeout.apply(void 0,i([e,t],o(r)))},clearTimeout:function(e){var t=b.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function h(){}function y(e){e()}var I=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,f(t)&&t.add(r)):r.destination=S,r}return r(t,e),t.create=function(e,t,r){return new g(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(p),m=Function.prototype.bind;function w(e,t){return m.call(e,t)}var D=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){_(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){_(e)}else _(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){_(e)}},e}(),g=function(e){function t(t,r,n){var o,i,s=e.call(this)||this;a(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:s&&d.useDeprecatedNextContext?((i=Object.create(t)).unsubscribe=function(){return s.unsubscribe()},o={next:t.next&&w(t.next,i),error:t.error&&w(t.error,i),complete:t.complete&&w(t.complete,i)}):o=t;return s.destination=new D(o),s}return r(t,e),t}(I);function _(e){var t;t=e,b.setTimeout((function(){throw t}))}var S={closed:!0,next:h,error:function(e){throw e},complete:h},x="function"==typeof Symbol&&Symbol.observable||"@@observable";function T(e){return e}var P=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,i=(n=e)&&n instanceof I||function(e){return e&&a(e.next)&&a(e.error)&&a(e.complete)}(n)&&f(n)?e:new g(e,t,r);return y((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=E(t))((function(t,n){var o=new g({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[x]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?T:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=E(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function E(e){var t;return null!==(t=null!=e?e:d.Promise)&&void 0!==t?t:Promise}var O=s((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),A=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r(t,e),t.prototype.lift=function(e){var t=new C(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new O},t.prototype.next=function(e){var t=this;y((function(){var r,o;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=n(t.currentObservers),a=i.next();!a.done;a=i.next()){a.value.next(e)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;y((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;y((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,i=r.observers;return n||o?l:(this.currentObservers=null,i.push(e),new p((function(){t.currentObservers=null,c(i,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new P;return e.source=this,e},t.create=function(e,t){return new C(e,t)},t}(P),C=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return r(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:l},t}(A),M=0;var L=function(){return"operation-".concat(++M)},z={},j=function(e){var t=e.operationID,r=e.operation,n=e.autoDelete,o=void 0===n||n;return z[t]={operation:r,autoDelete:o},r},k=function(e){delete z[e]},F=function(e){var t=e.data,r=t.operationID;if(r){var n=function(e){var t=z[e],r=t.operation;return t.autoDelete&&delete z[e],r||null}(r);n&&n.next(t.arg||(null==t?void 0:t.error))}},N=function(e){window.parent.postMessage(e,"*")},V=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("appID"))&&void 0!==e?e:null},H=Object.freeze({__proto__:null,persistData:function(e){var t=e.key,r=e.value,n=V();if(n){var o=L(),i={appID:n,operationID:o,operationType:"persistData",arg:{key:t,value:r}},a=new A,s=new Promise((function(e,t){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return j({operationID:o,operation:a}),N(i),s}},updateConfigurationValue:function(e){var t=e.name,r=e.value,n=V();if(n){var o=L(),i={appID:n,operationID:o,operationType:"updateConfigurationValue",arg:{name:t,value:r}},a=new A,s=new Promise((function(e){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return j({operationID:o,operation:a}),N(i),s}}}),U=Object.freeze({__proto__:null,addFieldListener:function(e){var t=e.fieldName,r=e.onChange,n=V();if(n){var o=L(),i="fieldName-".concat(n),a={appID:n,operationID:o,operationType:"addFieldListener",arg:{fieldName:t,operationID:i,operationType:"onFieldChanged"}},s=new A;j({operationID:o,operation:s});var u=new A;u.subscribe((function(e){var t=e.fieldValue;r(t)})),j({operationID:i,operation:u,autoDelete:!1}),N(a)}},addSelectedItemListener:function(e){var t=e.onChange,r=V();if(r){var n=L(),o="selectedItem-".concat(r),i={appID:r,operationID:n,operationType:"addSelectedItemListener",arg:{operationID:o,operationType:"onSelectedItemChange"}},a=new A;j({operationID:n,operation:a});var s=new A;s.subscribe((function(e){var r=e.selectedItems;t(r)})),j({operationID:o,operation:s,autoDelete:!1}),N(i)}},getContentItem:function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"getContentItem"},n=new A,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),N(r),o}},getSelectedItems:function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"getSelectedItems"},n=new A,o=new Promise((function(e){n.subscribe((function(t){var r=t.selectedItems;e(r),n.unsubscribe()}))}));return j({operationID:t,operation:n}),N(r),o}},removeFieldListener:function(e){var t=e.fieldName,r=V();if(r){var n=L(),o={appID:r,operationID:n,operationType:"removeFieldListener",arg:{fieldName:t,operationID:"fieldName-".concat(r)}},i=new A;i.subscribe((function(e){var t=e.removeOperationID;k(t),i.unsubscribe()})),j({operationID:n,operation:i}),N(o)}},removeSelectedItemListener:function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"removeSelectedItemListener",arg:{operationID:"selectedItem-".concat(e)}},n=new A;n.subscribe((function(e){var t=e.removeOperationID;k(t),n.unsubscribe()})),j({operationID:t,operation:n}),N(r)}},setFieldValue:function(e){var t=e.name,r=e.value,n=V();if(n){var o=L(),i={appID:n,operationID:o,operationType:"setFieldValue",arg:{name:t,value:r}},a=new A;j({operationID:o,operation:a}),N(i)}}}),K=Object.freeze({__proto__:null,selectAssets:function(e){var t=e.title,r=e.singleSelectOnly,n=e.callback,o=V();if(o){var i=L(),a=L(),s={appID:o,operationID:i,operationType:"selectAssets",arg:{closeModalID:a,title:t,singleSelectOnly:r}},u=new A;j({operationID:i,operation:u});var c=new A;c.subscribe((function(e){var t=e.assets;n(t),c.unsubscribe()})),j({operationID:a,operation:c}),N(s)}}}),R=Object.freeze({__proto__:null,getPageItem:function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"getPageItem"},n=new A,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),N(r),o}}}),Y="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;exports.assetsMethods=K,exports.closeModal=function(e){var t=e.props,r=V(),n=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("closeModalID"))&&void 0!==e?e:null}();if(r&&n){var o=L();N({appID:r,operationID:o,operationType:"closeModal",arg:{closeModalID:n,props:t}})}},exports.configMethods=H,exports.contentItemMethods=U,exports.getAPIKey=function(e){var t=e.apiType,r=V();if(r){var n=L(),o={appID:r,operationID:n,operationType:"getAPIKey",arg:{apiType:t}},i=new A,a=new Promise((function(e){i.subscribe((function(t){var r=t.apiKey;e(r),i.unsubscribe()}))}));return j({operationID:n,operation:i}),N(o),a}},exports.getAppInstall=function(){var e=V();if(!e)return null;var t=L(),r={appID:e,operationID:t,operationType:"getAppInstall"},n=new A,o=new Promise((function(e,t){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),N(r),o},exports.getManagementAPIToken=function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"getManagementAPIToken"},n=new A,o=new Promise((function(e){n.subscribe((function(t){var r=t.token;e(r),n.unsubscribe()}))}));return j({operationID:t,operation:n}),N(r),o}},exports.openModal=function(e){var t=e.name,r=e.title,n=e.props,o=e.callback,i=V();if(i){var a=L(),s=L(),u={appID:i,operationID:a,operationType:"openModal",arg:{closeModalID:s,title:r||null,name:t,props:n}},c=new A;j({operationID:a,operation:c});var p=new A;p.subscribe((function(e){o(e),p.unsubscribe()})),j({operationID:s,operation:p}),N(u)}},exports.pageMethods=R,exports.refresh=function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"refresh"},n=new A;j({operationID:t,operation:n}),N(r)}},exports.setExtraConfigValues=function(e){var t=V();if(t){var r=L(),n={appID:t,operationID:r,operationType:"setExtraConfigValues",arg:e},o=new A,i=new Promise((function(e,t){o.subscribe((function(t){e(t),o.unsubscribe()}))}));return j({operationID:r,operation:o}),N(n),i}},exports.setHeight=function(e){var t=e.height,r=V();if(r){var n=L(),o={appID:r,operationID:n,operationType:"setHeight",arg:{height:t}},i=new A;j({operationID:n,operation:i}),N(o)}},exports.setVisibility=function(e){var t=e.fieldID,r=e.visibility,n=V();if(n){var o=L(),i={appID:n,operationID:o,operationType:"setVisibility",arg:{fieldID:t,visibility:r}},a=new A;j({operationID:o,operation:a}),N(i)}},exports.useAgilityAppSDK=function(){var t=e.useState(!0),r=t[0],n=t[1],o=e.useState(null),i=o[0],a=o[1],s=e.useState(null),u=s[0],c=s[1],p=e.useState(null),l=p[0],f=p[1],v=e.useState(null),d=v[0],b=v[1],h=e.useState(null),y=h[0],I=h[1],m=e.useState(null),w=m[0],D=m[1],g=e.useState(null),_=g[0];g[1];var S=e.useState(null),x=S[0],T=S[1];return e.useEffect((function(){var e=V();if(e){var t=new A;t.subscribe((function(e){e&&(a(e.app),c(e.instance),f(e.locale),b(e.field||null),D(e.contentItem||null),I(e.contentModel||null),T(e.modalProps||null),n(!1),t.unsubscribe())}));var r=L();return j({operationID:r,operation:t}),window.addEventListener("message",F,!1),N({appID:e,operationID:r,operationType:"initialize"}),function(){removeEventListener("message",F,!1)}}}),[]),{initializing:r,appInstallContext:i,instance:u,locale:l,field:d,contentItem:w,contentModel:y,pageItem:_,modalProps:x}},exports.useAgilityPreInstall=function(){var t=e.useState(!0),r=t[0],n=t[1],o=e.useState(null),i=o[0],a=o[1],s=e.useState(null),u=s[0];s[1];var c=e.useState(null),p=c[0];return c[1],e.useEffect((function(){var e=V();if(e){var t=new A;t.subscribe((function(e){e&&(a(e.app),n(!1),t.unsubscribe())}));var r=L();return j({operationID:r,operation:t}),window.addEventListener("message",F,!1),N({appID:e,operationID:r,operationType:"preInstall"}),function(){removeEventListener("message",F,!1)}}}),[]),{initializing:r,appInstallContext:i,instance:u,locale:p}},exports.useElementHeight=function(){var t,r,n,o,i,a=e.useState(null),s=a[0],u=a[1],c=e.useState(0),p=c[0],l=c[1],f=e.useCallback((function(){l((null==s?void 0:s.offsetHeight)||0)}),[null==s?void 0:s.offsetHeight]);return t="resize",r=f,i=e.useRef(r),Y((function(){i.current=r}),[r]),e.useEffect((function(){var e,r=null!==(e=null==n?void 0:n.current)&&void 0!==e?e:window;if(r&&r.addEventListener){var a=function(e){return i.current(e)};return r.addEventListener(t,a,o),function(){r.removeEventListener(t,a,o)}}}),[t,n,o]),Y((function(){f()}),[null==s?void 0:s.offsetHeight]),[u,p]};
"use strict";var e=require("react"),t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};function r(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function n(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function i(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function a(e){return"function"==typeof e}function s(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var u=s((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function c(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var p=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,s,c;if(!this.closed){this.closed=!0;var p=this._parentage;if(p)if(this._parentage=null,Array.isArray(p))try{for(var l=n(p),f=l.next();!f.done;f=l.next()){f.value.remove(this)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}else p.remove(this);var d=this.initialTeardown;if(a(d))try{d()}catch(e){c=e instanceof u?e.errors:[e]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var h=n(b),y=h.next();!y.done;y=h.next()){var I=y.value;try{v(I)}catch(e){c=null!=c?c:[],e instanceof u?c=i(i([],o(c)),o(e.errors)):c.push(e)}}}catch(e){r={error:e}}finally{try{y&&!y.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(c)throw new u(c)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)v(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&c(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&c(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),l=p.EMPTY;function f(e){return e instanceof p||e&&"closed"in e&&a(e.remove)&&a(e.add)&&a(e.unsubscribe)}function v(e){a(e)?e():e.unsubscribe()}var d={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},b={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var a=b.delegate;return(null==a?void 0:a.setTimeout)?a.setTimeout.apply(a,i([e,t],o(r))):setTimeout.apply(void 0,i([e,t],o(r)))},clearTimeout:function(e){var t=b.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function h(){}function y(e){e()}var I=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,f(t)&&t.add(r)):r.destination=S,r}return r(t,e),t.create=function(e,t,r){return new g(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(p),m=Function.prototype.bind;function w(e,t){return m.call(e,t)}var D=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){_(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){_(e)}else _(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){_(e)}},e}(),g=function(e){function t(t,r,n){var o,i,s=e.call(this)||this;a(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:s&&d.useDeprecatedNextContext?((i=Object.create(t)).unsubscribe=function(){return s.unsubscribe()},o={next:t.next&&w(t.next,i),error:t.error&&w(t.error,i),complete:t.complete&&w(t.complete,i)}):o=t;return s.destination=new D(o),s}return r(t,e),t}(I);function _(e){var t;t=e,b.setTimeout((function(){throw t}))}var S={closed:!0,next:h,error:function(e){throw e},complete:h},x="function"==typeof Symbol&&Symbol.observable||"@@observable";function T(e){return e}var P=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,i=(n=e)&&n instanceof I||function(e){return e&&a(e.next)&&a(e.error)&&a(e.complete)}(n)&&f(n)?e:new g(e,t,r);return y((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=E(t))((function(t,n){var o=new g({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[x]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?T:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=E(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function E(e){var t;return null!==(t=null!=e?e:d.Promise)&&void 0!==t?t:Promise}var O=s((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),A=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r(t,e),t.prototype.lift=function(e){var t=new C(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new O},t.prototype.next=function(e){var t=this;y((function(){var r,o;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=n(t.currentObservers),a=i.next();!a.done;a=i.next()){a.value.next(e)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;y((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;y((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,i=r.observers;return n||o?l:(this.currentObservers=null,i.push(e),new p((function(){t.currentObservers=null,c(i,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new P;return e.source=this,e},t.create=function(e,t){return new C(e,t)},t}(P),C=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return r(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:l},t}(A),M=0;var L=function(){return"operation-".concat(++M)},z={},j=function(e){var t=e.operationID,r=e.operation,n=e.autoDelete,o=void 0===n||n;return z[t]={operation:r,autoDelete:o},r},k=function(e){delete z[e]},F=function(e){var t=e.data,r=t.operationID;if(r){var n=function(e){var t=z[e],r=t.operation;return t.autoDelete&&delete z[e],r||null}(r);n&&n.next(t.arg||(null==t?void 0:t.error))}},N=function(e){window.parent.postMessage(e,"*")},V=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("appID"))&&void 0!==e?e:null},H=Object.freeze({__proto__:null,persistData:function(e){var t=e.key,r=e.value,n=V();if(n){var o=L(),i={appID:n,operationID:o,operationType:"persistData",arg:{key:t,value:r}},a=new A,s=new Promise((function(e,t){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return j({operationID:o,operation:a}),N(i),s}},updateConfigurationValue:function(e){var t=e.name,r=e.value,n=V();if(n){var o=L(),i={appID:n,operationID:o,operationType:"updateConfigurationValue",arg:{name:t,value:r}},a=new A,s=new Promise((function(e){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return j({operationID:o,operation:a}),N(i),s}}}),U=Object.freeze({__proto__:null,addFieldListener:function(e){var t=e.fieldName,r=e.onChange,n=V();if(n){var o=L(),i="fieldName-".concat(n),a={appID:n,operationID:o,operationType:"addFieldListener",arg:{fieldName:t,operationID:i,operationType:"onFieldChanged"}},s=new A;j({operationID:o,operation:s});var u=new A;u.subscribe((function(e){var t=e.fieldValue;r(t)})),j({operationID:i,operation:u,autoDelete:!1}),N(a)}},addSelectedItemListener:function(e){var t=e.onChange,r=V();if(r){var n=L(),o="selectedItem-".concat(r),i={appID:r,operationID:n,operationType:"addSelectedItemListener",arg:{operationID:o,operationType:"onSelectedItemChange"}},a=new A;j({operationID:n,operation:a});var s=new A;s.subscribe((function(e){var r=e.selectedItems;t(r)})),j({operationID:o,operation:s,autoDelete:!1}),N(i)}},getContentItem:function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"getContentItem"},n=new A,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),N(r),o}},getSelectedItems:function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"getSelectedItems"},n=new A,o=new Promise((function(e){n.subscribe((function(t){var r=t.selectedItems;e(r),n.unsubscribe()}))}));return j({operationID:t,operation:n}),N(r),o}},removeFieldListener:function(e){var t=e.fieldName,r=V();if(r){var n=L(),o={appID:r,operationID:n,operationType:"removeFieldListener",arg:{fieldName:t,operationID:"fieldName-".concat(r)}},i=new A;i.subscribe((function(e){var t=e.removeOperationID;k(t),i.unsubscribe()})),j({operationID:n,operation:i}),N(o)}},removeSelectedItemListener:function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"removeSelectedItemListener",arg:{operationID:"selectedItem-".concat(e)}},n=new A;n.subscribe((function(e){var t=e.removeOperationID;k(t),n.unsubscribe()})),j({operationID:t,operation:n}),N(r)}},setFieldValue:function(e){var t=e.name,r=e.value,n=V();if(n){var o=L(),i={appID:n,operationID:o,operationType:"setFieldValue",arg:{name:t,value:r}},a=new A;j({operationID:o,operation:a}),N(i)}}}),K=Object.freeze({__proto__:null,selectAssets:function(e){var t=e.title,r=e.singleSelectOnly,n=e.callback,o=V();if(o){var i=L(),a=L(),s={appID:o,operationID:i,operationType:"selectAssets",arg:{closeModalID:a,title:t,singleSelectOnly:r}},u=new A;j({operationID:i,operation:u});var c=new A;c.subscribe((function(e){var t=e.assets;n(t),c.unsubscribe()})),j({operationID:a,operation:c}),N(s)}}}),R=Object.freeze({__proto__:null,getPageItem:function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"getPageItem"},n=new A,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),N(r),o}}}),Y="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;exports.assetsMethods=K,exports.closeModal=function(e){var t=V(),r=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("closeModalID"))&&void 0!==e?e:null}();if(t&&r){var n=L();N({appID:t,operationID:n,operationType:"closeModal",arg:{closeModalID:r,props:e}})}},exports.configMethods=H,exports.contentItemMethods=U,exports.getAPIKey=function(e){var t=e.apiType,r=V();if(r){var n=L(),o={appID:r,operationID:n,operationType:"getAPIKey",arg:{apiType:t}},i=new A,a=new Promise((function(e){i.subscribe((function(t){var r=t.apiKey;e(r),i.unsubscribe()}))}));return j({operationID:n,operation:i}),N(o),a}},exports.getAppInstall=function(){var e=V();if(!e)return null;var t=L(),r={appID:e,operationID:t,operationType:"getAppInstall"},n=new A,o=new Promise((function(e,t){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),N(r),o},exports.getManagementAPIToken=function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"getManagementAPIToken"},n=new A,o=new Promise((function(e){n.subscribe((function(t){var r=t.token;e(r),n.unsubscribe()}))}));return j({operationID:t,operation:n}),N(r),o}},exports.openModal=function(e){var t=e.name,r=e.title,n=e.props,o=e.callback,i=V();if(i){var a=L(),s=L(),u={appID:i,operationID:a,operationType:"openModal",arg:{closeModalID:s,title:r||null,name:t,props:n}},c=new A;j({operationID:a,operation:c});var p=new A;p.subscribe((function(e){o(e),p.unsubscribe()})),j({operationID:s,operation:p}),N(u)}},exports.pageMethods=R,exports.refresh=function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"refresh"},n=new A;j({operationID:t,operation:n}),N(r)}},exports.setExtraConfigValues=function(e){var t=V();if(t){var r=L(),n={appID:t,operationID:r,operationType:"setExtraConfigValues",arg:e},o=new A,i=new Promise((function(e,t){o.subscribe((function(t){e(t),o.unsubscribe()}))}));return j({operationID:r,operation:o}),N(n),i}},exports.setHeight=function(e){var t=e.height,r=V();if(r){var n=L(),o={appID:r,operationID:n,operationType:"setHeight",arg:{height:t}},i=new A;j({operationID:n,operation:i}),N(o)}},exports.setVisibility=function(e){var t=e.fieldID,r=e.visibility,n=V();if(n){var o=L(),i={appID:n,operationID:o,operationType:"setVisibility",arg:{fieldID:t,visibility:r}},a=new A;j({operationID:o,operation:a}),N(i)}},exports.useAgilityAppSDK=function(){var t=e.useState(!0),r=t[0],n=t[1],o=e.useState(null),i=o[0],a=o[1],s=e.useState(null),u=s[0],c=s[1],p=e.useState(null),l=p[0],f=p[1],v=e.useState(null),d=v[0],b=v[1],h=e.useState(null),y=h[0],I=h[1],m=e.useState(null),w=m[0],D=m[1],g=e.useState(null),_=g[0];g[1];var S=e.useState(null),x=S[0],T=S[1];return e.useEffect((function(){var e=V();if(e){var t=new A;t.subscribe((function(e){e&&(a(e.app),c(e.instance),f(e.locale),b(e.field||null),D(e.contentItem||null),I(e.contentModel||null),T(e.modalProps||null),n(!1),t.unsubscribe())}));var r=L();return j({operationID:r,operation:t}),window.addEventListener("message",F,!1),N({appID:e,operationID:r,operationType:"initialize"}),function(){removeEventListener("message",F,!1)}}}),[]),{initializing:r,appInstallContext:i,instance:u,locale:l,field:d,contentItem:w,contentModel:y,pageItem:_,modalProps:x}},exports.useAgilityPreInstall=function(){var t=e.useState(!0),r=t[0],n=t[1],o=e.useState(null),i=o[0],a=o[1],s=e.useState(null),u=s[0];s[1];var c=e.useState(null),p=c[0];return c[1],e.useEffect((function(){var e=V();if(e){var t=new A;t.subscribe((function(e){e&&(a(e.app),n(!1),t.unsubscribe())}));var r=L();return j({operationID:r,operation:t}),window.addEventListener("message",F,!1),N({appID:e,operationID:r,operationType:"preInstall"}),function(){removeEventListener("message",F,!1)}}}),[]),{initializing:r,appInstallContext:i,instance:u,locale:p}},exports.useElementHeight=function(){var t,r,n,o,i,a=e.useState(null),s=a[0],u=a[1],c=e.useState(0),p=c[0],l=c[1],f=e.useCallback((function(){l((null==s?void 0:s.offsetHeight)||0)}),[null==s?void 0:s.offsetHeight]);return t="resize",r=f,i=e.useRef(r),Y((function(){i.current=r}),[r]),e.useEffect((function(){var e,r=null!==(e=null==n?void 0:n.current)&&void 0!==e?e:window;if(r&&r.addEventListener){var a=function(e){return i.current(e)};return r.addEventListener(t,a,o),function(){r.removeEventListener(t,a,o)}}}),[t,n,o]),Y((function(){f()}),[null==s?void 0:s.offsetHeight]),[u,p]};
//# sourceMappingURL=index.js.map

@@ -1,11 +0,6 @@

interface ICloseModalParam<T> {
props: T;
}
/**
* Closes the current modal and passes the props to the callback. Only to be used on a modal surface.
*
* @template T
* @param {ICloseModalParam<T>} { props }
* @param {*} props
*/
export declare const closeModal: <T>({ props }: ICloseModalParam<T>) => void;
export {};
export declare const closeModal: (props: any) => void;

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

import{useState as e,useEffect as t,useLayoutEffect as r,useRef as n,useCallback as o}from"react";var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)};function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function c(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function p(e){return"function"==typeof e}function l(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var f=l((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function v(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var d=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=u(i),l=a.next();!l.done;l=a.next()){l.value.remove(this)}}catch(t){e={error:t}}finally{try{l&&!l.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else i.remove(this);var v=this.initialTeardown;if(p(v))try{v()}catch(e){o=e instanceof f?e.errors:[e]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var b=u(d),h=b.next();!h.done;h=b.next()){var I=h.value;try{y(I)}catch(e){o=null!=o?o:[],e instanceof f?o=c(c([],s(o)),s(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=b.return)&&n.call(b)}finally{if(r)throw r.error}}}if(o)throw new f(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)y(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&v(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&v(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),b=d.EMPTY;function h(e){return e instanceof d||e&&"closed"in e&&p(e.remove)&&p(e.add)&&p(e.unsubscribe)}function y(e){p(e)?e():e.unsubscribe()}var I={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},m={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=m.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,c([e,t],s(r))):setTimeout.apply(void 0,c([e,t],s(r)))},clearTimeout:function(e){var t=m.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function w(){}function D(e){e()}var g=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,h(t)&&t.add(r)):r.destination=O,r}return a(t,e),t.create=function(e,t,r){return new x(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(d),_=Function.prototype.bind;function S(e,t){return _.call(e,t)}var T=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){P(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){P(e)}else P(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){P(e)}},e}(),x=function(e){function t(t,r,n){var o,i,a=e.call(this)||this;p(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:a&&I.useDeprecatedNextContext?((i=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},o={next:t.next&&S(t.next,i),error:t.error&&S(t.error,i),complete:t.complete&&S(t.complete,i)}):o=t;return a.destination=new T(o),a}return a(t,e),t}(g);function P(e){var t;t=e,m.setTimeout((function(){throw t}))}var O={closed:!0,next:w,error:function(e){throw e},complete:w},E="function"==typeof Symbol&&Symbol.observable||"@@observable";function C(e){return e}var A=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,i=(n=e)&&n instanceof g||function(e){return e&&p(e.next)&&p(e.error)&&p(e.complete)}(n)&&h(n)?e:new x(e,t,r);return D((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=L(t))((function(t,n){var o=new x({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[E]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?C:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=L(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function L(e){var t;return null!==(t=null!=e?e:I.Promise)&&void 0!==t?t:Promise}var z=l((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),M=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return a(t,e),t.prototype.lift=function(e){var t=new j(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new z},t.prototype.next=function(e){var t=this;D((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=u(t.currentObservers),i=o.next();!i.done;i=o.next()){i.value.next(e)}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;D((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;D((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,i=r.observers;return n||o?b:(this.currentObservers=null,i.push(e),new d((function(){t.currentObservers=null,v(i,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new A;return e.source=this,e},t.create=function(e,t){return new j(e,t)},t}(A),j=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return a(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:b},t}(M),k=0;var F=function(){return"operation-".concat(++k)},N={},V=function(e){var t=e.operationID,r=e.operation,n=e.autoDelete,o=void 0===n||n;return N[t]={operation:r,autoDelete:o},r},H=function(e){delete N[e]},U=function(e){var t=e.data,r=t.operationID;if(r){var n=function(e){var t=N[e],r=t.operation;return t.autoDelete&&delete N[e],r||null}(r);n&&n.next(t.arg||(null==t?void 0:t.error))}},K=function(e){window.parent.postMessage(e,"*")},R=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("appID"))&&void 0!==e?e:null},Y=function(){var r=e(!0),n=r[0],o=r[1],i=e(null),a=i[0],u=i[1],s=e(null),c=s[0],p=s[1],l=e(null),f=l[0],v=l[1],d=e(null),b=d[0],h=d[1],y=e(null),I=y[0],m=y[1],w=e(null),D=w[0],g=w[1],_=e(null),S=_[0];_[1];var T=e(null),x=T[0],P=T[1];return t((function(){var e=R();if(e){var t=new M;t.subscribe((function(e){e&&(u(e.app),p(e.instance),v(e.locale),h(e.field||null),g(e.contentItem||null),m(e.contentModel||null),P(e.modalProps||null),o(!1),t.unsubscribe())}));var r=F();return V({operationID:r,operation:t}),window.addEventListener("message",U,!1),K({appID:e,operationID:r,operationType:"initialize"}),function(){removeEventListener("message",U,!1)}}}),[]),{initializing:n,appInstallContext:a,instance:c,locale:f,field:b,contentItem:D,contentModel:I,pageItem:S,modalProps:x}},q=function(){var r=e(!0),n=r[0],o=r[1],i=e(null),a=i[0],u=i[1],s=e(null),c=s[0];s[1];var p=e(null),l=p[0];return p[1],t((function(){var e=R();if(e){var t=new M;t.subscribe((function(e){e&&(u(e.app),o(!1),t.unsubscribe())}));var r=F();return V({operationID:r,operation:t}),window.addEventListener("message",U,!1),K({appID:e,operationID:r,operationType:"preInstall"}),function(){removeEventListener("message",U,!1)}}}),[]),{initializing:n,appInstallContext:a,instance:c,locale:l}},B=Object.freeze({__proto__:null,persistData:function(e){var t=e.key,r=e.value,n=R();if(n){var o=F(),i={appID:n,operationID:o,operationType:"persistData",arg:{key:t,value:r}},a=new M,u=new Promise((function(e,t){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return V({operationID:o,operation:a}),K(i),u}},updateConfigurationValue:function(e){var t=e.name,r=e.value,n=R();if(n){var o=F(),i={appID:n,operationID:o,operationType:"updateConfigurationValue",arg:{name:t,value:r}},a=new M,u=new Promise((function(e){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return V({operationID:o,operation:a}),K(i),u}}}),G=Object.freeze({__proto__:null,addFieldListener:function(e){var t=e.fieldName,r=e.onChange,n=R();if(n){var o=F(),i="fieldName-".concat(n),a={appID:n,operationID:o,operationType:"addFieldListener",arg:{fieldName:t,operationID:i,operationType:"onFieldChanged"}},u=new M;V({operationID:o,operation:u});var s=new M;s.subscribe((function(e){var t=e.fieldValue;r(t)})),V({operationID:i,operation:s,autoDelete:!1}),K(a)}},addSelectedItemListener:function(e){var t=e.onChange,r=R();if(r){var n=F(),o="selectedItem-".concat(r),i={appID:r,operationID:n,operationType:"addSelectedItemListener",arg:{operationID:o,operationType:"onSelectedItemChange"}},a=new M;V({operationID:n,operation:a});var u=new M;u.subscribe((function(e){var r=e.selectedItems;t(r)})),V({operationID:o,operation:u,autoDelete:!1}),K(i)}},getContentItem:function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"getContentItem"},n=new M,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return V({operationID:t,operation:n}),K(r),o}},getSelectedItems:function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"getSelectedItems"},n=new M,o=new Promise((function(e){n.subscribe((function(t){var r=t.selectedItems;e(r),n.unsubscribe()}))}));return V({operationID:t,operation:n}),K(r),o}},removeFieldListener:function(e){var t=e.fieldName,r=R();if(r){var n=F(),o={appID:r,operationID:n,operationType:"removeFieldListener",arg:{fieldName:t,operationID:"fieldName-".concat(r)}},i=new M;i.subscribe((function(e){var t=e.removeOperationID;H(t),i.unsubscribe()})),V({operationID:n,operation:i}),K(o)}},removeSelectedItemListener:function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"removeSelectedItemListener",arg:{operationID:"selectedItem-".concat(e)}},n=new M;n.subscribe((function(e){var t=e.removeOperationID;H(t),n.unsubscribe()})),V({operationID:t,operation:n}),K(r)}},setFieldValue:function(e){var t=e.name,r=e.value,n=R();if(n){var o=F(),i={appID:n,operationID:o,operationType:"setFieldValue",arg:{name:t,value:r}},a=new M;V({operationID:o,operation:a}),K(i)}}}),J=Object.freeze({__proto__:null,selectAssets:function(e){var t=e.title,r=e.singleSelectOnly,n=e.callback,o=R();if(o){var i=F(),a=F(),u={appID:o,operationID:i,operationType:"selectAssets",arg:{closeModalID:a,title:t,singleSelectOnly:r}},s=new M;V({operationID:i,operation:s});var c=new M;c.subscribe((function(e){var t=e.assets;n(t),c.unsubscribe()})),V({operationID:a,operation:c}),K(u)}}}),Q=Object.freeze({__proto__:null,getPageItem:function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"getPageItem"},n=new M,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return V({operationID:t,operation:n}),K(r),o}}}),W=function(e){var t=e.height,r=R();if(r){var n=F(),o={appID:r,operationID:n,operationType:"setHeight",arg:{height:t}},i=new M;V({operationID:n,operation:i}),K(o)}},X=function(e){var t=e.name,r=e.title,n=e.props,o=e.callback,i=R();if(i){var a=F(),u=F(),s={appID:i,operationID:a,operationType:"openModal",arg:{closeModalID:u,title:r||null,name:t,props:n}},c=new M;V({operationID:a,operation:c});var p=new M;p.subscribe((function(e){o(e),p.unsubscribe()})),V({operationID:u,operation:p}),K(s)}},Z=function(e){var t=e.props,r=R(),n=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("closeModalID"))&&void 0!==e?e:null}();if(r&&n){var o=F();K({appID:r,operationID:o,operationType:"closeModal",arg:{closeModalID:n,props:t}})}},$=function(){var e=R();if(!e)return null;var t=F(),r={appID:e,operationID:t,operationType:"getAppInstall"},n=new M,o=new Promise((function(e,t){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return V({operationID:t,operation:n}),K(r),o},ee=function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"refresh"},n=new M;V({operationID:t,operation:n}),K(r)}},te=function(e){var t=e.fieldID,r=e.visibility,n=R();if(n){var o=F(),i={appID:n,operationID:o,operationType:"setVisibility",arg:{fieldID:t,visibility:r}},a=new M;V({operationID:o,operation:a}),K(i)}},re=function(e){var t=R();if(t){var r=F(),n={appID:t,operationID:r,operationType:"setExtraConfigValues",arg:e},o=new M,i=new Promise((function(e,t){o.subscribe((function(t){e(t),o.unsubscribe()}))}));return V({operationID:r,operation:o}),K(n),i}},ne=function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"getManagementAPIToken"},n=new M,o=new Promise((function(e){n.subscribe((function(t){var r=t.token;e(r),n.unsubscribe()}))}));return V({operationID:t,operation:n}),K(r),o}},oe=function(e){var t=e.apiType,r=R();if(r){var n=F(),o={appID:r,operationID:n,operationType:"getAPIKey",arg:{apiType:t}},i=new M,a=new Promise((function(e){i.subscribe((function(t){var r=t.apiKey;e(r),i.unsubscribe()}))}));return V({operationID:n,operation:i}),K(o),a}},ie="undefined"!=typeof window?r:t;var ae=function(){var r,i,a,u,s,c=e(null),p=c[0],l=c[1],f=e(0),v=f[0],d=f[1],b=o((function(){d((null==p?void 0:p.offsetHeight)||0)}),[null==p?void 0:p.offsetHeight]);return r="resize",s=n(i=b),ie((function(){s.current=i}),[i]),t((function(){var e,t=null!==(e=null==a?void 0:a.current)&&void 0!==e?e:window;if(t&&t.addEventListener){var n=function(e){return s.current(e)};return t.addEventListener(r,n,u),function(){t.removeEventListener(r,n,u)}}}),[r,a,u]),ie((function(){b()}),[null==p?void 0:p.offsetHeight]),[l,v]};export{J as assetsMethods,Z as closeModal,B as configMethods,G as contentItemMethods,oe as getAPIKey,$ as getAppInstall,ne as getManagementAPIToken,X as openModal,Q as pageMethods,ee as refresh,re as setExtraConfigValues,W as setHeight,te as setVisibility,Y as useAgilityAppSDK,q as useAgilityPreInstall,ae as useElementHeight};
import{useState as e,useEffect as t,useLayoutEffect as r,useRef as n,useCallback as o}from"react";var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)};function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function c(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function p(e){return"function"==typeof e}function l(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var f=l((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function v(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var d=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=u(i),l=a.next();!l.done;l=a.next()){l.value.remove(this)}}catch(t){e={error:t}}finally{try{l&&!l.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else i.remove(this);var v=this.initialTeardown;if(p(v))try{v()}catch(e){o=e instanceof f?e.errors:[e]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var b=u(d),h=b.next();!h.done;h=b.next()){var I=h.value;try{y(I)}catch(e){o=null!=o?o:[],e instanceof f?o=c(c([],s(o)),s(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=b.return)&&n.call(b)}finally{if(r)throw r.error}}}if(o)throw new f(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)y(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&v(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&v(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),b=d.EMPTY;function h(e){return e instanceof d||e&&"closed"in e&&p(e.remove)&&p(e.add)&&p(e.unsubscribe)}function y(e){p(e)?e():e.unsubscribe()}var I={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},m={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=m.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,c([e,t],s(r))):setTimeout.apply(void 0,c([e,t],s(r)))},clearTimeout:function(e){var t=m.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function w(){}function D(e){e()}var g=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,h(t)&&t.add(r)):r.destination=O,r}return a(t,e),t.create=function(e,t,r){return new x(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(d),_=Function.prototype.bind;function S(e,t){return _.call(e,t)}var T=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){P(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){P(e)}else P(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){P(e)}},e}(),x=function(e){function t(t,r,n){var o,i,a=e.call(this)||this;p(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:a&&I.useDeprecatedNextContext?((i=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},o={next:t.next&&S(t.next,i),error:t.error&&S(t.error,i),complete:t.complete&&S(t.complete,i)}):o=t;return a.destination=new T(o),a}return a(t,e),t}(g);function P(e){var t;t=e,m.setTimeout((function(){throw t}))}var O={closed:!0,next:w,error:function(e){throw e},complete:w},E="function"==typeof Symbol&&Symbol.observable||"@@observable";function C(e){return e}var A=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,i=(n=e)&&n instanceof g||function(e){return e&&p(e.next)&&p(e.error)&&p(e.complete)}(n)&&h(n)?e:new x(e,t,r);return D((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=L(t))((function(t,n){var o=new x({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[E]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?C:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=L(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function L(e){var t;return null!==(t=null!=e?e:I.Promise)&&void 0!==t?t:Promise}var z=l((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),M=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return a(t,e),t.prototype.lift=function(e){var t=new j(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new z},t.prototype.next=function(e){var t=this;D((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=u(t.currentObservers),i=o.next();!i.done;i=o.next()){i.value.next(e)}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;D((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;D((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,i=r.observers;return n||o?b:(this.currentObservers=null,i.push(e),new d((function(){t.currentObservers=null,v(i,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new A;return e.source=this,e},t.create=function(e,t){return new j(e,t)},t}(A),j=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return a(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:b},t}(M),k=0;var F=function(){return"operation-".concat(++k)},N={},V=function(e){var t=e.operationID,r=e.operation,n=e.autoDelete,o=void 0===n||n;return N[t]={operation:r,autoDelete:o},r},H=function(e){delete N[e]},U=function(e){var t=e.data,r=t.operationID;if(r){var n=function(e){var t=N[e],r=t.operation;return t.autoDelete&&delete N[e],r||null}(r);n&&n.next(t.arg||(null==t?void 0:t.error))}},K=function(e){window.parent.postMessage(e,"*")},R=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("appID"))&&void 0!==e?e:null},Y=function(){var r=e(!0),n=r[0],o=r[1],i=e(null),a=i[0],u=i[1],s=e(null),c=s[0],p=s[1],l=e(null),f=l[0],v=l[1],d=e(null),b=d[0],h=d[1],y=e(null),I=y[0],m=y[1],w=e(null),D=w[0],g=w[1],_=e(null),S=_[0];_[1];var T=e(null),x=T[0],P=T[1];return t((function(){var e=R();if(e){var t=new M;t.subscribe((function(e){e&&(u(e.app),p(e.instance),v(e.locale),h(e.field||null),g(e.contentItem||null),m(e.contentModel||null),P(e.modalProps||null),o(!1),t.unsubscribe())}));var r=F();return V({operationID:r,operation:t}),window.addEventListener("message",U,!1),K({appID:e,operationID:r,operationType:"initialize"}),function(){removeEventListener("message",U,!1)}}}),[]),{initializing:n,appInstallContext:a,instance:c,locale:f,field:b,contentItem:D,contentModel:I,pageItem:S,modalProps:x}},q=function(){var r=e(!0),n=r[0],o=r[1],i=e(null),a=i[0],u=i[1],s=e(null),c=s[0];s[1];var p=e(null),l=p[0];return p[1],t((function(){var e=R();if(e){var t=new M;t.subscribe((function(e){e&&(u(e.app),o(!1),t.unsubscribe())}));var r=F();return V({operationID:r,operation:t}),window.addEventListener("message",U,!1),K({appID:e,operationID:r,operationType:"preInstall"}),function(){removeEventListener("message",U,!1)}}}),[]),{initializing:n,appInstallContext:a,instance:c,locale:l}},B=Object.freeze({__proto__:null,persistData:function(e){var t=e.key,r=e.value,n=R();if(n){var o=F(),i={appID:n,operationID:o,operationType:"persistData",arg:{key:t,value:r}},a=new M,u=new Promise((function(e,t){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return V({operationID:o,operation:a}),K(i),u}},updateConfigurationValue:function(e){var t=e.name,r=e.value,n=R();if(n){var o=F(),i={appID:n,operationID:o,operationType:"updateConfigurationValue",arg:{name:t,value:r}},a=new M,u=new Promise((function(e){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return V({operationID:o,operation:a}),K(i),u}}}),G=Object.freeze({__proto__:null,addFieldListener:function(e){var t=e.fieldName,r=e.onChange,n=R();if(n){var o=F(),i="fieldName-".concat(n),a={appID:n,operationID:o,operationType:"addFieldListener",arg:{fieldName:t,operationID:i,operationType:"onFieldChanged"}},u=new M;V({operationID:o,operation:u});var s=new M;s.subscribe((function(e){var t=e.fieldValue;r(t)})),V({operationID:i,operation:s,autoDelete:!1}),K(a)}},addSelectedItemListener:function(e){var t=e.onChange,r=R();if(r){var n=F(),o="selectedItem-".concat(r),i={appID:r,operationID:n,operationType:"addSelectedItemListener",arg:{operationID:o,operationType:"onSelectedItemChange"}},a=new M;V({operationID:n,operation:a});var u=new M;u.subscribe((function(e){var r=e.selectedItems;t(r)})),V({operationID:o,operation:u,autoDelete:!1}),K(i)}},getContentItem:function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"getContentItem"},n=new M,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return V({operationID:t,operation:n}),K(r),o}},getSelectedItems:function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"getSelectedItems"},n=new M,o=new Promise((function(e){n.subscribe((function(t){var r=t.selectedItems;e(r),n.unsubscribe()}))}));return V({operationID:t,operation:n}),K(r),o}},removeFieldListener:function(e){var t=e.fieldName,r=R();if(r){var n=F(),o={appID:r,operationID:n,operationType:"removeFieldListener",arg:{fieldName:t,operationID:"fieldName-".concat(r)}},i=new M;i.subscribe((function(e){var t=e.removeOperationID;H(t),i.unsubscribe()})),V({operationID:n,operation:i}),K(o)}},removeSelectedItemListener:function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"removeSelectedItemListener",arg:{operationID:"selectedItem-".concat(e)}},n=new M;n.subscribe((function(e){var t=e.removeOperationID;H(t),n.unsubscribe()})),V({operationID:t,operation:n}),K(r)}},setFieldValue:function(e){var t=e.name,r=e.value,n=R();if(n){var o=F(),i={appID:n,operationID:o,operationType:"setFieldValue",arg:{name:t,value:r}},a=new M;V({operationID:o,operation:a}),K(i)}}}),J=Object.freeze({__proto__:null,selectAssets:function(e){var t=e.title,r=e.singleSelectOnly,n=e.callback,o=R();if(o){var i=F(),a=F(),u={appID:o,operationID:i,operationType:"selectAssets",arg:{closeModalID:a,title:t,singleSelectOnly:r}},s=new M;V({operationID:i,operation:s});var c=new M;c.subscribe((function(e){var t=e.assets;n(t),c.unsubscribe()})),V({operationID:a,operation:c}),K(u)}}}),Q=Object.freeze({__proto__:null,getPageItem:function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"getPageItem"},n=new M,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return V({operationID:t,operation:n}),K(r),o}}}),W=function(e){var t=e.height,r=R();if(r){var n=F(),o={appID:r,operationID:n,operationType:"setHeight",arg:{height:t}},i=new M;V({operationID:n,operation:i}),K(o)}},X=function(e){var t=e.name,r=e.title,n=e.props,o=e.callback,i=R();if(i){var a=F(),u=F(),s={appID:i,operationID:a,operationType:"openModal",arg:{closeModalID:u,title:r||null,name:t,props:n}},c=new M;V({operationID:a,operation:c});var p=new M;p.subscribe((function(e){o(e),p.unsubscribe()})),V({operationID:u,operation:p}),K(s)}},Z=function(e){var t=R(),r=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("closeModalID"))&&void 0!==e?e:null}();if(t&&r){var n=F();K({appID:t,operationID:n,operationType:"closeModal",arg:{closeModalID:r,props:e}})}},$=function(){var e=R();if(!e)return null;var t=F(),r={appID:e,operationID:t,operationType:"getAppInstall"},n=new M,o=new Promise((function(e,t){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return V({operationID:t,operation:n}),K(r),o},ee=function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"refresh"},n=new M;V({operationID:t,operation:n}),K(r)}},te=function(e){var t=e.fieldID,r=e.visibility,n=R();if(n){var o=F(),i={appID:n,operationID:o,operationType:"setVisibility",arg:{fieldID:t,visibility:r}},a=new M;V({operationID:o,operation:a}),K(i)}},re=function(e){var t=R();if(t){var r=F(),n={appID:t,operationID:r,operationType:"setExtraConfigValues",arg:e},o=new M,i=new Promise((function(e,t){o.subscribe((function(t){e(t),o.unsubscribe()}))}));return V({operationID:r,operation:o}),K(n),i}},ne=function(){var e=R();if(e){var t=F(),r={appID:e,operationID:t,operationType:"getManagementAPIToken"},n=new M,o=new Promise((function(e){n.subscribe((function(t){var r=t.token;e(r),n.unsubscribe()}))}));return V({operationID:t,operation:n}),K(r),o}},oe=function(e){var t=e.apiType,r=R();if(r){var n=F(),o={appID:r,operationID:n,operationType:"getAPIKey",arg:{apiType:t}},i=new M,a=new Promise((function(e){i.subscribe((function(t){var r=t.apiKey;e(r),i.unsubscribe()}))}));return V({operationID:n,operation:i}),K(o),a}},ie="undefined"!=typeof window?r:t;var ae=function(){var r,i,a,u,s,c=e(null),p=c[0],l=c[1],f=e(0),v=f[0],d=f[1],b=o((function(){d((null==p?void 0:p.offsetHeight)||0)}),[null==p?void 0:p.offsetHeight]);return r="resize",s=n(i=b),ie((function(){s.current=i}),[i]),t((function(){var e,t=null!==(e=null==a?void 0:a.current)&&void 0!==e?e:window;if(t&&t.addEventListener){var n=function(e){return s.current(e)};return t.addEventListener(r,n,u),function(){t.removeEventListener(r,n,u)}}}),[r,a,u]),ie((function(){b()}),[null==p?void 0:p.offsetHeight]),[l,v]};export{J as assetsMethods,Z as closeModal,B as configMethods,G as contentItemMethods,oe as getAPIKey,$ as getAppInstall,ne as getManagementAPIToken,X as openModal,Q as pageMethods,ee as refresh,re as setExtraConfigValues,W as setHeight,te as setVisibility,Y as useAgilityAppSDK,q as useAgilityPreInstall,ae as useElementHeight};
//# sourceMappingURL=index.js.map

@@ -1,11 +0,6 @@

interface ICloseModalParam<T> {
props: T;
}
/**
* Closes the current modal and passes the props to the callback. Only to be used on a modal surface.
*
* @template T
* @param {ICloseModalParam<T>} { props }
* @param {*} props
*/
export declare const closeModal: <T>({ props }: ICloseModalParam<T>) => void;
export {};
export declare const closeModal: (props: any) => void;

@@ -494,12 +494,8 @@ interface IAppConfigValue {

interface ICloseModalParam<T> {
props: T;
}
/**
* Closes the current modal and passes the props to the callback. Only to be used on a modal surface.
*
* @template T
* @param {ICloseModalParam<T>} { props }
* @param {*} props
*/
declare const closeModal: <T>({ props }: ICloseModalParam<T>) => void;
declare const closeModal: (props: any) => void;

@@ -506,0 +502,0 @@ /**

{
"name": "@agility/app-sdk",
"version": "2.0.0-rc16",
"version": "2.0.0-rc17",
"description": "JavaScript library for building Agility CMS apps.",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc