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 to 2.0.1-rc1

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 w(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 D(e,t){return m.call(e,t)}var g=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}(),w=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&&D(t.next,i),error:t.error&&D(t.error,i),complete:t.complete&&D(t.complete,i)}):o=t;return s.destination=new g(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 w(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 w({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)},k={},z=function(e){var t=e.operationID,r=e.operation,n=e.autoDelete,o=void 0===n||n;return k[t]={operation:r,autoDelete:o},r},j=function(e){delete k[e]},N=function(e){var t=e.data,r=t.operationID;if(r){var n=function(e){var t=k[e],r=t.operation;return t.autoDelete&&delete k[e],r||null}(r);n&&n.next(t.arg||(null==t?void 0:t.error))}},F=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 z({operationID:o,operation:a}),F(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 z({operationID:o,operation:a}),F(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;z({operationID:o,operation:s});var u=new A;u.subscribe((function(e){var t=e.fieldValue;r(t)})),z({operationID:i,operation:u,autoDelete:!1}),F(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;z({operationID:n,operation:a});var s=new A;s.subscribe((function(e){var r=e.selectedItems;t(r)})),z({operationID:o,operation:s,autoDelete:!1}),F(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 z({operationID:t,operation:n}),F(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 z({operationID:t,operation:n}),F(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;j(t),i.unsubscribe()})),z({operationID:n,operation:i}),F(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;j(t),n.unsubscribe()})),z({operationID:t,operation:n}),F(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;z({operationID:o,operation:a}),F(i)}}}),B=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;z({operationID:i,operation:u});var c=new A;c.subscribe((function(e){var t=e.assets;n(t),c.unsubscribe()})),z({operationID:a,operation:c}),F(s)}}}),K=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 z({operationID:t,operation:n}),F(r),o}}}),R="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;exports.assetsMethods=B,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();F({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 z({operationID:n,operation:i}),F(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 z({operationID:t,operation:n}),F(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 z({operationID:t,operation:n}),F(r),o}},exports.openAlertModal=function(e){var t=e.title,r=e.message,n=e.okButtonText,o=e.cancelButtonText,i=e.iconName,a=void 0===i?"":i,s=e.iconColor,u=void 0===s?"":s,c=e.callback,p=V();if(p){var l=L(),f=L(),v={appID:p,operationID:l,operationType:"openAlertModal",arg:{closeModalID:f,title:t,message:r,okButtonText:n,cancelButtonText:o,iconName:a,iconColor:u}},d=new A;z({operationID:l,operation:d});var b=new A;b.subscribe((function(e){c(null==e?void 0:e.ok),b.unsubscribe()})),z({operationID:f,operation:b}),F(v)}},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;z({operationID:a,operation:c});var p=new A;p.subscribe((function(e){o(null==e?void 0:e.props),p.unsubscribe()})),z({operationID:s,operation:p}),F(u)}},exports.pageMethods=K,exports.refresh=function(){var e=V();if(e){var t=L(),r={appID:e,operationID:t,operationType:"refresh"},n=new A;z({operationID:t,operation:n}),F(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 z({operationID:r,operation:o}),F(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;z({operationID:n,operation:i}),F(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;z({operationID:o,operation:a}),F(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),D=m[0],g=m[1],w=e.useState(null),_=w[0];w[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),g(e.contentItem||null),I(e.contentModel||null),T(e.modalProps||null),n(!1),t.unsubscribe())}));var r=L();return z({operationID:r,operation:t}),window.addEventListener("message",N,!1),F({appID:e,operationID:r,operationType:"initialize"}),function(){removeEventListener("message",N,!1)}}}),[]),{initializing:r,appInstallContext:i,instance:u,locale:l,field:d,contentItem:D,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 z({operationID:r,operation:t}),window.addEventListener("message",N,!1),F({appID:e,operationID:r,operationType:"preInstall"}),function(){removeEventListener("message",N,!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),R((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]),R((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 w(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 D(e,t){return m.call(e,t)}var g=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}(),w=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&&D(t.next,i),error:t.error&&D(t.error,i),complete:t.complete&&D(t.complete,i)}):o=t;return s.destination=new g(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 w(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 w({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)},k={},z=function(e){var t=e.operationID,r=e.operation,n=e.autoDelete,o=void 0===n||n;return k[t]={operation:r,autoDelete:o},r},j=function(e){delete k[e]},N=function(e){var t=e.data,r=t.operationID;if(r){var n=function(e){var t=k[e],r=t.operation;return t.autoDelete&&delete k[e],r||null}(r);n&&n.next(t.arg||(null==t?void 0:t.error))}},F=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=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;z({operationID:o,operation:s});var u=new A;u.subscribe((function(e){var t=e.fieldValue;r(t)})),z({operationID:i,operation:u,autoDelete:!1}),F(a)}},U=Object.freeze({__proto__:null,addFieldListener:H,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;z({operationID:n,operation:a});var s=new A;s.subscribe((function(e){var r=e.selectedItems;t(r)})),z({operationID:o,operation:s,autoDelete:!1}),F(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 z({operationID:t,operation:n}),F(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 z({operationID:t,operation:n}),F(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;j(t),i.unsubscribe()})),z({operationID:n,operation:i}),F(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;j(t),n.unsubscribe()})),z({operationID:t,operation:n}),F(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;z({operationID:o,operation:a}),F(i)}}}),B=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 z({operationID:o,operation:a}),F(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 z({operationID:o,operation:a}),F(i),s}}}),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;z({operationID:i,operation:u});var c=new A;c.subscribe((function(e){var t=e.assets;n(t),c.unsubscribe()})),z({operationID:a,operation:c}),F(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 z({operationID:t,operation:n}),F(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();F({appID:t,operationID:n,operationType:"closeModal",arg:{closeModalID:r,props:e}})}},exports.configMethods=B,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 z({operationID:n,operation:i}),F(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 z({operationID:t,operation:n}),F(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 z({operationID:t,operation:n}),F(r),o}},exports.openAlertModal=function(e){var t=e.title,r=e.message,n=e.okButtonText,o=e.cancelButtonText,i=e.iconName,a=void 0===i?"":i,s=e.iconColor,u=void 0===s?"":s,c=e.callback,p=V();if(p){var l=L(),f=L(),v={appID:p,operationID:l,operationType:"openAlertModal",arg:{closeModalID:f,title:t,message:r,okButtonText:n,cancelButtonText:o,iconName:a,iconColor:u}},d=new A;z({operationID:l,operation:d});var b=new A;b.subscribe((function(e){c(null==e?void 0:e.ok),b.unsubscribe()})),z({operationID:f,operation:b}),F(v)}},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;z({operationID:a,operation:c});var p=new A;p.subscribe((function(e){o(null==e?void 0:e.props),p.unsubscribe()})),z({operationID:s,operation:p}),F(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;z({operationID:t,operation:n}),F(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 z({operationID:r,operation:o}),F(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;z({operationID:n,operation:i}),F(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;z({operationID:o,operation:a}),F(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),D=m[0],g=m[1],w=e.useState(null),_=w[0];w[1];var S=e.useState(""),x=S[0],T=S[1],P=e.useState(null),E=P[0],O=P[1];return e.useEffect((function(){var e=V();if(e){var t=new A;t.subscribe((function(e){var r,o;e&&(a(e.app),c(e.instance),f(e.locale),b(e.field||null),g(e.contentItem||null),I(e.contentModel||null),O(e.modalProps||null),e.field&&(T((null===(r=e.contentItem)||void 0===r?void 0:r.values[e.field.name])||""),H({fieldName:null===(o=e.field)||void 0===o?void 0:o.name,onChange:function(e){T(e||"")}})),n(!1),t.unsubscribe())}));var r=L();return z({operationID:r,operation:t}),window.addEventListener("message",N,!1),F({appID:e,operationID:r,operationType:"initialize"}),function(){removeEventListener("message",N,!1)}}}),[]),{initializing:r,appInstallContext:i,instance:u,locale:l,field:d,contentItem:D,contentModel:y,pageItem:_,modalProps:E,fieldValue: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 z({operationID:r,operation:t}),window.addEventListener("message",N,!1),F({appID:e,operationID:r,operationType:"preInstall"}),function(){removeEventListener("message",N,!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
import { IAppInstallContext, IInstance, IField, IContentItem, IContentModel, IPageItem } from './types';
export interface AgilityAddSKReturn {
/**
* Indicates if the SDK is still initializing.
*
* @type {boolean}
* @memberof AgilityAddSKReturn
*/
initializing: boolean;
/**
* The app install context.
*
* @type {(IAppInstallContext | null)}
* @memberof AgilityAddSKReturn
*/
appInstallContext: IAppInstallContext | null;
/**
* The current instance.
*
* @type {(IInstance | null)}
* @memberof AgilityAddSKReturn
*/
instance: IInstance | null;
/**
* The current locale.
*
* @type {(string | null)}
* @memberof AgilityAddSKReturn
*/
locale: string | null;
/**
* The current field. Only available when on a custom field.
*
* @type {(IField | null)}
* @memberof AgilityAddSKReturn
*/
field: IField | null;
/**
* The current content item. Only available when on a custom field or content item sidebar.
*
* @type {(IContentItem | null)}
* @memberof AgilityAddSKReturn
*/
contentItem: IContentItem | null;
/**
* The current content model. Only available when on a custom field, content item or list sidebar.
*
* @type {(IContentModel | null)}
* @memberof AgilityAddSKReturn
*/
contentModel: IContentModel | null;
/**
* The current page. Only available when on a page sidebar.
*
* @type {(IPageItem | null)}
* @memberof AgilityAddSKReturn
*/
pageItem: IPageItem | null;
/**
* The current modal props. Only available when on a modal surface.
*
* @type {*}
* @memberof AgilityAddSKReturn
*/
modalProps: any;
/**
* The current field value. Only available when on a custom field.
* If the field value changes outside of the SDK, this value will be updated.
*
* @type {string}
* @memberof AgilityAddSKReturn
*/
fieldValue: string;
}

@@ -13,0 +75,0 @@ /**

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

import{useState as e,useEffect as t,useLayoutEffect as n,useRef as r,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 n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},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 n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function c(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||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 n=e.indexOf(t);0<=n&&e.splice(n,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,n,r,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){n={error:e}}finally{try{h&&!h.done&&(r=b.return)&&r.call(b)}finally{if(n)throw n.error}}}if(o)throw new f(o)}},e.prototype.add=function(t){var n;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!==(n=this._finalizers)&&void 0!==n?n:[]).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 n=this._finalizers;n&&v(n,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 n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=m.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,c([e,t],s(n))):setTimeout.apply(void 0,c([e,t],s(n)))},clearTimeout:function(e){var t=m.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function D(){}function w(e){e()}var g=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,h(t)&&t.add(n)):n.destination=O,n}return a(t,e),t.create=function(e,t,n){return new x(e,t,n)},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,n,r){var o,i,a=e.call(this)||this;p(t)||!t?o={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r: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:D,error:function(e){throw e},complete:D},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 n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r,o=this,i=(r=e)&&r instanceof g||function(e){return e&&p(e.next)&&p(e.error)&&p(e.complete)}(r)&&h(r)?e:new x(e,t,n);return w((function(){var e=o,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?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 n=this;return new(t=M(t))((function(t,r){var o=new x({next:function(t){try{e(t)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t});n.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=[],n=0;n<arguments.length;n++)t[n]=arguments[n];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=M(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function M(e){var t;return null!==(t=null!=e?e:I.Promise)&&void 0!==t?t:Promise}var L=l((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),z=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 L},t.prototype.next=function(e){var t=this;w((function(){var n,r;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){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;w((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}}))},t.prototype.complete=function(){var e=this;w((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,n=this,r=n.hasError,o=n.isStopped,i=n.observers;return r||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,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):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,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return a(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.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,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:b},t}(z),k=0;var N=function(){return"operation-".concat(++k)},F={},V=function(e){var t=e.operationID,n=e.operation,r=e.autoDelete,o=void 0===r||r;return F[t]={operation:n,autoDelete:o},n},H=function(e){delete F[e]},U=function(e){var t=e.data,n=t.operationID;if(n){var r=function(e){var t=F[e],n=t.operation;return t.autoDelete&&delete F[e],n||null}(n);r&&r.next(t.arg||(null==t?void 0:t.error))}},B=function(e){window.parent.postMessage(e,"*")},K=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},R=function(){var n=e(!0),r=n[0],o=n[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],D=e(null),w=D[0],g=D[1],_=e(null),S=_[0];_[1];var T=e(null),x=T[0],P=T[1];return t((function(){var e=K();if(e){var t=new z;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 n=N();return V({operationID:n,operation:t}),window.addEventListener("message",U,!1),B({appID:e,operationID:n,operationType:"initialize"}),function(){removeEventListener("message",U,!1)}}}),[]),{initializing:r,appInstallContext:a,instance:c,locale:f,field:b,contentItem:w,contentModel:I,pageItem:S,modalProps:x}},Y=function(){var n=e(!0),r=n[0],o=n[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=K();if(e){var t=new z;t.subscribe((function(e){e&&(u(e.app),o(!1),t.unsubscribe())}));var n=N();return V({operationID:n,operation:t}),window.addEventListener("message",U,!1),B({appID:e,operationID:n,operationType:"preInstall"}),function(){removeEventListener("message",U,!1)}}}),[]),{initializing:r,appInstallContext:a,instance:c,locale:l}},q=Object.freeze({__proto__:null,persistData:function(e){var t=e.key,n=e.value,r=K();if(r){var o=N(),i={appID:r,operationID:o,operationType:"persistData",arg:{key:t,value:n}},a=new z,u=new Promise((function(e,t){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return V({operationID:o,operation:a}),B(i),u}},updateConfigurationValue:function(e){var t=e.name,n=e.value,r=K();if(r){var o=N(),i={appID:r,operationID:o,operationType:"updateConfigurationValue",arg:{name:t,value:n}},a=new z,u=new Promise((function(e){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return V({operationID:o,operation:a}),B(i),u}}}),G=Object.freeze({__proto__:null,addFieldListener:function(e){var t=e.fieldName,n=e.onChange,r=K();if(r){var o=N(),i="fieldName-".concat(r),a={appID:r,operationID:o,operationType:"addFieldListener",arg:{fieldName:t,operationID:i,operationType:"onFieldChanged"}},u=new z;V({operationID:o,operation:u});var s=new z;s.subscribe((function(e){var t=e.fieldValue;n(t)})),V({operationID:i,operation:s,autoDelete:!1}),B(a)}},addSelectedItemListener:function(e){var t=e.onChange,n=K();if(n){var r=N(),o="selectedItem-".concat(n),i={appID:n,operationID:r,operationType:"addSelectedItemListener",arg:{operationID:o,operationType:"onSelectedItemChange"}},a=new z;V({operationID:r,operation:a});var u=new z;u.subscribe((function(e){var n=e.selectedItems;t(n)})),V({operationID:o,operation:u,autoDelete:!1}),B(i)}},getContentItem:function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"getContentItem"},r=new z,o=new Promise((function(e){r.subscribe((function(t){e(t),r.unsubscribe()}))}));return V({operationID:t,operation:r}),B(n),o}},getSelectedItems:function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"getSelectedItems"},r=new z,o=new Promise((function(e){r.subscribe((function(t){var n=t.selectedItems;e(n),r.unsubscribe()}))}));return V({operationID:t,operation:r}),B(n),o}},removeFieldListener:function(e){var t=e.fieldName,n=K();if(n){var r=N(),o={appID:n,operationID:r,operationType:"removeFieldListener",arg:{fieldName:t,operationID:"fieldName-".concat(n)}},i=new z;i.subscribe((function(e){var t=e.removeOperationID;H(t),i.unsubscribe()})),V({operationID:r,operation:i}),B(o)}},removeSelectedItemListener:function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"removeSelectedItemListener",arg:{operationID:"selectedItem-".concat(e)}},r=new z;r.subscribe((function(e){var t=e.removeOperationID;H(t),r.unsubscribe()})),V({operationID:t,operation:r}),B(n)}},setFieldValue:function(e){var t=e.name,n=e.value,r=K();if(r){var o=N(),i={appID:r,operationID:o,operationType:"setFieldValue",arg:{name:t,value:n}},a=new z;V({operationID:o,operation:a}),B(i)}}}),J=Object.freeze({__proto__:null,selectAssets:function(e){var t=e.title,n=e.singleSelectOnly,r=e.callback,o=K();if(o){var i=N(),a=N(),u={appID:o,operationID:i,operationType:"selectAssets",arg:{closeModalID:a,title:t,singleSelectOnly:n}},s=new z;V({operationID:i,operation:s});var c=new z;c.subscribe((function(e){var t=e.assets;r(t),c.unsubscribe()})),V({operationID:a,operation:c}),B(u)}}}),Q=Object.freeze({__proto__:null,getPageItem:function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"getPageItem"},r=new z,o=new Promise((function(e){r.subscribe((function(t){e(t),r.unsubscribe()}))}));return V({operationID:t,operation:r}),B(n),o}}}),W=function(e){var t=e.height,n=K();if(n){var r=N(),o={appID:n,operationID:r,operationType:"setHeight",arg:{height:t}},i=new z;V({operationID:r,operation:i}),B(o)}},X=function(e){var t=e.title,n=e.message,r=e.okButtonText,o=e.cancelButtonText,i=e.iconName,a=void 0===i?"":i,u=e.iconColor,s=void 0===u?"":u,c=e.callback,p=K();if(p){var l=N(),f=N(),v={appID:p,operationID:l,operationType:"openAlertModal",arg:{closeModalID:f,title:t,message:n,okButtonText:r,cancelButtonText:o,iconName:a,iconColor:s}},d=new z;V({operationID:l,operation:d});var b=new z;b.subscribe((function(e){c(null==e?void 0:e.ok),b.unsubscribe()})),V({operationID:f,operation:b}),B(v)}},Z=function(e){var t=e.name,n=e.title,r=e.props,o=e.callback,i=K();if(i){var a=N(),u=N(),s={appID:i,operationID:a,operationType:"openModal",arg:{closeModalID:u,title:n||null,name:t,props:r}},c=new z;V({operationID:a,operation:c});var p=new z;p.subscribe((function(e){o(null==e?void 0:e.props),p.unsubscribe()})),V({operationID:u,operation:p}),B(s)}},$=function(e){var t=K(),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(t&&n){var r=N();B({appID:t,operationID:r,operationType:"closeModal",arg:{closeModalID:n,props:e}})}},ee=function(){var e=K();if(!e)return null;var t=N(),n={appID:e,operationID:t,operationType:"getAppInstall"},r=new z,o=new Promise((function(e,t){r.subscribe((function(t){e(t),r.unsubscribe()}))}));return V({operationID:t,operation:r}),B(n),o},te=function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"refresh"},r=new z;V({operationID:t,operation:r}),B(n)}},ne=function(e){var t=e.fieldID,n=e.visibility,r=K();if(r){var o=N(),i={appID:r,operationID:o,operationType:"setVisibility",arg:{fieldID:t,visibility:n}},a=new z;V({operationID:o,operation:a}),B(i)}},re=function(e){var t=K();if(t){var n=N(),r={appID:t,operationID:n,operationType:"setExtraConfigValues",arg:e},o=new z,i=new Promise((function(e,t){o.subscribe((function(t){e(t),o.unsubscribe()}))}));return V({operationID:n,operation:o}),B(r),i}},oe=function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"getManagementAPIToken"},r=new z,o=new Promise((function(e){r.subscribe((function(t){var n=t.token;e(n),r.unsubscribe()}))}));return V({operationID:t,operation:r}),B(n),o}},ie=function(e){var t=e.apiType,n=K();if(n){var r=N(),o={appID:n,operationID:r,operationType:"getAPIKey",arg:{apiType:t}},i=new z,a=new Promise((function(e){i.subscribe((function(t){var n=t.apiKey;e(n),i.unsubscribe()}))}));return V({operationID:r,operation:i}),B(o),a}},ae="undefined"!=typeof window?n:t;var ue=function(){var n,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 n="resize",s=r(i=b),ae((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 r=function(e){return s.current(e)};return t.addEventListener(n,r,u),function(){t.removeEventListener(n,r,u)}}}),[n,a,u]),ae((function(){b()}),[null==p?void 0:p.offsetHeight]),[l,v]};export{J as assetsMethods,$ as closeModal,q as configMethods,G as contentItemMethods,ie as getAPIKey,ee as getAppInstall,oe as getManagementAPIToken,X as openAlertModal,Z as openModal,Q as pageMethods,te as refresh,re as setExtraConfigValues,W as setHeight,ne as setVisibility,R as useAgilityAppSDK,Y as useAgilityPreInstall,ue as useElementHeight};
import{useState as e,useEffect as t,useLayoutEffect as n,useRef as r,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 n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},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 n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function c(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||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 n=e.indexOf(t);0<=n&&e.splice(n,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,n,r,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){n={error:e}}finally{try{h&&!h.done&&(r=b.return)&&r.call(b)}finally{if(n)throw n.error}}}if(o)throw new f(o)}},e.prototype.add=function(t){var n;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!==(n=this._finalizers)&&void 0!==n?n:[]).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 n=this._finalizers;n&&v(n,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 n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=m.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,c([e,t],s(n))):setTimeout.apply(void 0,c([e,t],s(n)))},clearTimeout:function(e){var t=m.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function D(){}function w(e){e()}var g=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,h(t)&&t.add(n)):n.destination=O,n}return a(t,e),t.create=function(e,t,n){return new x(e,t,n)},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,n,r){var o,i,a=e.call(this)||this;p(t)||!t?o={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r: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:D,error:function(e){throw e},complete:D},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 n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r,o=this,i=(r=e)&&r instanceof g||function(e){return e&&p(e.next)&&p(e.error)&&p(e.complete)}(r)&&h(r)?e:new x(e,t,n);return w((function(){var e=o,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?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 n=this;return new(t=M(t))((function(t,r){var o=new x({next:function(t){try{e(t)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t});n.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=[],n=0;n<arguments.length;n++)t[n]=arguments[n];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=M(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function M(e){var t;return null!==(t=null!=e?e:I.Promise)&&void 0!==t?t:Promise}var L=l((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),z=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 L},t.prototype.next=function(e){var t=this;w((function(){var n,r;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){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;w((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}}))},t.prototype.complete=function(){var e=this;w((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,n=this,r=n.hasError,o=n.isStopped,i=n.observers;return r||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,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):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,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return a(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.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,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:b},t}(z),k=0;var N=function(){return"operation-".concat(++k)},F={},V=function(e){var t=e.operationID,n=e.operation,r=e.autoDelete,o=void 0===r||r;return F[t]={operation:n,autoDelete:o},n},H=function(e){delete F[e]},U=function(e){var t=e.data,n=t.operationID;if(n){var r=function(e){var t=F[e],n=t.operation;return t.autoDelete&&delete F[e],n||null}(n);r&&r.next(t.arg||(null==t?void 0:t.error))}},B=function(e){window.parent.postMessage(e,"*")},K=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},R=function(e){var t=e.fieldName,n=e.onChange,r=K();if(r){var o=N(),i="fieldName-".concat(r),a={appID:r,operationID:o,operationType:"addFieldListener",arg:{fieldName:t,operationID:i,operationType:"onFieldChanged"}},u=new z;V({operationID:o,operation:u});var s=new z;s.subscribe((function(e){var t=e.fieldValue;n(t)})),V({operationID:i,operation:s,autoDelete:!1}),B(a)}},Y=Object.freeze({__proto__:null,addFieldListener:R,addSelectedItemListener:function(e){var t=e.onChange,n=K();if(n){var r=N(),o="selectedItem-".concat(n),i={appID:n,operationID:r,operationType:"addSelectedItemListener",arg:{operationID:o,operationType:"onSelectedItemChange"}},a=new z;V({operationID:r,operation:a});var u=new z;u.subscribe((function(e){var n=e.selectedItems;t(n)})),V({operationID:o,operation:u,autoDelete:!1}),B(i)}},getContentItem:function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"getContentItem"},r=new z,o=new Promise((function(e){r.subscribe((function(t){e(t),r.unsubscribe()}))}));return V({operationID:t,operation:r}),B(n),o}},getSelectedItems:function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"getSelectedItems"},r=new z,o=new Promise((function(e){r.subscribe((function(t){var n=t.selectedItems;e(n),r.unsubscribe()}))}));return V({operationID:t,operation:r}),B(n),o}},removeFieldListener:function(e){var t=e.fieldName,n=K();if(n){var r=N(),o={appID:n,operationID:r,operationType:"removeFieldListener",arg:{fieldName:t,operationID:"fieldName-".concat(n)}},i=new z;i.subscribe((function(e){var t=e.removeOperationID;H(t),i.unsubscribe()})),V({operationID:r,operation:i}),B(o)}},removeSelectedItemListener:function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"removeSelectedItemListener",arg:{operationID:"selectedItem-".concat(e)}},r=new z;r.subscribe((function(e){var t=e.removeOperationID;H(t),r.unsubscribe()})),V({operationID:t,operation:r}),B(n)}},setFieldValue:function(e){var t=e.name,n=e.value,r=K();if(r){var o=N(),i={appID:r,operationID:o,operationType:"setFieldValue",arg:{name:t,value:n}},a=new z;V({operationID:o,operation:a}),B(i)}}}),q=function(){var n=e(!0),r=n[0],o=n[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],D=e(null),w=D[0],g=D[1],_=e(null),S=_[0];_[1];var T=e(""),x=T[0],P=T[1],O=e(null),E=O[0],C=O[1];return t((function(){var e=K();if(e){var t=new z;t.subscribe((function(e){var n,r;e&&(u(e.app),p(e.instance),v(e.locale),h(e.field||null),g(e.contentItem||null),m(e.contentModel||null),C(e.modalProps||null),e.field&&(P((null===(n=e.contentItem)||void 0===n?void 0:n.values[e.field.name])||""),R({fieldName:null===(r=e.field)||void 0===r?void 0:r.name,onChange:function(e){P(e||"")}})),o(!1),t.unsubscribe())}));var n=N();return V({operationID:n,operation:t}),window.addEventListener("message",U,!1),B({appID:e,operationID:n,operationType:"initialize"}),function(){removeEventListener("message",U,!1)}}}),[]),{initializing:r,appInstallContext:a,instance:c,locale:f,field:b,contentItem:w,contentModel:I,pageItem:S,modalProps:E,fieldValue:x}},G=function(){var n=e(!0),r=n[0],o=n[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=K();if(e){var t=new z;t.subscribe((function(e){e&&(u(e.app),o(!1),t.unsubscribe())}));var n=N();return V({operationID:n,operation:t}),window.addEventListener("message",U,!1),B({appID:e,operationID:n,operationType:"preInstall"}),function(){removeEventListener("message",U,!1)}}}),[]),{initializing:r,appInstallContext:a,instance:c,locale:l}},J=Object.freeze({__proto__:null,persistData:function(e){var t=e.key,n=e.value,r=K();if(r){var o=N(),i={appID:r,operationID:o,operationType:"persistData",arg:{key:t,value:n}},a=new z,u=new Promise((function(e,t){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return V({operationID:o,operation:a}),B(i),u}},updateConfigurationValue:function(e){var t=e.name,n=e.value,r=K();if(r){var o=N(),i={appID:r,operationID:o,operationType:"updateConfigurationValue",arg:{name:t,value:n}},a=new z,u=new Promise((function(e){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return V({operationID:o,operation:a}),B(i),u}}}),Q=Object.freeze({__proto__:null,selectAssets:function(e){var t=e.title,n=e.singleSelectOnly,r=e.callback,o=K();if(o){var i=N(),a=N(),u={appID:o,operationID:i,operationType:"selectAssets",arg:{closeModalID:a,title:t,singleSelectOnly:n}},s=new z;V({operationID:i,operation:s});var c=new z;c.subscribe((function(e){var t=e.assets;r(t),c.unsubscribe()})),V({operationID:a,operation:c}),B(u)}}}),W=Object.freeze({__proto__:null,getPageItem:function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"getPageItem"},r=new z,o=new Promise((function(e){r.subscribe((function(t){e(t),r.unsubscribe()}))}));return V({operationID:t,operation:r}),B(n),o}}}),X=function(e){var t=e.height,n=K();if(n){var r=N(),o={appID:n,operationID:r,operationType:"setHeight",arg:{height:t}},i=new z;V({operationID:r,operation:i}),B(o)}},Z=function(e){var t=e.title,n=e.message,r=e.okButtonText,o=e.cancelButtonText,i=e.iconName,a=void 0===i?"":i,u=e.iconColor,s=void 0===u?"":u,c=e.callback,p=K();if(p){var l=N(),f=N(),v={appID:p,operationID:l,operationType:"openAlertModal",arg:{closeModalID:f,title:t,message:n,okButtonText:r,cancelButtonText:o,iconName:a,iconColor:s}},d=new z;V({operationID:l,operation:d});var b=new z;b.subscribe((function(e){c(null==e?void 0:e.ok),b.unsubscribe()})),V({operationID:f,operation:b}),B(v)}},$=function(e){var t=e.name,n=e.title,r=e.props,o=e.callback,i=K();if(i){var a=N(),u=N(),s={appID:i,operationID:a,operationType:"openModal",arg:{closeModalID:u,title:n||null,name:t,props:r}},c=new z;V({operationID:a,operation:c});var p=new z;p.subscribe((function(e){o(null==e?void 0:e.props),p.unsubscribe()})),V({operationID:u,operation:p}),B(s)}},ee=function(e){var t=K(),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(t&&n){var r=N();B({appID:t,operationID:r,operationType:"closeModal",arg:{closeModalID:n,props:e}})}},te=function(){var e=K();if(!e)return null;var t=N(),n={appID:e,operationID:t,operationType:"getAppInstall"},r=new z,o=new Promise((function(e,t){r.subscribe((function(t){e(t),r.unsubscribe()}))}));return V({operationID:t,operation:r}),B(n),o},ne=function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"refresh"},r=new z;V({operationID:t,operation:r}),B(n)}},re=function(e){var t=e.fieldID,n=e.visibility,r=K();if(r){var o=N(),i={appID:r,operationID:o,operationType:"setVisibility",arg:{fieldID:t,visibility:n}},a=new z;V({operationID:o,operation:a}),B(i)}},oe=function(e){var t=K();if(t){var n=N(),r={appID:t,operationID:n,operationType:"setExtraConfigValues",arg:e},o=new z,i=new Promise((function(e,t){o.subscribe((function(t){e(t),o.unsubscribe()}))}));return V({operationID:n,operation:o}),B(r),i}},ie=function(){var e=K();if(e){var t=N(),n={appID:e,operationID:t,operationType:"getManagementAPIToken"},r=new z,o=new Promise((function(e){r.subscribe((function(t){var n=t.token;e(n),r.unsubscribe()}))}));return V({operationID:t,operation:r}),B(n),o}},ae=function(e){var t=e.apiType,n=K();if(n){var r=N(),o={appID:n,operationID:r,operationType:"getAPIKey",arg:{apiType:t}},i=new z,a=new Promise((function(e){i.subscribe((function(t){var n=t.apiKey;e(n),i.unsubscribe()}))}));return V({operationID:r,operation:i}),B(o),a}},ue="undefined"!=typeof window?n:t;var se=function(){var n,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 n="resize",s=r(i=b),ue((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 r=function(e){return s.current(e)};return t.addEventListener(n,r,u),function(){t.removeEventListener(n,r,u)}}}),[n,a,u]),ue((function(){b()}),[null==p?void 0:p.offsetHeight]),[l,v]};export{Q as assetsMethods,ee as closeModal,J as configMethods,Y as contentItemMethods,ae as getAPIKey,te as getAppInstall,ie as getManagementAPIToken,Z as openAlertModal,$ as openModal,W as pageMethods,ne as refresh,oe as setExtraConfigValues,X as setHeight,re as setVisibility,q as useAgilityAppSDK,G as useAgilityPreInstall,se as useElementHeight};
//# sourceMappingURL=index.js.map
import { IAppInstallContext, IInstance, IField, IContentItem, IContentModel, IPageItem } from './types';
export interface AgilityAddSKReturn {
/**
* Indicates if the SDK is still initializing.
*
* @type {boolean}
* @memberof AgilityAddSKReturn
*/
initializing: boolean;
/**
* The app install context.
*
* @type {(IAppInstallContext | null)}
* @memberof AgilityAddSKReturn
*/
appInstallContext: IAppInstallContext | null;
/**
* The current instance.
*
* @type {(IInstance | null)}
* @memberof AgilityAddSKReturn
*/
instance: IInstance | null;
/**
* The current locale.
*
* @type {(string | null)}
* @memberof AgilityAddSKReturn
*/
locale: string | null;
/**
* The current field. Only available when on a custom field.
*
* @type {(IField | null)}
* @memberof AgilityAddSKReturn
*/
field: IField | null;
/**
* The current content item. Only available when on a custom field or content item sidebar.
*
* @type {(IContentItem | null)}
* @memberof AgilityAddSKReturn
*/
contentItem: IContentItem | null;
/**
* The current content model. Only available when on a custom field, content item or list sidebar.
*
* @type {(IContentModel | null)}
* @memberof AgilityAddSKReturn
*/
contentModel: IContentModel | null;
/**
* The current page. Only available when on a page sidebar.
*
* @type {(IPageItem | null)}
* @memberof AgilityAddSKReturn
*/
pageItem: IPageItem | null;
/**
* The current modal props. Only available when on a modal surface.
*
* @type {*}
* @memberof AgilityAddSKReturn
*/
modalProps: any;
/**
* The current field value. Only available when on a custom field.
* If the field value changes outside of the SDK, this value will be updated.
*
* @type {string}
* @memberof AgilityAddSKReturn
*/
fieldValue: string;
}

@@ -13,0 +75,0 @@ /**

@@ -312,11 +312,73 @@ interface IAppConfigValue {

interface AgilityAddSKReturn {
/**
* Indicates if the SDK is still initializing.
*
* @type {boolean}
* @memberof AgilityAddSKReturn
*/
initializing: boolean;
/**
* The app install context.
*
* @type {(IAppInstallContext | null)}
* @memberof AgilityAddSKReturn
*/
appInstallContext: IAppInstallContext | null;
/**
* The current instance.
*
* @type {(IInstance | null)}
* @memberof AgilityAddSKReturn
*/
instance: IInstance | null;
/**
* The current locale.
*
* @type {(string | null)}
* @memberof AgilityAddSKReturn
*/
locale: string | null;
/**
* The current field. Only available when on a custom field.
*
* @type {(IField | null)}
* @memberof AgilityAddSKReturn
*/
field: IField | null;
/**
* The current content item. Only available when on a custom field or content item sidebar.
*
* @type {(IContentItem | null)}
* @memberof AgilityAddSKReturn
*/
contentItem: IContentItem | null;
/**
* The current content model. Only available when on a custom field, content item or list sidebar.
*
* @type {(IContentModel | null)}
* @memberof AgilityAddSKReturn
*/
contentModel: IContentModel | null;
/**
* The current page. Only available when on a page sidebar.
*
* @type {(IPageItem | null)}
* @memberof AgilityAddSKReturn
*/
pageItem: IPageItem | null;
/**
* The current modal props. Only available when on a modal surface.
*
* @type {*}
* @memberof AgilityAddSKReturn
*/
modalProps: any;
/**
* The current field value. Only available when on a custom field.
* If the field value changes outside of the SDK, this value will be updated.
*
* @type {string}
* @memberof AgilityAddSKReturn
*/
fieldValue: string;
}

@@ -323,0 +385,0 @@ /**

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

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

# Agility CMS App SDK
This is a React SDK for building UI Apps for Agility CMS.
## Getting Started
Coming soon...
## Example Apps
One of the best ways to learn a new SDK is to see some examples!
### Google Analytics
A dashboard app that uses oauth to connect to Google and pull GA data.
https://github.com/agility/agility-cms-app-google-analytics
### Google Translate
A sidebar app that translates and detects language for the current content item.
https://github.com/agility/agility-cms-app-google-translate
### Big Commerce
A custom field app that allows selection of a product from BigCommerce. Includes a modal with a product listing and search component.
https://github.com/agility/agility-cms-app-bigcommerce
### Local Development

@@ -5,0 +30,0 @@

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