datocms-plugin-asset-optimization 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -59,4 +59,4 @@ Caused By:
|
|
|
59
59
|
|
|
60
60
|
`.concat(JSON.stringify(i.errors,null,2))),i.message=o,i.preCallStack&&(i.stack+=`
|
|
61
61
|
Caused By:
|
|
62
|
-
`.concat(i.preCallStack)),i}return Object.defineProperty(t.prototype,"errors",{get:function(){return LS(this.response.body)?this.response.body.data:[]},enumerable:!1,configurable:!0}),t.prototype.findError=function(n,r){var i=Array.isArray(n)?n:[n];return this.errors.find(function(o){return i.includes(o.attributes.code)&&(!r||(typeof r=="function"?r(o.attributes.details):Object.entries(r).every(function(a){var u=a[0],l=a[1];return o.attributes.details[u]===l})))})},t}(Error),RS=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ya=function(e){RS(t,e);function t(){var n=this.constructor,r=e.call(this,"Promise canceled!")||this;return Object.setPrototypeOf(r,n.prototype),r}return t}(Error);function Ka(e,t){var n=null,r=new Promise(function(i,o){n=function(){try{t&&t(),o(new Ya)}catch(u){o(u)}};var a=typeof e=="function"?e():e;a.then(i,o)});return n&&(r.cancel=n),r}function bo(e){return new Promise(function(t){setTimeout(t,e)})}var NS=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},FS=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};function MS(e){return NS(this,void 0,void 0,function(){var t,n,r;return FS(this,function(i){switch(i.label){case 0:n=0,i.label=1;case 1:return i.trys.push([1,4,,5]),n+=1,[4,bo(n*1e3)];case 2:return i.sent(),[4,e()];case 3:return t=i.sent(),[3,5];case 4:if(r=i.sent(),!(r instanceof oi)||r.response.status!==404)throw r;return[3,5];case 5:if(!t)return[3,1];i.label=6;case 6:return[2,t]}})})}var xm={},sc={},uc={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TaskCollisionStrategy=void 0,function(t){t[t.DEFAULT=0]="DEFAULT",t[t.KEEP_THIS=1]="KEEP_THIS",t[t.KEEP_OTHER=2]="KEEP_OTHER",t[t.KEEP_BOTH=3]="KEEP_BOTH",t[t.RESOLVE_THIS=4]="RESOLVE_THIS",t[t.RESOLVE_OTHER=5]="RESOLVE_OTHER"}(e.TaskCollisionStrategy||(e.TaskCollisionStrategy={}))})(uc);var Qa={};Object.defineProperty(Qa,"__esModule",{value:!0});class DS{constructor(t,n){this._code=t,this._message=n}get code(){return this._code}get message(){return this._message}}Qa.default=DS;var Vn={};Object.defineProperty(Vn,"__esModule",{value:!0});Vn.mutexEquality=Vn.mutexBitwiseAnd=void 0;function AS(e,t){return(e&t)!==0}Vn.mutexBitwiseAnd=AS;function zS(e,t){return e===t}Vn.mutexEquality=zS;var lc={};Object.defineProperty(lc,"__esModule",{value:!0});class $S{constructor(t,n){this._meta=void 0,this._task=t,this._scheduler=n}withDescriptor(t){return this._descriptor=t,this}withMutex(t){return this._mutex=t,this}withMeta(t){return this._meta=t,this}runBeforeExecuting(t){return this._onPreExecute=t,this}handleCollisions(t){return this._onTaskCollision=t,this}execute(t){return this._scheduler.enqueue({priority:t,mutex:this._mutex,descriptor:this._descriptor,meta:this._meta,execute:this._task,onPreExecute:this._onPreExecute,onTaskCollision:this._onTaskCollision})}}lc.default=$S;var VS=Ot&&Ot.__awaiter||function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},bm=Ot&&Ot.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(sc,"__esModule",{value:!0});const wt=uc,US=bm(Qa),qS=Vn,BS=bm(lc);var rt;(function(e){e[e.PENDING=0]="PENDING",e[e.EXECUTING=1]="EXECUTING",e[e.TERMINATED=2]="TERMINATED"})(rt||(rt={}));function nd(e,t){for(let n of e.listeners)n.reject(t)}class HS{constructor(t,n={}){this._queue=[],this._isExecuting=!1,this._idleListeners=[],this._maxConcurrentTasks=t,this._samePriorityMutex=!!n.samePriorityMutex,this._mutexStrategy=n.mutexStrategy||qS.mutexEquality,n.disableLogging?this._errorLog=()=>{}:this._errorLog=console.error}enqueue(t){return new Promise((n,r)=>{typeof t=="function"&&(t={priority:0,execute:t});const i=this._checkMutexes(t,n,r);i.task?this._addTask(i.task):i.canceled&&r(this.createCanceledError())})}prepare(t){return new BS.default(t,this)}_addTask(t){this._queue.push(t),this._applyPriorities(),this._isExecuting||(this._isExecuting=!0,setTimeout(this._executeNextTasks.bind(this)))}get executingTasks(){return this._queue.reduce((t,n)=>n.state===rt.EXECUTING?t+1:t,0)}createCanceledError(){return new US.default(50,"Task has been canceled in favor of another task")}_findFirstPendingTask(){return this._queue.find(t=>t.state===rt.PENDING)}_isIdle(){return this._queue.length===0||!this._queue.find(t=>t.state!==rt.TERMINATED)}_removeTaskAt(t){this._queue.splice(t,1)}_executeTask(t){return VS(this,void 0,void 0,function*(){try{return t.task.onPreExecute&&t.task.onPreExecute(),yield t.task.execute()}catch(n){throw n}finally{t.state=rt.TERMINATED;let n=this._queue.indexOf(t);this._removeTaskAt(n),this._executeNextTasks()}})}_executeNextTasks(){let t=this.executingTasks;if(t>=this._maxConcurrentTasks)return;let n=this._maxConcurrentTasks-t;for(let r=0;r<n;r++){const i=this._findFirstPendingTask();if(!i){this._isIdle()&&this._switchToIdle();return}i.state=rt.EXECUTING,this._executeTask(i).then(o=>{for(const{resolve:a}of i.listeners)try{a(o)}catch(u){this._errorLog("An error occurred while resolving listener",u)}}).catch(o=>{for(const{reject:a}of i.listeners)try{a(o)}catch(u){this._errorLog("An error occurred while rejecting listener",u)}})}}_switchToIdle(){this._isExecuting=!1;const t=this._idleListeners;this._idleListeners=[];for(const{resolve:n}of t)try{n()}catch{}}waitForIdle(){return this._isExecuting?new Promise((t,n)=>{this._idleListeners.push({resolve:t,reject:n})}):Promise.resolve()}_applyPriorities(){this._queue.sort((t,n)=>n.task.priority-t.task.priority)}_checkMutexes(t,n,r){for(let i=0;i<this._queue.length;i++){let o=this._queue[i];if(o.state===rt.TERMINATED||this._samePriorityMutex&&o.task.priority!=t.priority||!o.task.mutex||!t.mutex||!this._mutexStrategy(o.task.mutex,t.mutex))continue;let a,u;if(o.task.onTaskCollision)if(a=o.task.onTaskCollision(t),a===wt.TaskCollisionStrategy.KEEP_OTHER&&o.state!==rt.EXECUTING){this._removeTaskAt(i--),nd(o,this.createCanceledError());continue}else{if(a===wt.TaskCollisionStrategy.KEEP_THIS)return{canceled:!0};if(a===wt.TaskCollisionStrategy.RESOLVE_OTHER)return this._removeTaskAt(i--),{canceled:!1,task:{task:t,state:rt.PENDING,listeners:[{resolve:n,reject:r},...o.listeners]}};if(a===wt.TaskCollisionStrategy.RESOLVE_THIS)return o.listeners=[...o.listeners,{resolve:n,reject:r}],{canceled:!1}}if(t.onTaskCollision){if(u=t.onTaskCollision(o.task),u===wt.TaskCollisionStrategy.KEEP_OTHER)return{canceled:!0};if(u===wt.TaskCollisionStrategy.KEEP_THIS){this._removeTaskAt(i--),nd(o,this.createCanceledError());continue}else{if(u===wt.TaskCollisionStrategy.RESOLVE_OTHER)return o.listeners=[...o.listeners,{resolve:n,reject:r}],{canceled:!1};if(u===wt.TaskCollisionStrategy.RESOLVE_THIS)return this._removeTaskAt(i--),{canceled:!1,task:{task:t,state:rt.PENDING,listeners:[{resolve:n,reject:r},...o.listeners]}}}}if(!(a===wt.TaskCollisionStrategy.KEEP_BOTH&&u===wt.TaskCollisionStrategy.KEEP_BOTH))return{canceled:!0}}return{canceled:!1,task:{task:t,state:rt.PENDING,listeners:[{resolve:n,reject:r}]}}}}sc.default=HS;(function(e){var t=Ot&&Ot.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(e,"__esModule",{value:!0}),e.mutexEquality=e.mutexBitwiseAnd=e.SchedulerError=e.TaskCollisionStrategy=e.Scheduler=void 0;const n=t(sc);e.Scheduler=n.default;const r=uc;Object.defineProperty(e,"TaskCollisionStrategy",{enumerable:!0,get:function(){return r.TaskCollisionStrategy}});const i=t(Qa);e.SchedulerError=i.default;const o=Vn;Object.defineProperty(e,"mutexBitwiseAnd",{enumerable:!0,get:function(){return o.mutexBitwiseAnd}}),Object.defineProperty(e,"mutexEquality",{enumerable:!0,get:function(){return o.mutexEquality}})})(xm);var GS=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},Tn=function(e){return this instanceof Tn?(this.v=e,this):new Tn(e)},WS=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof Tn?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}};function Bn(e,t,n){return WS(this,arguments,function(){var i,o,a,u,l,m,s,c,d,f,h,p,v,E,m;return GS(this,function(y){switch(y.label){case 0:if(i=(n==null?void 0:n.perPage)||e.defaultLimit,i>e.maxLimit)throw new Error("perPage option cannot exceed maximum value of ".concat(e.maxLimit));if(o=(n==null?void 0:n.concurrency)||1,o>10)throw new Error("concurrency option cannot exceed maximum value of 10");return[4,Tn(t({limit:i,offset:0}))];case 1:a=y.sent(),u=0,l=a.data,y.label=2;case 2:return u<l.length?(m=l[u],[4,Tn(m)]):[3,6];case 3:return[4,y.sent()];case 4:y.sent(),y.label=5;case 5:return u++,[3,2];case 6:for(s=a.meta.total_count,c=new xm.Scheduler(o),d=[],f=function(g){d.push(c.enqueue(function(){return t({limit:i,offset:g})}))},h=i;h<s;h+=i)f(h);y.label=7;case 7:return d.length>0?[4,Tn(d.shift())]:[3,14];case 8:p=y.sent(),v=0,E=p.data,y.label=9;case 9:return v<E.length?(m=E[v],[4,Tn(m)]):[3,13];case 10:return[4,y.sent()];case 11:y.sent(),y.label=12;case 12:return v++,[3,9];case 13:return[3,7];case 14:return[2]}})})}function Hn(e){e&&"page"in e&&console.warn("Passing a `page` query param on paged iterators has no effect: use the `perPage` option instead.")}var io=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))},Om="__ARRAY_INDEX__";function YS(e){return e.reduce(function(t,n,r){return r===0?n:n===Om?"".concat(t,"[]"):"".concat(t,"[").concat(n,"]")},"")}function KS(e){if(typeof e=="number"||typeof e=="string")return e.toString();if(e===!0)return"true";if(e===!1)return"false";throw"Don't know how to serialize param value ".concat(JSON.stringify(e))}function Qu(e,t){t===void 0&&(t=[]);var n=[];if(typeof e=="number"||typeof e=="string"||typeof e=="boolean")n.push([YS(t),KS(e)]);else if(typeof e=="object"){if(Array.isArray(e))for(var r=0,i=e;r<i.length;r++)for(var o=i[r],a=0,u=Qu(o,io(io([],t,!0),[Om],!1));a<u.length;a++){var l=u[a];n.push(l)}else if(e)for(var s=0,c=Object.entries(e);s<c.length;s++)for(var d=c[s],f=d[0],o=d[1],h=0,p=Qu(o,io(io([],t,!0),[f],!1));h<p.length;h++){var l=p[h];n.push(l)}}return n}var Ft=function(){return Ft=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},Ft.apply(this,arguments)},QS=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},XS=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},JS=typeof window<"u"&&typeof window.document<"u",ZS=5,it;(function(e){e[e.NONE=0]="NONE",e[e.BASIC=1]="BASIC",e[e.BODY=2]="BODY",e[e.BODY_AND_HEADERS=3]="BODY_AND_HEADERS"})(it||(it={}));function eE(e){var t={};return e.forEach(function(n,r){t[r]=n}),t}function rd(e,t,n,r,i,o,a){return{request:{url:t,method:e,headers:n,body:r},response:{status:i.status,statusText:i.statusText,headers:eE(i.headers),body:o},preCallStack:a}}function tE(e,t,n,r,i){return{request:{url:t,method:e,headers:n,body:r},preCallStack:i}}function nE(e,t,n,r,i,o,a){return{request:{url:t,method:e,headers:n,body:r},response:{status:i,statusText:"N/A",headers:{},body:o},preCallStack:a}}function rE(e){return typeof e=="object"&&!!e&&"code"in e}function iE(e){return Object.fromEntries(Object.entries(e).map(function(t){var n=t[0],r=t[1];return[n.toLowerCase(),r]}))}var id=1;function Oo(e){var t;return QS(this,void 0,void 0,function(){var n,r,i,o,a,u,l,s,c,d,f,h,p,v,E,m,j,V,y,g,w,O,b,x,P,R,j,V,q,U,ee,X,K,re;return XS(this,function(I){switch(I.label){case 0:if(n=id,id+=1,r=e.fetchFn||(typeof fetch>"u"?void 0:fetch)||(typeof globalThis>"u"?void 0:globalThis.fetch),typeof r>"u")throw new Error("fetch() is not available: either polyfill it globally, or provide it as fetchFn option.");if(i=e.preCallStack,o=e.userAgent||"@datocms/rest-client-utils",a=e.retryCount||1,u=e.logLevel||it.NONE,l="autoRetry"in e?e.autoRetry:!0,s=e.logFn||function(){return!0},c=Ft({"content-type":"application/json",accept:"application/json",authorization:"Bearer ".concat(e.apiToken),"user-agent":o},e.extraHeaders?iE(e.extraHeaders):{}),JS&&delete c["user-agent"],d=e.baseUrl.replace(/\/$/,""),f=e.body?JSON.stringify(e.body,null,2):void 0,h=e.queryParams&&Object.keys(e.queryParams).length>0?"?".concat(new URLSearchParams(Qu(e.queryParams)).toString()):"",p="".concat(d).concat(e.url).concat(h),u>=it.BASIC){if(s("[".concat(n,"] ").concat(e.method," ").concat(p)),u>=it.BODY_AND_HEADERS)for(v=0,E=Object.entries(c||{});v<E.length;v++)m=E[v],j=m[0],V=m[1],s("[".concat(n,"] ").concat(j,": ").concat(V));u>=it.BODY&&f&&s("[".concat(n,"] ").concat(f))}I.label=1;case 1:return I.trys.push([1,12,,16]),y=Ka(r(p,{method:e.method,headers:c,body:f})),g=setTimeout(function(){y.cancel()},e.requestTimeout||3e4),[4,y];case 2:if(w=I.sent(),clearTimeout(g),O=w.headers.get("Content-Type"),b=O&&!O.includes("application/json"),!(w.status===429||b))return[3,4];if(!l||b&&e.method!=="GET")throw new oi(rd(e.method,p,c,e.body,w,void 0,i));return x=w.headers.has("X-RateLimit-Reset")?Number.parseInt(w.headers.get("X-RateLimit-Reset"),10):a,u>=it.BASIC&&(w.status===429?s("[".concat(n,"] Rate limit exceeded, wait ").concat(x," seconds then retry...")):s("[".concat(n,'] Invalid response content type "').concat(O,'" (status ').concat(w.status,"). Wait ").concat(x," seconds then retry..."))),[4,bo(x*1e3)];case 3:return I.sent(),[2,Oo(Ft(Ft({},e),{retryCount:a+1}))];case 4:if(u>=it.BASIC&&(s("[".concat(n,"] Status: ").concat(w.status," (").concat(w.statusText,")")),u>=it.BODY_AND_HEADERS))for(P=0,R=["x-api-version","x-environment","x-queue-time","x-ratelimit-remaining","x-request-id","cf-ray"];P<R.length;P++)j=R[P],V=w.headers.get(j),V&&s("[".concat(n,"] ").concat(j,": ").concat(V));return w.status!==204?[3,5]:(U=void 0,[3,7]);case 5:return[4,w.json()];case 6:U=I.sent(),I.label=7;case 7:return q=U,u>=it.BODY&&q&&s("[".concat(n,"] ").concat(JSON.stringify(q,null,2))),w.status!==202?[3,9]:[4,e.fetchJobResult(q.data.id)];case 8:if(ee=I.sent(),ee.status<200||ee.status>=300)throw new oi(nE(e.method,p,c,e.body,ee.status,ee.payload,i));q=ee.payload,I.label=9;case 9:return w.status>=200&&w.status<300?[2,q]:(X=new oi(rd(e.method,p,c,e.body,w,q,i)),K=(t=X.errors.find(function(D){return D.attributes.transient}))===null||t===void 0?void 0:t.attributes.code,l&&K?(u>=it.BASIC&&s("[".concat(n,"] ").concat(K,", wait ").concat(a," seconds then retry...")),[4,bo(a*1e3)]):[3,11]);case 10:return I.sent(),[2,Oo(Ft(Ft({},e),{retryCount:a+1}))];case 11:throw X;case 12:return re=I.sent(),re instanceof Ya||rE(re)&&re.code.includes("ETIMEDOUT")?l&&a<ZS?(u>=it.BASIC&&s("[".concat(n,"] Timeout error, wait ").concat(a," seconds then retry...")),[4,bo(a*1e3)]):[3,14]:[3,15];case 13:return I.sent(),[2,Oo(Ft(Ft({},e),{retryCount:a+1}))];case 14:throw new jS(tE(e.method,p,c,e.body,i));case 15:throw re;case 16:return[2]}})})}var bn=function(){return bn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},bn.apply(this,arguments)},oE=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function Co(e){return typeof e=="object"&&!!e&&"id"in e&&"type"in e}function Rs(e){return Array.isArray(e)&&e.every(Co)}function M(e,t){if(typeof e!="object"||!e)throw new Error("Invalid body!");if(Array.isArray(e))return{data:e.map(function(P){var R;return(R=M(P,t))===null||R===void 0?void 0:R.data})};var n=e,r=n.id,i=n.type,o=n.meta,a=oE(n,["id","type","meta"]),u={},l={};if(t.attributes==="*")for(var s=0,c=Object.entries(a);s<c.length;s++){var d=c[s],f=d[0],h=d[1];if(t.relationships.includes(f))if(Co(h)){var p=h.id,v=h.type;l[f]={data:{id:p,type:v}}}else Rs(h)?l[f]={data:h.map(function(P){var R=P.id,j=P.type;return{id:R,type:j}})}:l[f]={data:null};else u[f]=h}else if(t.relationships==="*")for(var E=0,m=Object.entries(a);E<m.length;E++){var y=m[E],f=y[0],h=y[1];if(t.attributes.includes(f))u[f]=h;else if(Co(h)){var g=h.id,v=h.type;l[f]={data:{id:g,type:v}}}else Rs(h)?l[f]={data:h.map(function(j){var V=j.id,q=j.type;return{id:V,type:q}})}:l[f]={data:null}}else{for(var w=0,O=Object.entries(a);w<O.length;w++){var b=O[w],f=b[0],h=b[1];if(t.attributes.includes(f))u[f]=h;else if(t.relationships.includes(f))if(Co(h)){var x=h.id,v=h.type;l[f]={data:{id:x,type:v}}}else Rs(h)?l[f]={data:h.map(function(j){var V=j.id,q=j.type;return{id:V,type:q}})}:l[f]={data:null}}t.attributes.includes("type")&&(u.type=i)}return{data:bn(bn(bn(bn(bn({},r||t.id?{id:r||t.id}:{}),{type:t.type}),Object.keys(u).length>0?{attributes:u}:{}),Object.keys(l).length>0?{relationships:l}:{}),o?{meta:o}:{})}}function C(e){return typeof e=="string"?e:e.id}var B=function(){function e(t){this.client=t}return e}(),aE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),sE=function(e){aE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"role",attributes:["name","can_edit_favicon","can_edit_site","can_edit_schema","can_manage_menu","can_edit_environment","can_promote_environments","environments_access","can_manage_users","can_manage_shared_filters","can_manage_upload_collections","can_manage_build_triggers","can_manage_webhooks","can_manage_environments","can_manage_sso","can_access_audit_log","can_manage_workflows","can_manage_access_tokens","can_perform_site_search","can_access_build_events_log","positive_item_type_permissions","negative_item_type_permissions","positive_upload_permissions","negative_upload_permissions","positive_build_trigger_permissions","negative_build_trigger_permissions"],relationships:["inherits_permissions_from"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/roles",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"role",attributes:["name","can_edit_favicon","can_edit_site","can_edit_schema","can_manage_menu","can_edit_environment","can_promote_environments","environments_access","can_manage_users","can_manage_shared_filters","can_manage_upload_collections","can_manage_build_triggers","can_manage_webhooks","can_manage_environments","can_manage_sso","can_access_audit_log","can_manage_workflows","can_manage_access_tokens","can_perform_site_search","can_access_build_events_log","positive_item_type_permissions","negative_item_type_permissions","positive_upload_permissions","negative_upload_permissions","positive_build_trigger_permissions","negative_build_trigger_permissions"],relationships:["inherits_permissions_from"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/roles/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/roles"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/roles/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/roles/".concat(n)})},t.prototype.duplicate=function(n){return this.rawDuplicate(C(n)).then(function(r){return S(r)})},t.prototype.rawDuplicate=function(n){return this.client.request({method:"POST",url:"/roles/".concat(n,"/duplicate")})},t.TYPE="role",t}(B),uE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),jn=function(){return jn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},jn.apply(this,arguments)},lE=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},cE=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},od=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))};function ad(e,t){return e==null&&t==null?!0:e===t}function fE(e,t){for(var n in e)if(!ad(e[n],t[n]))return!1;for(var n in t)if(!ad(e[n],t[n]))return!1;return!0}function oo(e,t,n,r){if(!t)return e;var i=t.add,o=t.remove;return od(od([],o?o.reduce(function(a,u){var l=jn(jn({},u),{environment:n}),s=a.find(function(c){return fE(c,l)});if(!s)throw new Error("Cannot find rule ".concat(JSON.stringify(l)," to remove in ").concat(r,"!"));return a.filter(function(c){return c!==s})},e):e,!0),i?i.map(function(a){return jn({environment:n},a)}):[],!0)}var dE=function(e){uE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.updateCurrentEnvironmentPermissions=function(n,r){return lE(this,void 0,void 0,function(){var i,o,a,u,l,s;return cE(this,function(c){switch(c.label){case 0:return o=this.client.config.environment,o?[3,2]:[4,this.client.environments.list()];case 1:o=c.sent().find(function(d){return d.meta.primary}).id,c.label=2;case 2:return i=o,[4,this.find(n)];case 3:return a=c.sent(),u=!!(r.positive_item_type_permissions||r.negative_item_type_permissions),l=!!(r.positive_upload_permissions||r.negative_upload_permissions),s=jn(jn({},u?{positive_item_type_permissions:oo(a.positive_item_type_permissions,r.positive_item_type_permissions,i,"positive_item_type_permissions"),negative_item_type_permissions:oo(a.negative_item_type_permissions,r.negative_item_type_permissions,i,"negative_item_type_permissions")}:{}),l?{positive_upload_permissions:oo(a.positive_upload_permissions,r.positive_upload_permissions,i,"positive_upload_permissions"),negative_upload_permissions:oo(a.negative_upload_permissions,r.negative_upload_permissions,i,"negative_upload_permissions")}:{}),[2,this.update(n,s)]}})})},t}(sE),pE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),hE=function(e){pE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"user",attributes:["is_active"],relationships:["role"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/users/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/users"})},t.prototype.find=function(n,r){return this.rawFind(C(n),r).then(function(i){return S(i)})},t.prototype.rawFind=function(n,r){return this.client.request({method:"GET",url:"/users/".concat(n),queryParams:r})},t.prototype.findMe=function(n){return this.rawFindMe(n).then(function(r){return S(r)})},t.prototype.rawFindMe=function(n){return this.client.request({method:"GET",url:"/users/me",queryParams:n})},t.prototype.destroy=function(n,r){return this.rawDestroy(C(n),r).then(function(i){return S(i)})},t.prototype.rawDestroy=function(n,r){return this.client.request({method:"DELETE",url:"/users/".concat(n),queryParams:r})},t.TYPE="user",t}(B),mE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),yE=function(e){mE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/sso-users"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/sso-users/".concat(n)})},t.prototype.copyUsers=function(){return this.rawCopyUsers().then(function(n){return S(n)})},t.prototype.rawCopyUsers=function(){return this.client.request({method:"POST",url:"/sso-users/copy-users"})},t.prototype.destroy=function(n,r){return this.rawDestroy(C(n),r).then(function(i){return S(i)})},t.prototype.rawDestroy=function(n,r){return this.client.request({method:"DELETE",url:"/sso-users/".concat(n),queryParams:r})},t.TYPE="sso_user",t}(B),vE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),gE=function(e){vE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.query=function(n){return this.rawQuery(M(n,{type:"audit_log_query",attributes:["filter","next_token","detailed_log"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawQuery=function(n){return this.client.request({method:"POST",url:"/audit-log-events/query",body:n})},t.TYPE="audit_log_event",t}(B),_E=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),wE=function(e){_E(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"menu_item",attributes:["label","external_url","position","open_in_new_tab"],relationships:["item_type","item_type_filter","parent"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/menu-items",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"menu_item",attributes:["label","external_url","position","open_in_new_tab"],relationships:["item_type","item_type_filter","parent"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/menu-items/".concat(n),body:r})},t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/menu-items",queryParams:n})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/menu-items/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/menu-items/".concat(n)})},t.prototype.reorder=function(n){return this.rawReorder(M(n,{type:"menu_item",attributes:["position"],relationships:["parent"]})).then(function(r){return S(r)})},t.prototype.rawReorder=function(n){return this.client.request({method:"POST",url:"/menu-items/reorder",body:n})},t.TYPE="menu_item",t}(B),SE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),EE=function(e){SE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"schema_menu_item",attributes:["label","position","kind"],relationships:["item_type","parent"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/schema-menu-items",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"schema_menu_item",attributes:["label","position","kind"],relationships:["item_type","parent","children"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/schema-menu-items/".concat(n),body:r})},t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/schema-menu-items",queryParams:n})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/schema-menu-items/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/schema-menu-items/".concat(n)})},t.prototype.reorder=function(n){return this.rawReorder(M(n,{type:"schema_menu_item",attributes:["position"],relationships:["parent"]})).then(function(r){return S(r)})},t.prototype.rawReorder=function(n){return this.client.request({method:"POST",url:"/schema-menu-items/reorder",body:n})},t.TYPE="schema_menu_item",t}(B),xE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),bE=function(e){xE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"upload_collection",attributes:["label","position"],relationships:["parent"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/upload-collections",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"upload_collection",attributes:["label","position"],relationships:["parent","children"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/upload-collections/".concat(n),body:r})},t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/upload-collections",queryParams:n})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/upload-collections/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/upload-collections/".concat(n)})},t.prototype.reorder=function(n){return this.rawReorder(M(n,{type:"upload_collection",attributes:["position"],relationships:["parent"]})).then(function(r){return S(r)})},t.prototype.rawReorder=function(n){return this.client.request({method:"POST",url:"/upload-collections/reorder",body:n})},t.TYPE="upload_collection",t}(B),OE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),CE=function(e){OE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(M(n,{type:"item_type",attributes:["name","api_key","singleton","all_locales_required","sortable","modular_block","draft_mode_active","draft_saving_active","tree","ordering_direction","ordering_meta","collection_appeareance","collection_appearance","hint","inverse_relationships_enabled"],relationships:["ordering_field","presentation_title_field","presentation_image_field","title_field","image_preview_field","excerpt_field","workflow"]}),r).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/item-types",body:n,queryParams:r})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"item_type",attributes:["name","api_key","collection_appeareance","collection_appearance","singleton","all_locales_required","sortable","modular_block","draft_mode_active","draft_saving_active","tree","ordering_direction","ordering_meta","has_singleton_item","hint","inverse_relationships_enabled"],relationships:["ordering_field","presentation_title_field","presentation_image_field","title_field","image_preview_field","excerpt_field","workflow"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/item-types/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/item-types"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/item-types/".concat(n)})},t.prototype.duplicate=function(n){return this.rawDuplicate(C(n)).then(function(r){return S(r)})},t.prototype.rawDuplicate=function(n){return this.client.request({method:"POST",url:"/item-types/".concat(n,"/duplicate")})},t.prototype.destroy=function(n,r){return this.rawDestroy(C(n),r).then(function(i){return S(i)})},t.prototype.rawDestroy=function(n,r){return this.client.request({method:"DELETE",url:"/item-types/".concat(n),queryParams:r})},t.prototype.rawReorderFieldsAndFieldsets=function(n,r){return this.client.request({method:"POST",url:"/item-types/".concat(n,"/reorder-fields-and-fieldsets"),body:r})},t.TYPE="item_type",t}(B),PE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),TE=function(e){PE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(C(n),M(r,{type:"field",attributes:["label","field_type","api_key","localized","validators","appeareance","appearance","position","hint","default_value","deep_filtering_enabled"],relationships:["fieldset"]})).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/item-types/".concat(n,"/fields"),body:r})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"field",attributes:["default_value","label","api_key","localized","validators","appeareance","appearance","position","field_type","hint","deep_filtering_enabled"],relationships:["fieldset"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/fields/".concat(n),body:r})},t.prototype.list=function(n){return this.rawList(C(n)).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/item-types/".concat(n,"/fields")})},t.prototype.referencing=function(n){return this.rawReferencing(C(n)).then(function(r){return S(r)})},t.prototype.rawReferencing=function(n){return this.client.request({method:"GET",url:"/item-types/".concat(n,"/fields/referencing")})},t.prototype.related=function(n){return this.rawRelated(C(n)).then(function(r){return S(r)})},t.prototype.rawRelated=function(n){return this.client.request({method:"GET",url:"/item-types/".concat(n,"/fields/related")})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/fields/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/fields/".concat(n)})},t.prototype.duplicate=function(n){return this.rawDuplicate(C(n)).then(function(r){return S(r)})},t.prototype.rawDuplicate=function(n){return this.client.request({method:"POST",url:"/fields/".concat(n,"/duplicate")})},t.TYPE="field",t}(B),kE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),IE=function(e){kE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(C(n),M(r,{type:"fieldset",attributes:["title","hint","position","collapsible","start_collapsed"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/item-types/".concat(n,"/fieldsets"),body:r})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"fieldset",attributes:["title","hint","position","collapsible","start_collapsed"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/fieldsets/".concat(n),body:r})},t.prototype.list=function(n){return this.rawList(C(n)).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/item-types/".concat(n,"/fieldsets")})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/fieldsets/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/fieldsets/".concat(n)})},t.TYPE="fieldset",t}(B),LE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),jE=function(e){LE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"email_credentials",attributes:["email","password","otp_code"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/sessions",body:n})},t.TYPE="session",t}(B),RE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),NE=function(e){RE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"access_token",attributes:["name","can_access_cda","can_access_cda_preview","can_access_cma"],relationships:["role"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/access_tokens",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"access_token",attributes:["name","can_access_cda","can_access_cda_preview","can_access_cma"],relationships:["role"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/access_tokens/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/access_tokens"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/access_tokens/".concat(n)})},t.prototype.regenerateToken=function(n){return this.rawRegenerateToken(C(n)).then(function(r){return S(r)})},t.prototype.rawRegenerateToken=function(n){return this.client.request({method:"POST",url:"/access_tokens/".concat(n,"/regenerate_token")})},t.prototype.destroy=function(n,r){return this.rawDestroy(C(n),r).then(function(i){return S(i)})},t.prototype.rawDestroy=function(n,r){return this.client.request({method:"DELETE",url:"/access_tokens/".concat(n),queryParams:r})},t.TYPE="access_token",t}(B),FE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ME=function(e){FE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"plugin",attributes:["package_name","name","description","url","permissions","plugin_type","field_types","parameter_definitions","package_version"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/plugins",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"plugin",attributes:["name","description","url","parameters","package_version","permissions"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/plugins/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/plugins"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/plugins/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/plugins/".concat(n)})},t.prototype.fields=function(n){return this.rawFields(C(n)).then(function(r){return S(r)})},t.prototype.rawFields=function(n){return this.client.request({method:"GET",url:"/plugins/".concat(n,"/fields")})},t.TYPE="plugin",t}(B),DE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),AE=function(e){DE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/job-results/".concat(n)})},t.TYPE="job_result",t}(B),zE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),$E=function(e){zE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/subscription-limits"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/subscription-limits/".concat(n)})},t.TYPE="subscription_limit",t}(B),VE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),UE=function(e){VE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/subscription-features"})},t.TYPE="subscription_feature",t}(B),qE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),BE=function(e){qE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/build-events"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/build-events/".concat(n)})},t.TYPE="build_event",t}(B),HE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),sa=function(){return sa=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},sa.apply(this,arguments)},GE=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},WE=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},hr=function(e){return this instanceof hr?(this.v=e,this):new hr(e)},YE=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof hr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},KE=function(e){HE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/items",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return YE(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return GE(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=WE(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,hr(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,hr(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,hr(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:30,maxLimit:500},function(o){return i.rawList(sa(sa({},n),{page:o}))},r)},t.prototype.validateExisting=function(n,r){return this.rawValidateExisting(C(n),M(r,{id:C(n),type:"item",attributes:"*",relationships:["item_type","creator"]}))},t.prototype.rawValidateExisting=function(n,r){return this.client.request({method:"POST",url:"/items/".concat(n,"/validate"),body:r})},t.prototype.validateNew=function(n){return this.rawValidateNew(M(n,{type:"item",attributes:"*",relationships:["item_type","creator"]}))},t.prototype.rawValidateNew=function(n){return this.client.request({method:"POST",url:"/items/validate",body:n})},t.prototype.create=function(n){return this.rawCreate(M(n,{type:"item",attributes:"*",relationships:["item_type","creator"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/items",body:n})},t.prototype.duplicate=function(n){return this.rawDuplicate(C(n)).then(function(r){return S(r)})},t.prototype.rawDuplicate=function(n){return this.client.request({method:"POST",url:"/items/".concat(n,"/duplicate")})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"item",attributes:"*",relationships:["item_type","creator"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/items/".concat(n),body:r})},t.prototype.references=function(n,r){return this.rawReferences(C(n),r).then(function(i){return S(i)})},t.prototype.rawReferences=function(n,r){return this.client.request({method:"GET",url:"/items/".concat(n,"/references"),queryParams:r})},t.prototype.find=function(n,r){return this.rawFind(C(n),r).then(function(i){return S(i)})},t.prototype.rawFind=function(n,r){return this.client.request({method:"GET",url:"/items/".concat(n),queryParams:r})},t.prototype.currentVsPublishedState=function(n){return this.rawCurrentVsPublishedState(C(n)).then(function(r){return S(r)})},t.prototype.rawCurrentVsPublishedState=function(n){return this.client.request({method:"GET",url:"/items/".concat(n,"/current-vs-published-state")})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/items/".concat(n)})},t.prototype.batchDestroy=function(n){return this.rawBatchDestroy(n).then(function(r){return S(r)})},t.prototype.rawBatchDestroy=function(n){return this.client.request({method:"DELETE",url:"/items",queryParams:n})},t.prototype.batchPublish=function(n){return this.rawBatchPublish(n).then(function(r){return S(r)})},t.prototype.rawBatchPublish=function(n){return this.client.request({method:"PUT",url:"/items/publish",queryParams:n})},t.prototype.batchUnpublish=function(n){return this.rawBatchUnpublish(n).then(function(r){return S(r)})},t.prototype.rawBatchUnpublish=function(n){return this.client.request({method:"PUT",url:"/items/unpublish",queryParams:n})},t.prototype.publish=function(n,r,i){return this.rawPublish(C(n),r?M(r,{type:"selective_publish_operation",attributes:["content_in_locales","non_localized_content"],relationships:[]}):null,i).then(function(o){return S(o)})},t.prototype.rawPublish=function(n,r,i){return this.client.request({method:"PUT",url:"/items/".concat(n,"/publish"),body:r,queryParams:i})},t.prototype.unpublish=function(n,r,i){return this.rawUnpublish(C(n),r?M(r,{type:"selective_unpublish_operation",attributes:["content_in_locales"],relationships:[]}):null,i).then(function(o){return S(o)})},t.prototype.rawUnpublish=function(n,r,i){return this.client.request({method:"PUT",url:"/items/".concat(n,"/unpublish"),body:r,queryParams:i})},t.prototype.bulkPublish=function(n){return this.rawBulkPublish(M(n,{type:"item_bulk_publish_operation",attributes:[],relationships:["items"]})).then(function(r){return S(r)})},t.prototype.rawBulkPublish=function(n){return this.client.request({method:"POST",url:"/items/bulk/publish",body:n})},t.prototype.bulkUnpublish=function(n){return this.rawBulkUnpublish(M(n,{type:"item_bulk_unpublish_operation",attributes:[],relationships:["items"]})).then(function(r){return S(r)})},t.prototype.rawBulkUnpublish=function(n){return this.client.request({method:"POST",url:"/items/bulk/unpublish",body:n})},t.prototype.bulkDestroy=function(n){return this.rawBulkDestroy(M(n,{type:"item_bulk_destroy_operation",attributes:[],relationships:["items"]})).then(function(r){return S(r)})},t.prototype.rawBulkDestroy=function(n){return this.client.request({method:"POST",url:"/items/bulk/destroy",body:n})},t.prototype.bulkMoveToStage=function(n){return this.rawBulkMoveToStage(M(n,{type:"item_bulk_move_to_stage_operation",attributes:["stage"],relationships:["items"]})).then(function(r){return S(r)})},t.prototype.rawBulkMoveToStage=function(n){return this.client.request({method:"POST",url:"/items/bulk/move-to-stage",body:n})},t.TYPE="item",t}(B),QE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ua=function(){return ua=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ua.apply(this,arguments)},XE=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},JE=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},mr=function(e){return this instanceof mr?(this.v=e,this):new mr(e)},ZE=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof mr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},ex=function(e){QE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.restore=function(n){return this.rawRestore(C(n)).then(function(r){return S(r)})},t.prototype.rawRestore=function(n){return this.client.request({method:"POST",url:"/versions/".concat(n,"/restore")})},t.prototype.list=function(n,r){return this.rawList(C(n),r).then(function(i){return S(i)})},t.prototype.rawList=function(n,r){return this.client.request({method:"GET",url:"/items/".concat(n,"/versions"),queryParams:r})},t.prototype.listPagedIterator=function(n,r,i){return ZE(this,arguments,function(){var a,u,l,s,c,d,f,h,p;return XE(this,function(v){switch(v.label){case 0:v.trys.push([0,9,10,15]),a=!0,u=JE(this.rawListPagedIterator(C(n),r,i)),v.label=1;case 1:return[4,mr(u.next())];case 2:if(l=v.sent(),d=l.done,!!d)return[3,8];p=l.value,a=!1,v.label=3;case 3:return v.trys.push([3,,6,7]),s=p,[4,mr(Gt(s))];case 4:return[4,v.sent()];case 5:return v.sent(),[3,7];case 6:return a=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return c=v.sent(),f={error:c},[3,15];case 10:return v.trys.push([10,,13,14]),!a&&!d&&(h=u.return)?[4,mr(h.call(u))]:[3,12];case 11:v.sent(),v.label=12;case 12:return[3,14];case 13:if(f)throw f.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r,i){var o=this;return Hn(r),Bn({defaultLimit:15,maxLimit:50},function(a){return o.rawList(n,ua(ua({},r),{page:a}))},i)},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/versions/".concat(n)})},t.TYPE="item_version",t}(B),tx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),la=function(){return la=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},la.apply(this,arguments)},nx=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},rx=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},yr=function(e){return this instanceof yr?(this.v=e,this):new yr(e)},ix=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof yr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},Cm=function(e){tx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"upload",attributes:["path","copyright","author","notes","default_field_metadata","tags"],relationships:["upload_collection"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/uploads",body:n})},t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/uploads",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return ix(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return nx(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=rx(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,yr(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,yr(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,yr(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:30,maxLimit:500},function(o){return i.rawList(la(la({},n),{page:o}))},r)},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/uploads/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/uploads/".concat(n)})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"upload",attributes:["path","basename","copyright","author","notes","tags","default_field_metadata"],relationships:["creator","upload_collection"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/uploads/".concat(n),body:r})},t.prototype.batchAddTags=function(n,r){return this.rawBatchAddTags(M(n,{type:"upload",attributes:["tags"],relationships:[]}),r).then(function(i){return S(i)})},t.prototype.rawBatchAddTags=function(n,r){return this.client.request({method:"PUT",url:"/uploads/batch-add-tags",body:n,queryParams:r})},t.prototype.batchDestroy=function(n){return this.rawBatchDestroy(n).then(function(r){return S(r)})},t.prototype.rawBatchDestroy=function(n){return this.client.request({method:"DELETE",url:"/uploads/batch-destroy",queryParams:n})},t.prototype.references=function(n,r){return this.rawReferences(C(n),r).then(function(i){return S(i)})},t.prototype.rawReferences=function(n,r){return this.client.request({method:"GET",url:"/uploads/".concat(n,"/references"),queryParams:r})},t.prototype.bulkTag=function(n){return this.rawBulkTag(M(n,{type:"upload_bulk_tag_operation",attributes:["tags"],relationships:["uploads"]})).then(function(r){return S(r)})},t.prototype.rawBulkTag=function(n){return this.client.request({method:"POST",url:"/uploads/bulk/tag",body:n})},t.prototype.bulkSetUploadCollection=function(n){return this.rawBulkSetUploadCollection(M(n,{type:"upload_bulk_set_upload_collection_operation",attributes:[],relationships:["upload_collection","uploads"]})).then(function(r){return S(r)})},t.prototype.rawBulkSetUploadCollection=function(n){return this.client.request({method:"POST",url:"/uploads/bulk/set-upload-collection",body:n})},t.prototype.bulkDestroy=function(n){return this.rawBulkDestroy(M(n,{type:"upload_bulk_destroy_operation",attributes:[],relationships:["uploads"]})).then(function(r){return S(r)})},t.prototype.rawBulkDestroy=function(n){return this.client.request({method:"POST",url:"/uploads/bulk/destroy",body:n})},t.TYPE="upload",t}(B),ox=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ax=function(e){ox(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"upload_request",attributes:["filename"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/upload-requests",body:n})},t.TYPE="upload_request",t}(B),sx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ux=function(e){sx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(C(n),M(r,{type:"upload_track",attributes:["url_or_upload_request_id","type","name","language_code","closed_captions"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/uploads/".concat(n,"/tracks"),body:r})},t.prototype.list=function(n){return this.rawList(C(n)).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/uploads/".concat(n,"/tracks")})},t.prototype.destroy=function(n,r){return this.rawDestroy(C(n),C(r)).then(function(i){return S(i)})},t.prototype.rawDestroy=function(n,r){return this.client.request({method:"DELETE",url:"/uploads/".concat(n,"/tracks/").concat(r)})},t.prototype.generateSubtitles=function(n,r){return this.rawGenerateSubtitles(C(n),M(r,{type:"upload_track",attributes:["name","language_code"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawGenerateSubtitles=function(n,r){return this.client.request({method:"POST",url:"/uploads/".concat(n,"/tracks/generate-subtitles"),body:r})},t.TYPE="upload_track",t}(B),lx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),cx=function(e){lx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(C(n),M(r,{type:"scheduled_publication",attributes:["publication_scheduled_at","selective_publication"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/items/".concat(n,"/scheduled-publication"),body:r})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/items/".concat(n,"/scheduled-publication")})},t.TYPE="scheduled_publication",t}(B),fx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),dx=function(e){fx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(C(n),M(r,{type:"scheduled_unpublishing",attributes:["unpublishing_scheduled_at","content_in_locales"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/items/".concat(n,"/scheduled-unpublishing"),body:r})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/items/".concat(n,"/scheduled-unpublishing")})},t.TYPE="scheduled_unpublishing",t}(B),px=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ca=function(){return ca=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ca.apply(this,arguments)},hx=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},mx=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},vr=function(e){return this instanceof vr?(this.v=e,this):new vr(e)},yx=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof vr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},vx=function(e){px(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/search-results",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return yx(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return hx(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=mx(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,vr(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,vr(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,vr(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:20,maxLimit:100},function(o){return i.rawList(ca(ca({},n),{page:o}))},r)},t.TYPE="search_result",t}(B),gx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),_x=function(e){gx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.fork=function(n,r,i){return this.rawFork(C(n),M(r,{id:C(n),type:"environment",attributes:[],relationships:[]}),i).then(function(o){return S(o)})},t.prototype.rawFork=function(n,r,i){return this.client.request({method:"POST",url:"/environments/".concat(n,"/fork"),body:r,queryParams:i})},t.prototype.promote=function(n){return this.rawPromote(C(n)).then(function(r){return S(r)})},t.prototype.rawPromote=function(n){return this.client.request({method:"PUT",url:"/environments/".concat(n,"/promote")})},t.prototype.rename=function(n,r){return this.rawRename(C(n),M(r,{id:C(n),type:"environment",attributes:[],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawRename=function(n,r){return this.client.request({method:"PUT",url:"/environments/".concat(n,"/rename"),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/environments"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/environments/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/environments/".concat(n)})},t.TYPE="environment",t}(B),wx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Sx=function(e){wx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(){return this.rawFind().then(function(n){return S(n)})},t.prototype.rawFind=function(){return this.client.request({method:"GET",url:"/maintenance-mode"})},t.prototype.activate=function(n){return this.rawActivate(n).then(function(r){return S(r)})},t.prototype.rawActivate=function(n){return this.client.request({method:"PUT",url:"/maintenance-mode/activate",queryParams:n})},t.prototype.deactivate=function(){return this.rawDeactivate().then(function(n){return S(n)})},t.prototype.rawDeactivate=function(){return this.client.request({method:"PUT",url:"/maintenance-mode/deactivate"})},t.TYPE="maintenance_mode",t}(B),Ex=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),xx=function(e){Ex(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"webhook",attributes:["name","url","custom_payload","headers","events","http_basic_user","http_basic_password","enabled","payload_api_version","nested_items_in_payload","auto_retry"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/webhooks",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"webhook",attributes:["name","url","custom_payload","headers","events","http_basic_user","http_basic_password","enabled","payload_api_version","nested_items_in_payload","auto_retry"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/webhooks/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/webhooks"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/webhooks/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/webhooks/".concat(n)})},t.TYPE="webhook",t}(B),bx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),fa=function(){return fa=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},fa.apply(this,arguments)},Ox=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},Cx=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},gr=function(e){return this instanceof gr?(this.v=e,this):new gr(e)},Px=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof gr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},Tx=function(e){bx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/webhook_calls",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return Px(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return Ox(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=Cx(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,gr(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,gr(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,gr(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:30,maxLimit:500},function(o){return i.rawList(fa(fa({},n),{page:o}))},r)},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/webhook_calls/".concat(n)})},t.prototype.resendWebhook=function(n){return this.rawResendWebhook(C(n))},t.prototype.rawResendWebhook=function(n){return this.client.request({method:"POST",url:"/webhook_calls/".concat(n,"/resend_webhook")})},t.TYPE="webhook_call",t}(B),kx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ix=function(e){kx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/build-triggers"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/build-triggers/".concat(n)})},t.prototype.create=function(n){return this.rawCreate(M(n,{type:"build_trigger",attributes:["name","webhook_token","adapter","indexing_enabled","frontend_url","autotrigger_on_scheduled_publications","adapter_settings"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/build-triggers",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"build_trigger",attributes:["name","adapter","indexing_enabled","frontend_url","autotrigger_on_scheduled_publications","adapter_settings"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/build-triggers/".concat(n),body:r})},t.prototype.trigger=function(n){return this.rawTrigger(C(n))},t.prototype.rawTrigger=function(n){return this.client.request({method:"POST",url:"/build-triggers/".concat(n,"/trigger")})},t.prototype.abort=function(n){return this.rawAbort(C(n))},t.prototype.rawAbort=function(n){return this.client.request({method:"DELETE",url:"/build-triggers/".concat(n,"/abort")})},t.prototype.abortIndexing=function(n){return this.rawAbortIndexing(C(n))},t.prototype.rawAbortIndexing=function(n){return this.client.request({method:"DELETE",url:"/build-triggers/".concat(n,"/abort_indexing")})},t.prototype.reindex=function(n){return this.rawReindex(C(n))},t.prototype.rawReindex=function(n){return this.client.request({method:"PUT",url:"/build-triggers/".concat(n,"/reindex")})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/build-triggers/".concat(n)})},t.TYPE="build_trigger",t}(B),Lx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),jx=function(e){Lx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"item_type_filter",attributes:["name","filter","columns","order_by","shared"],relationships:["item_type"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/item-type-filters",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"item_type_filter",attributes:["name","columns","order_by","shared","filter"],relationships:["item_type"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/item-type-filters/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/item-type-filters"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/item-type-filters/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/item-type-filters/".concat(n)})},t.TYPE="item_type_filter",t}(B),Rx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Nx=function(e){Rx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"upload_filter",attributes:["name","filter","shared"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/upload-filters",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"upload_filter",attributes:["name","shared","filter"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/upload-filters/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/upload-filters"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/upload-filters/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/upload-filters/".concat(n)})},t.TYPE="upload_filter",t}(B),Fx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Mx=function(e){Fx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"site_invitation",attributes:["email"],relationships:["role"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/site-invitations",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"site_invitation",attributes:[],relationships:["role"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/site-invitations/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/site-invitations"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/site-invitations/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/site-invitations/".concat(n)})},t.prototype.resend=function(n){return this.rawResend(C(n)).then(function(r){return S(r)})},t.prototype.rawResend=function(n){return this.client.request({method:"POST",url:"/site-invitations/".concat(n,"/resend")})},t.TYPE="site_invitation",t}(B),Dx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ax=function(e){Dx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/editing-sessions"})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/editing-sessions/".concat(n),body:r})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/editing-sessions/".concat(n)})},t.TYPE="editing_session",t}(B),zx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),$x=function(e){zx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/sso-groups"})},t.prototype.copyRoles=function(n){return this.rawCopyRoles(C(n)).then(function(r){return S(r)})},t.prototype.rawCopyRoles=function(n){return this.client.request({method:"POST",url:"/sso-groups/".concat(n,"/copy-roles")})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"sso_group",attributes:["priority"],relationships:["role"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/sso-groups/".concat(n),body:r})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/sso-groups/".concat(n)})},t.TYPE="sso_group",t}(B),Vx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ux=function(e){Vx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(){return this.rawFind().then(function(n){return S(n)})},t.prototype.rawFind=function(){return this.client.request({method:"GET",url:"/sso-settings"})},t.prototype.generateToken=function(){return this.rawGenerateToken().then(function(n){return S(n)})},t.prototype.rawGenerateToken=function(){return this.client.request({method:"PUT",url:"/sso-settings/generate-token"})},t.prototype.update=function(n){return this.rawUpdate(M(n,{type:"sso_settings",attributes:["idp_saml_metadata_url","idp_saml_metadata_xml"],relationships:["default_role"]})).then(function(r){return S(r)})},t.prototype.rawUpdate=function(n){return this.client.request({method:"PUT",url:"/sso-settings",body:n})},t.TYPE="sso_settings",t}(B),qx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Bx=function(e){qx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(n){return this.rawFind(n).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/emoji-suggestions",queryParams:n})},t.TYPE="emoji_suggestions",t}(B),Hx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Gx=function(e){Hx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(){return this.rawFind().then(function(n){return S(n)})},t.prototype.rawFind=function(){return this.client.request({method:"GET",url:"/white-label-settings"})},t.prototype.update=function(n){return this.rawUpdate(M(n,{type:"white_label_settings",attributes:["custom_i18n_messages_template_url"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawUpdate=function(n){return this.client.request({method:"PUT",url:"/white-label-settings",body:n})},t.TYPE="white_label_settings",t}(B),Wx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Yx=function(e){Wx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(){return this.rawFind().then(function(n){return S(n)})},t.prototype.rawFind=function(){return this.client.request({method:"GET",url:"/public-info"})},t.TYPE="public_info",t}(B),Kx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Qx=function(e){Kx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/daily-site-usages"})},t.TYPE="daily_usage",t}(B),Xx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Jx=function(e){Xx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(n,r){return this.rawFind(C(n),r).then(function(i){return S(i)})},t.prototype.rawFind=function(n,r){return this.client.request({method:"GET",url:"/usage-log-counters/".concat(n),queryParams:r})},t.TYPE="usage_counter",t}(B),Zx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),da=function(){return da=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},da.apply(this,arguments)},eb=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},tb=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},_r=function(e){return this instanceof _r?(this.v=e,this):new _r(e)},nb=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof _r?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},rb=function(e){Zx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/upload-tags",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return nb(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return eb(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=tb(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,_r(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,_r(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,_r(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:50,maxLimit:500},function(o){return i.rawList(da(da({},n),{page:o}))},r)},t.prototype.create=function(n){return this.rawCreate(M(n,{type:"upload_tag",attributes:["name"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/upload-tags",body:n})},t.TYPE="upload_tag",t}(B),ib=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),pa=function(){return pa=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},pa.apply(this,arguments)},ob=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},ab=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},wr=function(e){return this instanceof wr?(this.v=e,this):new wr(e)},sb=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof wr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},ub=function(e){ib(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/upload-smart-tags",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return sb(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return ob(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=ab(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,wr(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,wr(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,wr(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:50,maxLimit:500},function(o){return i.rawList(pa(pa({},n),{page:o}))},r)},t.TYPE="upload_smart_tag",t}(B),lb=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),cb=function(e){lb(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(n){return this.rawFind(n).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/site",queryParams:n})},t.prototype.update=function(n){return this.rawUpdate(M(n,{type:"site",attributes:["no_index","favicon","global_seo","name","theme","locales","timezone","require_2fa","ip_tracking_enabled","force_use_of_sandbox_environments"],relationships:["sso_default_role"]})).then(function(r){return S(r)})},t.prototype.rawUpdate=function(n){return this.client.request({method:"PUT",url:"/site",body:n})},t.prototype.activateImprovedTimezoneManagement=function(){return this.rawActivateImprovedTimezoneManagement().then(function(n){return S(n)})},t.prototype.rawActivateImprovedTimezoneManagement=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-timezone-management"})},t.prototype.activateImprovedHexManagement=function(){return this.rawActivateImprovedHexManagement().then(function(n){return S(n)})},t.prototype.rawActivateImprovedHexManagement=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-hex-management"})},t.prototype.activateImprovedGqlMultilocaleFields=function(){return this.rawActivateImprovedGqlMultilocaleFields().then(function(n){return S(n)})},t.prototype.rawActivateImprovedGqlMultilocaleFields=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-gql-multilocale-fields"})},t.prototype.activateImprovedGqlVisibilityControl=function(){return this.rawActivateImprovedGqlVisibilityControl().then(function(n){return S(n)})},t.prototype.rawActivateImprovedGqlVisibilityControl=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-gql-visibility-control"})},t.prototype.activateImprovedBooleanFields=function(){return this.rawActivateImprovedBooleanFields().then(function(n){return S(n)})},t.prototype.rawActivateImprovedBooleanFields=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-boolean-fields"})},t.prototype.activateDraftModeAsDefault=function(){return this.rawActivateDraftModeAsDefault().then(function(n){return S(n)})},t.prototype.rawActivateDraftModeAsDefault=function(){return this.client.request({method:"PUT",url:"/site/activate-draft-mode-as-default"})},t.prototype.activateImprovedValidationAtPublishing=function(){return this.rawActivateImprovedValidationAtPublishing().then(function(n){return S(n)})},t.prototype.rawActivateImprovedValidationAtPublishing=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-validation-at-publishing"})},t.prototype.updateAssetsCdnDefaultSettings=function(n){return this.rawUpdateAssetsCdnDefaultSettings(M(n,{type:"assets-cdn-default-settings",attributes:["assets_cdn_default_settings"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawUpdateAssetsCdnDefaultSettings=function(n){return this.client.request({method:"PUT",url:"/site/assets-cdn-default-settings",body:n})},t.TYPE="site",t}(B),fb=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),db=function(e){fb(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"workflow",attributes:["name","api_key","stages"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/workflows",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"workflow",attributes:["name","api_key","stages"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/workflows/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/workflows"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/workflows/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n))},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/workflows/".concat(n)})},t.TYPE="workflow",t}(B),Zt=function(){return Zt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},Zt.apply(this,arguments)},pb=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},hb=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},mb=function(){function e(t){this.config=t,this.roles=new dE(this),this.users=new hE(this),this.ssoUsers=new yE(this),this.auditLogEvents=new gE(this),this.menuItems=new wE(this),this.schemaMenuItems=new EE(this),this.uploadCollections=new bE(this),this.itemTypes=new CE(this),this.fields=new TE(this),this.fieldsets=new IE(this),this.session=new jE(this),this.accessTokens=new NE(this),this.plugins=new ME(this),this.jobResults=new AE(this),this.subscriptionLimits=new $E(this),this.subscriptionFeatures=new UE(this),this.buildEvents=new BE(this),this.items=new KE(this),this.itemVersions=new ex(this),this.uploads=new Cm(this),this.uploadRequest=new ax(this),this.uploadTracks=new ux(this),this.scheduledPublication=new cx(this),this.scheduledUnpublishing=new dx(this),this.searchResults=new vx(this),this.environments=new _x(this),this.maintenanceMode=new Sx(this),this.webhooks=new xx(this),this.webhookCalls=new Tx(this),this.buildTriggers=new Ix(this),this.itemTypeFilters=new jx(this),this.uploadFilters=new Nx(this),this.siteInvitations=new Mx(this),this.editingSessions=new Ax(this),this.ssoGroups=new $x(this),this.ssoSettings=new Ux(this),this.emojiSuggestions=new Bx(this),this.whiteLabelSettings=new Gx(this),this.publicInfo=new Yx(this),this.dailyUsages=new Qx(this),this.usageCounters=new Jx(this),this.uploadTags=new rb(this),this.uploadSmartTags=new ub(this),this.site=new cb(this),this.workflows=new db(this)}return Object.defineProperty(e.prototype,"baseUrl",{get:function(){return this.config.baseUrl||e.defaultBaseUrl},enumerable:!1,configurable:!0}),e.prototype.request=function(t){var n=this;return Oo(Zt(Zt(Zt({},this.config),t),{logFn:this.config.logFn||console.log,userAgent:"@datocms/cma-client v3.4.5",baseUrl:this.baseUrl,preCallStack:new Error().stack,extraHeaders:Zt(Zt(Zt({},this.config.extraHeaders||{}),this.config.environment?{"X-Environment":this.config.environment}:{}),{"X-API-Version":"3"}),fetchJobResult:function(r){return n.jobResultsFetcher?n.jobResultsFetcher(r):MS(function(){return n.jobResults.find(r)})}}))},e.prototype.eventsChannelName=function(){return pb(this,void 0,void 0,function(){var t;return hb(this,function(n){switch(n.label){case 0:return this.cachedEventsChannelName?[2,this.cachedEventsChannelName]:[4,this.site.rawFind()];case 1:return t=n.sent().data,this.cachedEventsChannelName=this.config.environment?"private-site-".concat(t.id,"-environment-").concat(this.config.environment):"private-site-".concat(t.id),[2,this.cachedEventsChannelName]}})})},e.defaultBaseUrl="https://site-api.datocms.com",e}();function yb(e,t,n){var r=n===void 0?{}:n,i=r.onProgress,o=r.additionalHeaders,a=new XMLHttpRequest;return Ka(new Promise(function(u,l){if(i&&a.upload&&(a.upload.onprogress=function(p){p.lengthComputable&&i({type:"UPLOADING_FILE",payload:{progress:Math.round(p.loaded/p.total*100)}})}),a.onreadystatechange=function(){a.readyState===4&&(a.status===200?u():l(new Error("Status ".concat(a.status))))},a.addEventListener("error",l,!1),a.open("PUT",t,!0),o)for(var s=0,c=Object.entries(o);s<c.length;s++){var d=c[s],f=d[0],h=d[1];a.setRequestHeader(f,h)}a.send(e)}),function(){a.onreadystatechange=null,a.abort()})}var ha=function(){return ha=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ha.apply(this,arguments)},vb=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},gb=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};function _b(e,t,n){var r=this;n===void 0&&(n={});var i=n.filename||("name"in t?t.name:void 0);if(!i)throw new Error("Missing filename, please provide it as an option!");var o=!1,a=void 0;return Ka(function(){return vb(r,void 0,void 0,function(){var u,l,s,c;return gb(this,function(d){switch(d.label){case 0:return n.onProgress&&(n==null||n.onProgress({type:"REQUESTING_UPLOAD_URL",payload:{filename:i}})),[4,e.uploadRequest.create({filename:i})];case 1:if(u=d.sent(),l=u.id,s=u.url,c=u.request_headers,o)throw new Ya;return n.onProgress&&n.onProgress({type:"UPLOADING_FILE",payload:{progress:0}}),a=yb(t,s,ha(ha({},n),{additionalHeaders:c})),[4,a];case 2:return d.sent(),[2,l]}})})},function(){a?a.cancel():o=!0})}var wb=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ma=function(){return ma=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ma.apply(this,arguments)},Sb=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},Eb=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},xb=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},bb=function(e){wb(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.createFromFileOrBlob=function(n){var r=this,i=!1,o;return Ka(function(){return Sb(r,void 0,void 0,function(){var a,u,l,s,c;return Eb(this,function(d){switch(d.label){case 0:if(i)throw new Ya;return a=n.fileOrBlob,u=n.filename,l=n.onProgress,s=xb(n,["fileOrBlob","filename","onProgress"]),o=_b(this.client,a,{filename:u,onProgress:l}),[4,o];case 1:return c=d.sent(),l&&l({type:"CREATING_UPLOAD_OBJECT"}),[2,this.create(ma(ma({},s),{path:c}))]}})})},function(){o?o.cancel():i=!0})},t}(Cm),Ob=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Cb=function(e){Ob(t,e);function t(n){var r=e.call(this,n)||this;return r.uploads=new bb(r),r}return t}(mb);function Pb(e){return new Cb(e)}const Tb="_assetListCard_1g8hn_23",kb="_assetListHeader_1g8hn_43",Ib="_assetListHeaderTitle_1g8hn_52",Lb="_categoryBadge_1g8hn_67",jb="_badgeGreen_1g8hn_81",Rb="_badgeRed_1g8hn_85",Nb="_badgeGray_1g8hn_89",Fb="_badgeBlue_1g8hn_93",Mb="_noAssetsMessage_1g8hn_97",Db="_assetList_1g8hn_23",Ab="_assetListItem_1g8hn_112",zb="_assetItemContent_1g8hn_126",$b="_assetIcon_1g8hn_132",Vb="_fileIconWrapper_1g8hn_136",Ub="_assetDetails_1g8hn_149",qb="_assetPath_1g8hn_154",Bb="_optimizationStats_1g8hn_161",Hb="_sizeInfo_1g8hn_169",Gb="_sizeBefore_1g8hn_176",Wb="_sizeAfter_1g8hn_176",Yb="_sizeLabel_1g8hn_182",Kb="_sizeValue_1g8hn_187",Qb="_sizeArrow_1g8hn_200",Xb="_savingsBadge_1g8hn_205",Jb="_assetActions_1g8hn_215",Zb="_container_1g8hn_226",eO="_optimizingContainer_1g8hn_290",tO="_statusText_1g8hn_302",nO="_percentageText_1g8hn_308",rO="_progressBar_1g8hn_315",iO="_progressBarFill_1g8hn_326",oO="_logWrapper_1g8hn_359",aO="_logHeader_1g8hn_369",sO="_logsContainer_1g8hn_381",uO="_logs_1g8hn_381",lO="_logEntry_1g8hn_397",cO="_sizeComparison_1g8hn_410",fO="_originalSize_1g8hn_568",dO="_optimizedSize_1g8hn_578",pO="_sizeSavings_1g8hn_583",hO="_settingsContainer_1g8hn_628",mO="_settingsForm_1g8hn_634",yO="_fieldRow_1g8hn_659",vO="_field_1g8hn_659",gO="_formActionContainer_1g8hn_670",_O="_buttonGroup_1g8hn_674",wO="_resultsContainer_1g8hn_718",SO="_optimizationSummaryTitle_1g8hn_727",EO="_statsCardGrid_1g8hn_735",xO="_statsCard_1g8hn_735",bO="_clickableStatsCard_1g8hn_752",OO="_statsCardTitle_1g8hn_792",CO="_statsCardValue_1g8hn_800",PO="_optimizedValue_1g8hn_806",TO="_skippedValue_1g8hn_810",kO="_failedValue_1g8hn_814",IO="_statsCardLabel_1g8hn_818",LO="_savingsSummary_1g8hn_823",jO="_savingsCard_1g8hn_827",RO="_savingsRow_1g8hn_834",NO="_savingsLabel_1g8hn_846",FO="_savingsValue_1g8hn_851",MO="_actionsContainer_1g8hn_857",DO="_infoText_1g8hn_866",AO="_hintWithDoc_1g8hn_882",zO="_plainHint_1g8hn_896",$O="_docLinkIcon_1g8hn_909",VO="_currentAssetPreview_1g8hn_973",UO="_assetPreviewImage_1g8hn_984",qO="_assetPreviewInfo_1g8hn_1001",BO="_assetPreviewTitle_1g8hn_1006",HO="_assetPreviewMeta_1g8hn_1016",GO="_advancedOptionsGroup_1g8hn_1025",WO="_optionsGrid_1g8hn_1035",YO="_optionItem_1g8hn_1042",KO="_paramTooltip_1g8hn_1049",QO="_tooltipText_1g8hn_1054",T={assetListCard:Tb,assetListHeader:kb,assetListHeaderTitle:Ib,categoryBadge:Lb,badgeGreen:jb,badgeRed:Rb,badgeGray:Nb,badgeBlue:Fb,noAssetsMessage:Mb,assetList:Db,assetListItem:Ab,assetItemContent:zb,assetIcon:$b,fileIconWrapper:Vb,assetDetails:Ub,assetPath:qb,optimizationStats:Bb,sizeInfo:Hb,sizeBefore:Gb,sizeAfter:Wb,sizeLabel:Yb,sizeValue:Kb,sizeArrow:Qb,savingsBadge:Xb,assetActions:Jb,container:Zb,optimizingContainer:eO,statusText:tO,percentageText:nO,progressBar:rO,progressBarFill:iO,logWrapper:oO,logHeader:aO,logsContainer:sO,logs:uO,logEntry:lO,sizeComparison:cO,originalSize:fO,optimizedSize:dO,sizeSavings:pO,settingsContainer:hO,settingsForm:mO,fieldRow:yO,field:vO,formActionContainer:gO,buttonGroup:_O,resultsContainer:wO,optimizationSummaryTitle:SO,statsCardGrid:EO,statsCard:xO,clickableStatsCard:bO,statsCardTitle:OO,statsCardValue:CO,optimizedValue:PO,skippedValue:TO,failedValue:kO,statsCardLabel:IO,savingsSummary:LO,savingsCard:jO,savingsRow:RO,savingsLabel:NO,savingsValue:FO,actionsContainer:MO,infoText:DO,hintWithDoc:AO,plainHint:zO,docLinkIcon:$O,currentAssetPreview:VO,assetPreviewImage:UO,assetPreviewInfo:qO,assetPreviewTitle:BO,assetPreviewMeta:HO,advancedOptionsGroup:GO,optionsGrid:WO,optionItem:YO,paramTooltip:KO,tooltipText:QO},Pm={largeAssetThreshold:3,veryLargeAssetThreshold:8,qualityLarge:85,qualityVeryLarge:80,resizeDimensionLarge:2400,resizeDimensionVeryLarge:2e3,minimumReduction:10,targetFormat:"avif",preserveOriginalFormat:!1,resizeLargeImages:!0,useAutoCompress:!0,useDpr:!0,useLossless:!1,useChromaSubsampling:!1,preserveColorProfile:!0};function XO(e,t){if(!e.is_image)return null;const n=t.largeAssetThreshold*1024*1024,r=t.veryLargeAssetThreshold*1024*1024,i=e.size>=n,o=e.size>=r;let a="?";if(t.useAutoCompress&&(a+="auto=compress"),o)a+=a.length>1?"&":"",a+=`q=${t.qualityVeryLarge}`;else if(i)a+=a.length>1?"&":"",a+=`q=${t.qualityLarge}`;else return null;if(t.resizeLargeImages&&e.width&&e.height){const u=Math.max(e.width,e.height),l=o?t.resizeDimensionVeryLarge:i?t.resizeDimensionLarge:null;l&&u>l&&(e.width>=e.height?(a+=a.length>1?"&":"",a+=`max-w=${l}`):(a+=a.length>1?"&":"",a+=`h=${l}`))}return t.targetFormat&&!t.preserveOriginalFormat&&(a+=a.length>1?"&":"",a+=`fm=${t.targetFormat}`),o&&t.useDpr&&(a+=a.length>1?"&":"",a+="dpr=2"),t.useLossless&&(a+=a.length>1?"&":"",a+="lossless=1"),t.useChromaSubsampling&&(a+=a.length>1?"&":"",a+="chromasub=444"),t.preserveColorProfile&&(a+=a.length>1?"&":"",a+="cs=origin"),a}var JO="Expected a function",sd=NaN,ZO="[object Symbol]",eC=/^\s+|\s+$/g,tC=/^[-+]0x[0-9a-f]+$/i,nC=/^0b[01]+$/i,rC=/^0o[0-7]+$/i,iC=parseInt,oC=typeof Ot=="object"&&Ot&&Ot.Object===Object&&Ot,aC=typeof self=="object"&&self&&self.Object===Object&&self,sC=oC||aC||Function("return this")(),uC=Object.prototype,lC=uC.toString,cC=Math.max,fC=Math.min,Ns=function(){return sC.Date.now()};function dC(e,t,n){var r,i,o,a,u,l,s=0,c=!1,d=!1,f=!0;if(typeof e!="function")throw new TypeError(JO);t=ud(t)||0,Xu(n)&&(c=!!n.leading,d="maxWait"in n,o=d?cC(ud(n.maxWait)||0,t):o,f="trailing"in n?!!n.trailing:f);function h(b){var x=r,P=i;return r=i=void 0,s=b,a=e.apply(P,x),a}function p(b){return s=b,u=setTimeout(m,t),c?h(b):a}function v(b){var x=b-l,P=b-s,R=t-x;return d?fC(R,o-P):R}function E(b){var x=b-l,P=b-s;return l===void 0||x>=t||x<0||d&&P>=o}function m(){var b=Ns();if(E(b))return y(b);u=setTimeout(m,v(b))}function y(b){return u=void 0,f&&r?h(b):(r=i=void 0,a)}function g(){u!==void 0&&clearTimeout(u),s=0,r=l=i=u=void 0}function w(){return u===void 0?a:y(Ns())}function O(){var b=Ns(),x=E(b);if(r=arguments,i=this,l=b,x){if(u===void 0)return p(l);if(d)return u=setTimeout(m,t),h(l)}return u===void 0&&(u=setTimeout(m,t)),a}return O.cancel=g,O.flush=w,O}function Xu(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function pC(e){return!!e&&typeof e=="object"}function hC(e){return typeof e=="symbol"||pC(e)&&lC.call(e)==ZO}function ud(e){if(typeof e=="number")return e;if(hC(e))return sd;if(Xu(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Xu(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(eC,"");var n=nC.test(e);return n||rC.test(e)?iC(e.slice(2),n?2:8):tC.test(e)?sd:+e}var mC=dC;const yC=ya(mC),tt=({children:e,paramName:t,paramValue:n})=>{const i=n==null?`${t}`:typeof n=="boolean"?n?`${t}=1`:"":`${t}=${n}`;return i?_.jsxs("div",{className:T.paramTooltip,children:[e,_.jsx("span",{className:T.tooltipText,children:i})]}):_.jsx(_.Fragment,{children:e})},jt=({hint:e,url:t})=>{const n=`Learn more about ${e}`,r=()=>{window.open(t,"_blank","noopener,noreferrer")};return _.jsxs("button",{className:T.hintWithDoc,onClick:r,type:"button","aria-label":n,children:[_.jsx("span",{children:e}),_.jsx("span",{className:T.docLinkIcon,children:"ℹ"})]})},Yn=({hint:e})=>_.jsx("div",{className:T.plainHint,children:_.jsx("span",{children:e})}),Rt={format:"https://docs.imgix.com/apis/rendering/format/fm",auto:"https://docs.imgix.com/apis/rendering/automatic",resize:"https://docs.imgix.com/apis/rendering/size/w",quality:"https://docs.imgix.com/apis/rendering/format/q",dpr:"https://docs.imgix.com/apis/rendering/pixel-density/dpr",lossless:"https://docs.imgix.com/apis/rendering/format/lossless",chroma:"https://docs.imgix.com/apis/rendering/format/chroma-subsampling",colorSpace:"https://docs.imgix.com/apis/rendering/format/color-space"},vC=({settings:e,onSettingsChange:t,onStartOptimization:n,ctx:r})=>{const i=k.useRef(null);k.useEffect(()=>(i.current=yC(async c=>{try{await r.updatePluginParameters({optimization_settings:JSON.stringify(c)}),console.log("Settings saved to plugin parameters:",c)}catch(d){console.error("Error saving settings:",d)}},500),()=>{i.current&&i.current.cancel()}),[r]),k.useEffect(()=>{i.current&&i.current(e)},[e]);const o=c=>d=>{const f=Number.parseFloat(d);if(!Number.isNaN(f)){let h=f;(c==="qualityLarge"||c==="qualityVeryLarge")&&(h=Math.min(Math.max(0,f),100)),c==="minimumReduction"&&(h=Math.min(Math.max(0,f),100)),(c==="largeAssetThreshold"||c==="veryLargeAssetThreshold")&&(h=Math.max(.1,f)),(c==="resizeDimensionLarge"||c==="resizeDimensionVeryLarge")&&(h=Math.max(1,f)),t({...e,[c]:h})}},a=c=>d=>{t({...e,[c]:d})},u=c=>(d,f)=>{d&&typeof d=="object"&&!Array.isArray(d)&&"value"in d&&t({...e,[c]:d.value})},l=[{label:"WebP",value:"webp"},{label:"AVIF",value:"avif"}],s=l.find(c=>c.value===e.targetFormat)||l[0];return _.jsxs(u_,{className:T.settingsForm,children:[_.jsxs(Vr,{children:[_.jsx("h4",{children:"Size Thresholds"}),_.jsxs("div",{className:T.fieldRow,children:[_.jsxs("div",{className:T.field,children:[_.jsx(wn,{id:"largeAssetThreshold",name:"largeAssetThreshold",label:"Large Asset (MB)",value:e.largeAssetThreshold.toString(),onChange:o("largeAssetThreshold")}),_.jsx(Yn,{hint:`Assets above ${e.largeAssetThreshold}MB will be optimized`})]}),_.jsxs("div",{className:T.field,children:[_.jsx(wn,{id:"veryLargeAssetThreshold",name:"veryLargeAssetThreshold",label:"Very Large Asset (MB)",value:e.veryLargeAssetThreshold.toString(),onChange:o("veryLargeAssetThreshold")}),_.jsx(Yn,{hint:`Assets above ${e.veryLargeAssetThreshold}MB get stronger optimization`})]})]}),_.jsxs("div",{className:T.field,children:[_.jsx(wn,{id:"minimumReduction",name:"minimumReduction",label:"Minimum Size Reduction (%)",value:e.minimumReduction.toString(),onChange:o("minimumReduction")}),_.jsx(Yn,{hint:"Only replace if reduced by at least this percentage"})]})]}),_.jsxs(Vr,{children:[_.jsx("h4",{children:"Basic Optimization"}),_.jsxs("div",{className:T.fieldRow,children:[_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"fm",paramValue:e.preserveOriginalFormat?void 0:e.targetFormat,children:_.jsx(_n,{id:"preserveOriginalFormat",name:"preserveOriginalFormat",label:"Preserve Original Format",value:e.preserveOriginalFormat,onChange:a("preserveOriginalFormat")})}),_.jsx(jt,{hint:"Keep original image format (JPG, PNG, etc.)",url:Rt.format})]}),_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"auto",paramValue:"compress",children:_.jsx(_n,{id:"useAutoCompress",name:"useAutoCompress",label:"Auto Compress",value:e.useAutoCompress,onChange:a("useAutoCompress")})}),_.jsx(jt,{hint:"Use Imgix's auto compression features",url:Rt.auto})]})]}),!e.preserveOriginalFormat&&_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"fm",paramValue:e.targetFormat,children:_.jsx(h_,{id:"targetFormat",name:"targetFormat",label:"Target Format",value:s,onChange:u("targetFormat"),selectInputProps:{options:l}})}),_.jsx(Yn,{hint:"Format to convert images to"})]}),_.jsxs("p",{className:T.infoText,children:[_.jsx("strong",{children:"Format Settings:"})," ",e.preserveOriginalFormat?"Original image formats will be preserved while optimizing quality and file size.":`Images will be converted to ${e.targetFormat.toUpperCase()} format for better compression.`,e.useAutoCompress&&_.jsx("span",{children:" Auto compression is enabled, letting Imgix automatically optimize each image."})]}),_.jsx("div",{className:T.fieldRow,children:_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"max-w",paramValue:e.resizeLargeImages?"value":void 0,children:_.jsx(_n,{id:"resizeLargeImages",name:"resizeLargeImages",label:"Resize Large Images",value:e.resizeLargeImages,onChange:a("resizeLargeImages")})}),_.jsx(jt,{hint:"Reduce image dimensions to save space",url:Rt.resize})]})})]}),e.resizeLargeImages&&_.jsxs(Vr,{children:[_.jsx("h4",{children:"Resize Dimensions"}),_.jsxs("div",{className:T.fieldRow,children:[_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"max-w",paramValue:e.resizeDimensionLarge,children:_.jsx(wn,{id:"resizeDimensionLarge",name:"resizeDimensionLarge",label:"Large Image Max Width (px)",value:e.resizeDimensionLarge.toString(),onChange:o("resizeDimensionLarge")})}),_.jsx(Yn,{hint:"Max dimension for large images"})]}),_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"max-w",paramValue:e.resizeDimensionVeryLarge,children:_.jsx(wn,{id:"resizeDimensionVeryLarge",name:"resizeDimensionVeryLarge",label:"Very Large Image Max Width (px)",value:e.resizeDimensionVeryLarge.toString(),onChange:o("resizeDimensionVeryLarge")})}),_.jsx(Yn,{hint:"Max dimension for very large images"})]})]})]}),_.jsxs(Vr,{children:[_.jsx("h4",{children:"Compression Settings"}),!e.useLossless&&_.jsxs("div",{className:T.fieldRow,children:[_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"q",paramValue:e.qualityLarge,children:_.jsx(wn,{id:"qualityLarge",name:"qualityLarge",label:"Large Image Quality",value:e.qualityLarge.toString(),onChange:o("qualityLarge")})}),_.jsx(jt,{hint:"Quality for large images (0-100)",url:Rt.quality})]}),_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"q",paramValue:e.qualityVeryLarge,children:_.jsx(wn,{id:"qualityVeryLarge",name:"qualityVeryLarge",label:"Very Large Image Quality",value:e.qualityVeryLarge.toString(),onChange:o("qualityVeryLarge")})}),_.jsx(jt,{hint:"Quality for very large images (0-100)",url:Rt.quality})]})]}),e.useLossless&&_.jsxs("p",{className:T.infoText,style:{marginBottom:0},children:[_.jsx("strong",{children:"Lossless Mode:"})," Standard quality settings are disabled when using Lossless Mode."]})]}),_.jsxs(Vr,{className:T.advancedOptionsGroup,children:[_.jsx("h4",{children:"Advanced Options"}),_.jsxs("div",{className:T.optionsGrid,children:[_.jsxs("div",{className:T.optionItem,children:[_.jsx(tt,{paramName:"lossless",paramValue:e.useLossless?1:void 0,children:_.jsx(_n,{id:"useLossless",name:"useLossless",label:"Use Lossless Compression",value:e.useLossless,onChange:a("useLossless")})}),_.jsx(jt,{hint:"Use lossless compression when possible",url:Rt.lossless})]}),_.jsxs("div",{className:T.optionItem,children:[_.jsx(tt,{paramName:"dpr",paramValue:e.useDpr?2:void 0,children:_.jsx(_n,{id:"useDpr",name:"useDpr",label:"Use DPR Optimization",value:e.useDpr,onChange:a("useDpr")})}),_.jsx(jt,{hint:"Optimize for high-resolution displays (Retina)",url:Rt.dpr})]}),_.jsxs("div",{className:T.optionItem,children:[_.jsx(tt,{paramName:"chromasub",paramValue:e.useChromaSubsampling?444:void 0,children:_.jsx(_n,{id:"useChromaSubsampling",name:"useChromaSubsampling",label:"Enhanced Chroma Sampling",value:e.useChromaSubsampling,onChange:a("useChromaSubsampling")})}),_.jsx(jt,{hint:"Use higher quality chroma subsampling (444) for JPEGs",url:Rt.chroma})]}),_.jsxs("div",{className:T.optionItem,children:[_.jsx(tt,{paramName:"cs",paramValue:e.preserveColorProfile?"origin":void 0,children:_.jsx(_n,{id:"preserveColorProfile",name:"preserveColorProfile",label:"Preserve Color Profiles",value:e.preserveColorProfile,onChange:a("preserveColorProfile")})}),_.jsx(jt,{hint:"Maintain accurate colors from original image",url:Rt.colorSpace})]})]})]}),_.jsx("div",{className:T.formActionContainer,children:_.jsxs("div",{className:T.buttonGroup,children:[_.jsx(kn,{buttonType:"muted",buttonSize:"l",onClick:()=>t({...Pm}),children:"Restore Defaults"}),_.jsx(kn,{buttonType:"primary",buttonSize:"l",onClick:n,fullWidth:!0,children:"Start Optimization"})]})})]})};function Rn(e){return e<1024?`${e} bytes`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const gC=({log:e})=>{if(e.length===0)return null;const t=k.useRef(null);return k.useEffect(()=>{if(t.current){const{scrollHeight:n,clientHeight:r}=t.current;t.current.scrollTop=n-r}},[]),_.jsxs("div",{className:T.logWrapper,children:[_.jsxs("div",{className:T.logHeader,children:[_.jsx("h3",{children:"Activity Log"}),_.jsxs("span",{children:[e.length," entries"]})]}),_.jsx("div",{className:T.logsContainer,ref:t,children:_.jsx("div",{className:T.logs,children:e.map((n,r)=>_.jsxs("div",{className:T.logEntry,children:[_.jsx("span",{children:n.text}),n.originalSize&&n.optimizedSize&&_.jsxs("span",{className:T.sizeComparison,children:[_.jsx("span",{className:T.originalSize,children:Rn(n.originalSize)}),_.jsx("span",{className:T.sizeArrow,children:"→"}),_.jsx("span",{className:T.optimizedSize,children:Rn(n.optimizedSize)}),_.jsxs("span",{className:T.sizeSavings,children:["(-",n.savingsPercentage,"%)"]})]})]},`log-${r}-${n.text.substring(0,10)}`))})})]})},_C=({current:e,total:t,isVisible:n,assetSizeCategory:r="large",currentAsset:i})=>{var a;if(!n)return null;const o=t>0?Math.min(100,Math.max(0,Math.round(e/t*100))):0;return _.jsxs("div",{className:T.optimizingContainer,children:[i&&_.jsxs("div",{className:T.currentAssetPreview,children:[_.jsx("div",{className:T.assetPreviewImage,children:_.jsx("img",{src:`${i.url}?w=120&h=80&fit=crop&auto=format`,alt:i.basename})}),_.jsxs("div",{className:T.assetPreviewInfo,children:[_.jsx("div",{className:T.assetPreviewTitle,children:i.basename}),_.jsxs("div",{className:T.assetPreviewMeta,children:[(a=i.path.split(".").pop())==null?void 0:a.toUpperCase()," • ",(i.size/(1024*1024)).toFixed(2)," MB • ",i.width,"×",i.height,"px"]})]})]}),_.jsxs("div",{className:T.statusText,children:[_.jsx(mS,{size:16})," ",_.jsxs("span",{children:["Processing ",r," assets: ",e," of ",t]})]}),_.jsx("div",{className:T.percentageText,children:_.jsxs("span",{children:[o,"%"]})}),_.jsx("div",{className:T.progressBar,children:_.jsx("div",{className:T.progressBarFill,style:{width:`${o}%`}})})]})},wC=({result:e,setSelectedCategory:t,resetState:n,largeAssetThreshold:r})=>{if(!e)return null;const{optimized:i,skipped:o,failed:a,totalAssets:u,optimizedAssets:l}=e,s=l.reduce((p,v)=>p+(v.originalSize-v.optimizedSize),0),c=l.length>0?Math.round(l.reduce((p,v)=>p+(v.originalSize-v.optimizedSize)/v.originalSize*100,0)/l.length):0,d=()=>s<1024?`${s} bytes`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`,f=(p,v)=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),t(v))},h=()=>{n?n():t(null)};return _.jsxs("div",{className:T.resultsContainer,children:[_.jsx("h2",{className:T.optimizationSummaryTitle,children:"Optimization Summary"}),u===0&&r&&_.jsx("div",{className:`${T.infoBox}`,style:{margin:"0 0 16px 0",padding:"16px",backgroundColor:"var(--light-bg-color)",borderRadius:"4px"},children:_.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[_.jsx("div",{style:{marginRight:"8px",color:"var(--accent-color)",display:"flex"},children:_.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[_.jsx("title",{children:"Information"}),_.jsx("path",{d:"M12 22C6.477 22 2 17.523 2 12C2 6.477 6.477 2 12 2C17.523 2 22 6.477 22 12C22 17.523 17.523 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 7H13V9H11V7ZM11 11H13V17H11V11Z",fill:"currentColor"})]})}),_.jsxs("p",{style:{margin:0,color:"var(--base-body-color)"},children:["No images in your project are larger than ",_.jsxs("strong",{children:[r,"MB"]}),". Try lowering the minimum size threshold to optimize more assets."]})]})}),_.jsxs("div",{className:T.statsCardGrid,children:[_.jsxs("div",{className:T.statsCard,children:[_.jsx("h3",{className:T.statsCardTitle,children:"Total Assets"}),_.jsx("div",{className:T.statsCardValue,children:u}),_.jsx("div",{className:T.statsCardLabel,children:u>0?"Total":"No assets found"})]}),_.jsxs("div",{className:`${T.statsCard} ${i>0?T.clickableStatsCard:""}`,onClick:()=>i>0?t("optimized"):null,onKeyDown:p=>i>0?f(p,"optimized"):null,role:i>0?"button":void 0,tabIndex:i>0?0:void 0,children:[_.jsx("h3",{className:T.statsCardTitle,children:"Optimized"}),_.jsx("div",{className:`${T.statsCardValue} ${T.optimizedValue}`,children:i}),_.jsx("div",{className:T.statsCardLabel,children:i>0?"Click to view":"No optimized assets"})]}),_.jsxs("div",{className:`${T.statsCard} ${o>0?T.clickableStatsCard:""}`,onClick:()=>o>0?t("skipped"):null,onKeyDown:p=>o>0?f(p,"skipped"):null,role:o>0?"button":void 0,tabIndex:o>0?0:void 0,children:[_.jsx("h3",{className:T.statsCardTitle,children:"Skipped"}),_.jsx("div",{className:`${T.statsCardValue} ${T.skippedValue}`,children:o}),_.jsx("div",{className:T.statsCardLabel,children:o>0?"Click to view":"No skipped assets"})]}),_.jsxs("div",{className:`${T.statsCard} ${a>0?T.clickableStatsCard:""}`,onClick:()=>a>0?t("failed"):null,onKeyDown:p=>a>0?f(p,"failed"):null,role:a>0?"button":void 0,tabIndex:a>0?0:void 0,children:[_.jsx("h3",{className:T.statsCardTitle,children:"Failed"}),_.jsx("div",{className:`${T.statsCardValue} ${T.failedValue}`,children:a}),_.jsx("div",{className:T.statsCardLabel,children:a>0?"Click to view":"No failed assets"})]})]}),_.jsx("div",{className:T.savingsSummary,children:_.jsxs("div",{className:T.savingsCard,children:[_.jsxs("div",{className:T.savingsRow,children:[_.jsx("div",{className:T.savingsLabel,children:"Total Storage Saved"}),_.jsx("div",{className:T.savingsValue,children:d()})]}),_.jsxs("div",{className:T.savingsRow,children:[_.jsx("div",{className:T.savingsLabel,children:"Average Optimization per Asset"}),_.jsxs("div",{className:T.savingsValue,children:[c,"%"]})]})]})}),_.jsx("div",{className:T.actionsContainer,children:_.jsx(kn,{buttonType:"primary",buttonSize:"l",onClick:h,fullWidth:!0,children:"New Optimization"})})]})},SC=({assets:e,category:t,onClose:n,ctx:r})=>{const i=()=>{switch(t){case"optimized":return T.badgeGreen;case"failed":return T.badgeRed;case"skipped":return T.badgeGray;default:return T.badgeBlue}};return _.jsxs("div",{className:T.assetListCard,children:[_.jsxs("div",{className:T.assetListHeader,children:[_.jsxs("div",{className:T.assetListHeaderTitle,children:[_.jsx("div",{className:`${T.categoryBadge} ${i()}`,children:e.length}),_.jsxs("h3",{children:[t.charAt(0).toUpperCase()+t.slice(1)," Assets"]})]}),n&&_.jsx(kn,{buttonType:"negative",buttonSize:"xs",onClick:n,children:"Close"})]}),e.length===0?_.jsxs("div",{className:T.noAssetsMessage,children:["No ",t," assets to display."]}):_.jsx("ul",{className:T.assetList,children:e.map(o=>{const a={id:o.id,path:o.path,url:o.url,size:"size"in o?o.size:"originalSize"in o?o.originalSize:0,basename:"basename"in o?o.basename:"",originalSize:"originalSize"in o?o.originalSize:void 0,optimizedSize:"optimizedSize"in o?o.optimizedSize:void 0},u=a.originalSize&&a.optimizedSize?Math.round((a.originalSize-a.optimizedSize)/a.originalSize*100):null,l=a.path.split(".").pop()||"";return _.jsx("li",{className:T.assetListItem,children:_.jsxs("div",{className:T.assetItemContent,children:[_.jsx("div",{className:T.assetIcon,children:_.jsx("div",{className:T.fileIconWrapper,children:l.toUpperCase()})}),_.jsxs("div",{className:T.assetDetails,children:[_.jsx("p",{className:T.assetPath,children:a.path}),t==="optimized"&&a.originalSize&&a.optimizedSize&&_.jsxs("div",{className:T.optimizationStats,children:[_.jsxs("div",{className:T.sizeInfo,children:[_.jsxs("div",{className:T.sizeBefore,children:[_.jsx("span",{className:T.sizeLabel,children:"Original:"}),_.jsx("span",{className:T.sizeValue,children:Rn(a.originalSize)})]}),_.jsx("div",{className:T.sizeArrow,children:"→"}),_.jsxs("div",{className:T.sizeAfter,children:[_.jsx("span",{className:T.sizeLabel,children:"Optimized:"}),_.jsx("span",{className:T.sizeValue,children:Rn(a.optimizedSize)})]})]}),u&&_.jsxs("div",{className:`${T.savingsBadge} ${T.badgeGreen}`,children:[u,"% savings"]})]})]}),_.jsxs("div",{className:T.assetActions,children:[_.jsx(kn,{buttonSize:"xxs",buttonType:"primary",onClick:()=>window.open(a.url,"_blank"),children:"View Asset"}),_.jsx(kn,{buttonSize:"xxs",buttonType:"muted",style:{marginLeft:"8px"},onClick:()=>window.open(`https://${r.site.attributes.internal_domain}/media/assets/${a.id}`,"_blank"),children:"Media Area"})]})]})},a.id)})})]})};async function EC(e,t,n=60,r=2e3){var u;const i="https://site-api.datocms.com",o={Authorization:`Bearer ${t}`,"Content-Type":"application/json",Accept:"application/json","X-Api-Version":"3"};let a=0;for(;a<n;){a++;try{const l=await fetch(`${i}/job-results/${e}`,{headers:o});if(l.status===200){const s=await l.json();if(((u=s.data.attributes)==null?void 0:u.status)===200)return console.log(`Job ${e} completed successfully`),s}console.log(`Job ${e} still processing (attempt ${a}/${n})...`),await new Promise(s=>setTimeout(s,r))}catch(l){console.error(`Error checking job status: ${l}`)}}throw new Error(`Job ${e} did not complete after ${n} attempts`)}async function xC(e,t,n,r){var i,o;if(console.log(`Replacing DatoCMS asset ID ${e} with image from URL: ${t}`),!e||!n)throw new Error("Missing required parameters: assetId and apiToken are required");try{const a="https://site-api.datocms.com",u={Authorization:`Bearer ${n}`,"Content-Type":"application/json",Accept:"application/json","X-Api-Version":"3"},l=await fetch(`${a}/upload-requests`,{method:"POST",headers:u,body:JSON.stringify({data:{type:"upload_request",attributes:{filename:r||"optimized-image.jpg"}}})});if(!l.ok){const w=await l.text();throw new Error(`Failed to create upload request: ${l.status} ${w}`)}const s=await l.json(),{id:c,attributes:{url:d,request_headers:f}}=s.data,h=await fetch(t);if(!h.ok)throw new Error(`Failed to fetch image from URL: ${h.status} ${h.statusText}`);const v=await(await h.blob()).arrayBuffer(),E=new Uint8Array(v),m=await fetch(d,{method:"PUT",headers:{...f,"Content-Length":E.length.toString()},body:E});if(!m.ok)throw new Error(`Failed to upload file to S3: ${m.status} ${m.statusText}`);const y=await fetch(`${a}/uploads/${e}`,{method:"PUT",headers:u,body:JSON.stringify({data:{id:e,type:"upload",attributes:{path:c}}})});if(!y.ok){const w=await y.text();throw new Error(`Failed to update asset metadata: ${y.status} ${w}`)}const g=await y.json();if(g.data&&g.data.type==="job"){const w=g.data.id;console.log(`Asset update initiated as job ${w}, waiting for completion...`);const O=await EC(w,n);if(((i=O.data.attributes)==null?void 0:i.status)!==200)throw new Error(`Job completed with error status: ${(o=O.data.attributes)==null?void 0:o.status}`);return O.data.attributes.payload}return console.log("Asset replaced successfully:",g),g}catch(a){throw console.error("Error replacing asset:",a),a}}function bC(e){var t,n,r,i,o,a;return{id:e.id,is_image:e.is_image||!1,size:e.size||0,url:e.url||"",path:e.path||"",basename:e.basename||"",width:e.width||void 0,height:e.height||void 0,alt:((n=(t=e.default_field_metadata)==null?void 0:t.en)==null?void 0:n.alt)||void 0,title:((i=(r=e.default_field_metadata)==null?void 0:r.en)==null?void 0:i.title)||void 0,customData:((a=(o=e.default_field_metadata)==null?void 0:o.en)==null?void 0:a.custom_data)||{},tags:e.tags||[]}}function ao(e){return{id:e.id,path:e.path,url:e.url}}function OC(e,t,n){return{id:e.id,path:e.path,url:e.url,originalSize:t,optimizedSize:n}}const CC=({ctx:e})=>{const[t,n]=k.useState(!1),[r,i]=k.useState(0),[o,a]=k.useState(0),[u,l]=k.useState(null),[s,c]=k.useState([]),[d,f]=k.useState({...Pm}),[h,p]=k.useState(void 0),[v,E]=k.useState(null);k.useEffect(()=>{(async()=>{try{const b=e.plugin.attributes.parameters;if(b&&typeof b.optimization_settings=="string")try{const x=JSON.parse(b.optimization_settings);f(x),console.log("Loaded settings from plugin parameters:",x)}catch(x){console.error("Error parsing saved settings:",x)}else console.log("No saved settings found, using defaults")}catch(b){console.error("Error accessing plugin parameters:",b)}})()},[e]),k.useEffect(()=>{const O=b=>{if(t){const x="Optimization is in progress. Leaving the page now may cause you to lose assets! Are you sure you want to leave?";return b.preventDefault(),b.returnValue=x,x}};return window.addEventListener("beforeunload",O),()=>{window.removeEventListener("beforeunload",O)}},[t]);const m=O=>{c(b=>[{text:`[${new Date().toISOString()}] ${O}`},...b])},y=(O,b,x)=>{const P=b-x,R=Math.round(P/b*100);c(j=>[{text:`[${new Date().toISOString()}] Successfully optimized asset: ${O} `,originalSize:b,optimizedSize:x,savingsPercentage:R},...j])},g=async()=>{try{if(await e.openConfirm({title:"Confirm Asset Optimization",content:"WARNING: This is a destructive action that will permanently replace all assets that fall into the optimization thresholds. This action is non-reversible and original assets cannot be recovered once replaced. Are you sure you want to proceed?",choices:[{label:"Proceed to Final Confirmation",value:"confirm",intent:"positive"}],cancel:{label:"Cancel",value:!1}})!=="confirm"||await e.openConfirm({title:"Final Confirmation Required",content:"ARE YOU ABSOLUTELY SURE? This will immediately replace your original assets with optimized versions. Your original assets will be PERMANENTLY DELETED and CANNOT be recovered. This may affect the visual quality of your images if not configured correctly.",choices:[{label:"Yes, Replace My Assets",value:"confirm",intent:"positive"}],cancel:{label:"No, Cancel Operation",value:!1}})!=="confirm")return;w(),n(!0),m("Starting asset optimization process...");const x=Pb({apiToken:e.currentUserAccessToken??""});m("Fetching assets from DatoCMS...");const P=d.largeAssetThreshold*1024*1024,R=[];let j=0;for await(const D of x.uploads.listPagedIterator({filter:{fields:{type:{eq:"image"},size:{gte:P}}}}))j++,R.push(bC(D));m(`Found ${j} assets larger than ${d.largeAssetThreshold}MB.`),m(`Found ${R.length} optimizable images.`),a(R.length);let V=0,q=0,U=0;const ee=[],X=[],K=[];let re=0,I=0;for(let D=0;D<R.length;D++){const N=R[D];i(D+1),p(N);try{m(`Processing asset: ${N.path} (${Rn(N.size)})`),re+=N.size;const Y=XO(N,d);if(!Y){m(`Skipping asset ${N.path}: No suitable optimization parameters found.`),X.push(ao(N)),q++;continue}const G=`${N.url}${Y}`;m(`Optimizing with parameters: ${Y}`);const he=await fetch(G);if(!he.ok)throw new Error(`Failed to fetch optimized image: ${he.statusText}`);const ce=await he.blob();m(`Optimized image size: ${Rn(ce.size)}`);const $e=N.size*(1-d.minimumReduction/100);if(ce.size>$e){m(`Optimization not significant enough for ${N.path}. Skipping.`),X.push(ao(N)),q++;continue}m(`Replacing asset ${N.path}...`);try{const oe=e.currentUserAccessToken;if(!oe)throw new Error("Failed to get API token");const Fe=`${N.url}${Y}`;await xC(N.id,Fe,oe,N.basename),ee.push(OC(N,N.size,ce.size)),I+=ce.size,V++,y(N.path,N.size,ce.size),m(`Successfully replaced asset ${N.path}`)}catch(oe){m(`Error replacing asset: ${oe instanceof Error?oe.message:String(oe)}`),K.push(ao(N)),U++}}catch(Y){m(`Error optimizing asset ${N.path}: ${Y instanceof Error?Y.message:String(Y)}`),K.push(ao(N)),U++}}l({optimized:V,skipped:q,failed:U,totalAssets:j,optimizedAssets:ee,skippedAssets:X,failedAssets:K}),m(`Optimization complete. Optimized: ${V}, Skipped: ${q}, Failed: ${U}`),V>0&&m(`Total size savings: ${Rn(re-I)} (${Math.round((re-I)/re*100)}%)`),m("Asset optimization process completed!"),e.notice("Asset optimization process completed!")}catch(O){m(`Error during optimization process: ${O instanceof Error?O.message:String(O)}`),e.alert(`Error during optimization process: ${O instanceof Error?O.message:String(O)}`)}finally{n(!1)}},w=()=>{l(null),c([]),i(0),a(0),p(void 0)};return _.jsx(xd,{ctx:e,children:_.jsxs("div",{className:T.container,children:[_.jsx("h1",{className:T.title,children:"Asset Optimization"}),!t&&!u&&_.jsx("div",{className:T.settingsContainer,children:_.jsx(vC,{settings:d,onSettingsChange:f,onStartOptimization:g,ctx:e})}),_.jsx(_C,{current:r,total:o,isVisible:t,assetSizeCategory:d.veryLargeAssetThreshold>0?"large and very large":"large",currentAsset:h}),u&&_.jsxs(_.Fragment,{children:[_.jsx(wC,{result:u,setSelectedCategory:E,resetState:w,largeAssetThreshold:d.largeAssetThreshold}),v&&_.jsx(SC,{assets:v==="optimized"?u.optimizedAssets:v==="skipped"?u.skippedAssets:u.failedAssets,category:v,onClose:()=>E(null),ctx:e})]}),_.jsx(gC,{log:s})]})})};var Tm,ld=Oh;Tm=ld.createRoot,ld.hydrateRoot;const PC=document.getElementById("root"),TC=Tm(PC);function cd(e){TC.render(_.jsx(k.StrictMode,{children:e}))}Dy({renderConfigScreen(e){return cd(_.jsx(kS,{ctx:e}))},settingsAreaSidebarItemGroups(e){return e.currentRole.attributes.can_edit_schema?[{label:"Asset Management",items:[{label:"Optimize assets",icon:"images",pointsTo:{pageId:"optimize-assets"}}]}]:[]},renderPage(e,t){switch(e){case"optimize-assets":return cd(_.jsx(CC,{ctx:t}))}}});
|
|
62
|
+
`.concat(i.preCallStack)),i}return Object.defineProperty(t.prototype,"errors",{get:function(){return LS(this.response.body)?this.response.body.data:[]},enumerable:!1,configurable:!0}),t.prototype.findError=function(n,r){var i=Array.isArray(n)?n:[n];return this.errors.find(function(o){return i.includes(o.attributes.code)&&(!r||(typeof r=="function"?r(o.attributes.details):Object.entries(r).every(function(a){var u=a[0],l=a[1];return o.attributes.details[u]===l})))})},t}(Error),RS=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ya=function(e){RS(t,e);function t(){var n=this.constructor,r=e.call(this,"Promise canceled!")||this;return Object.setPrototypeOf(r,n.prototype),r}return t}(Error);function Ka(e,t){var n=null,r=new Promise(function(i,o){n=function(){try{t&&t(),o(new Ya)}catch(u){o(u)}};var a=typeof e=="function"?e():e;a.then(i,o)});return n&&(r.cancel=n),r}function bo(e){return new Promise(function(t){setTimeout(t,e)})}var NS=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},FS=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};function MS(e){return NS(this,void 0,void 0,function(){var t,n,r;return FS(this,function(i){switch(i.label){case 0:n=0,i.label=1;case 1:return i.trys.push([1,4,,5]),n+=1,[4,bo(n*1e3)];case 2:return i.sent(),[4,e()];case 3:return t=i.sent(),[3,5];case 4:if(r=i.sent(),!(r instanceof oi)||r.response.status!==404)throw r;return[3,5];case 5:if(!t)return[3,1];i.label=6;case 6:return[2,t]}})})}var xm={},sc={},uc={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TaskCollisionStrategy=void 0,function(t){t[t.DEFAULT=0]="DEFAULT",t[t.KEEP_THIS=1]="KEEP_THIS",t[t.KEEP_OTHER=2]="KEEP_OTHER",t[t.KEEP_BOTH=3]="KEEP_BOTH",t[t.RESOLVE_THIS=4]="RESOLVE_THIS",t[t.RESOLVE_OTHER=5]="RESOLVE_OTHER"}(e.TaskCollisionStrategy||(e.TaskCollisionStrategy={}))})(uc);var Qa={};Object.defineProperty(Qa,"__esModule",{value:!0});class DS{constructor(t,n){this._code=t,this._message=n}get code(){return this._code}get message(){return this._message}}Qa.default=DS;var Vn={};Object.defineProperty(Vn,"__esModule",{value:!0});Vn.mutexEquality=Vn.mutexBitwiseAnd=void 0;function AS(e,t){return(e&t)!==0}Vn.mutexBitwiseAnd=AS;function zS(e,t){return e===t}Vn.mutexEquality=zS;var lc={};Object.defineProperty(lc,"__esModule",{value:!0});class $S{constructor(t,n){this._meta=void 0,this._task=t,this._scheduler=n}withDescriptor(t){return this._descriptor=t,this}withMutex(t){return this._mutex=t,this}withMeta(t){return this._meta=t,this}runBeforeExecuting(t){return this._onPreExecute=t,this}handleCollisions(t){return this._onTaskCollision=t,this}execute(t){return this._scheduler.enqueue({priority:t,mutex:this._mutex,descriptor:this._descriptor,meta:this._meta,execute:this._task,onPreExecute:this._onPreExecute,onTaskCollision:this._onTaskCollision})}}lc.default=$S;var VS=Ot&&Ot.__awaiter||function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},bm=Ot&&Ot.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(sc,"__esModule",{value:!0});const wt=uc,US=bm(Qa),qS=Vn,BS=bm(lc);var rt;(function(e){e[e.PENDING=0]="PENDING",e[e.EXECUTING=1]="EXECUTING",e[e.TERMINATED=2]="TERMINATED"})(rt||(rt={}));function nd(e,t){for(let n of e.listeners)n.reject(t)}class HS{constructor(t,n={}){this._queue=[],this._isExecuting=!1,this._idleListeners=[],this._maxConcurrentTasks=t,this._samePriorityMutex=!!n.samePriorityMutex,this._mutexStrategy=n.mutexStrategy||qS.mutexEquality,n.disableLogging?this._errorLog=()=>{}:this._errorLog=console.error}enqueue(t){return new Promise((n,r)=>{typeof t=="function"&&(t={priority:0,execute:t});const i=this._checkMutexes(t,n,r);i.task?this._addTask(i.task):i.canceled&&r(this.createCanceledError())})}prepare(t){return new BS.default(t,this)}_addTask(t){this._queue.push(t),this._applyPriorities(),this._isExecuting||(this._isExecuting=!0,setTimeout(this._executeNextTasks.bind(this)))}get executingTasks(){return this._queue.reduce((t,n)=>n.state===rt.EXECUTING?t+1:t,0)}createCanceledError(){return new US.default(50,"Task has been canceled in favor of another task")}_findFirstPendingTask(){return this._queue.find(t=>t.state===rt.PENDING)}_isIdle(){return this._queue.length===0||!this._queue.find(t=>t.state!==rt.TERMINATED)}_removeTaskAt(t){this._queue.splice(t,1)}_executeTask(t){return VS(this,void 0,void 0,function*(){try{return t.task.onPreExecute&&t.task.onPreExecute(),yield t.task.execute()}catch(n){throw n}finally{t.state=rt.TERMINATED;let n=this._queue.indexOf(t);this._removeTaskAt(n),this._executeNextTasks()}})}_executeNextTasks(){let t=this.executingTasks;if(t>=this._maxConcurrentTasks)return;let n=this._maxConcurrentTasks-t;for(let r=0;r<n;r++){const i=this._findFirstPendingTask();if(!i){this._isIdle()&&this._switchToIdle();return}i.state=rt.EXECUTING,this._executeTask(i).then(o=>{for(const{resolve:a}of i.listeners)try{a(o)}catch(u){this._errorLog("An error occurred while resolving listener",u)}}).catch(o=>{for(const{reject:a}of i.listeners)try{a(o)}catch(u){this._errorLog("An error occurred while rejecting listener",u)}})}}_switchToIdle(){this._isExecuting=!1;const t=this._idleListeners;this._idleListeners=[];for(const{resolve:n}of t)try{n()}catch{}}waitForIdle(){return this._isExecuting?new Promise((t,n)=>{this._idleListeners.push({resolve:t,reject:n})}):Promise.resolve()}_applyPriorities(){this._queue.sort((t,n)=>n.task.priority-t.task.priority)}_checkMutexes(t,n,r){for(let i=0;i<this._queue.length;i++){let o=this._queue[i];if(o.state===rt.TERMINATED||this._samePriorityMutex&&o.task.priority!=t.priority||!o.task.mutex||!t.mutex||!this._mutexStrategy(o.task.mutex,t.mutex))continue;let a,u;if(o.task.onTaskCollision)if(a=o.task.onTaskCollision(t),a===wt.TaskCollisionStrategy.KEEP_OTHER&&o.state!==rt.EXECUTING){this._removeTaskAt(i--),nd(o,this.createCanceledError());continue}else{if(a===wt.TaskCollisionStrategy.KEEP_THIS)return{canceled:!0};if(a===wt.TaskCollisionStrategy.RESOLVE_OTHER)return this._removeTaskAt(i--),{canceled:!1,task:{task:t,state:rt.PENDING,listeners:[{resolve:n,reject:r},...o.listeners]}};if(a===wt.TaskCollisionStrategy.RESOLVE_THIS)return o.listeners=[...o.listeners,{resolve:n,reject:r}],{canceled:!1}}if(t.onTaskCollision){if(u=t.onTaskCollision(o.task),u===wt.TaskCollisionStrategy.KEEP_OTHER)return{canceled:!0};if(u===wt.TaskCollisionStrategy.KEEP_THIS){this._removeTaskAt(i--),nd(o,this.createCanceledError());continue}else{if(u===wt.TaskCollisionStrategy.RESOLVE_OTHER)return o.listeners=[...o.listeners,{resolve:n,reject:r}],{canceled:!1};if(u===wt.TaskCollisionStrategy.RESOLVE_THIS)return this._removeTaskAt(i--),{canceled:!1,task:{task:t,state:rt.PENDING,listeners:[{resolve:n,reject:r},...o.listeners]}}}}if(!(a===wt.TaskCollisionStrategy.KEEP_BOTH&&u===wt.TaskCollisionStrategy.KEEP_BOTH))return{canceled:!0}}return{canceled:!1,task:{task:t,state:rt.PENDING,listeners:[{resolve:n,reject:r}]}}}}sc.default=HS;(function(e){var t=Ot&&Ot.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(e,"__esModule",{value:!0}),e.mutexEquality=e.mutexBitwiseAnd=e.SchedulerError=e.TaskCollisionStrategy=e.Scheduler=void 0;const n=t(sc);e.Scheduler=n.default;const r=uc;Object.defineProperty(e,"TaskCollisionStrategy",{enumerable:!0,get:function(){return r.TaskCollisionStrategy}});const i=t(Qa);e.SchedulerError=i.default;const o=Vn;Object.defineProperty(e,"mutexBitwiseAnd",{enumerable:!0,get:function(){return o.mutexBitwiseAnd}}),Object.defineProperty(e,"mutexEquality",{enumerable:!0,get:function(){return o.mutexEquality}})})(xm);var GS=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},Tn=function(e){return this instanceof Tn?(this.v=e,this):new Tn(e)},WS=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof Tn?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}};function Bn(e,t,n){return WS(this,arguments,function(){var i,o,a,u,l,m,s,c,d,f,h,p,v,E,m;return GS(this,function(y){switch(y.label){case 0:if(i=(n==null?void 0:n.perPage)||e.defaultLimit,i>e.maxLimit)throw new Error("perPage option cannot exceed maximum value of ".concat(e.maxLimit));if(o=(n==null?void 0:n.concurrency)||1,o>10)throw new Error("concurrency option cannot exceed maximum value of 10");return[4,Tn(t({limit:i,offset:0}))];case 1:a=y.sent(),u=0,l=a.data,y.label=2;case 2:return u<l.length?(m=l[u],[4,Tn(m)]):[3,6];case 3:return[4,y.sent()];case 4:y.sent(),y.label=5;case 5:return u++,[3,2];case 6:for(s=a.meta.total_count,c=new xm.Scheduler(o),d=[],f=function(g){d.push(c.enqueue(function(){return t({limit:i,offset:g})}))},h=i;h<s;h+=i)f(h);y.label=7;case 7:return d.length>0?[4,Tn(d.shift())]:[3,14];case 8:p=y.sent(),v=0,E=p.data,y.label=9;case 9:return v<E.length?(m=E[v],[4,Tn(m)]):[3,13];case 10:return[4,y.sent()];case 11:y.sent(),y.label=12;case 12:return v++,[3,9];case 13:return[3,7];case 14:return[2]}})})}function Hn(e){e&&"page"in e&&console.warn("Passing a `page` query param on paged iterators has no effect: use the `perPage` option instead.")}var io=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))},Om="__ARRAY_INDEX__";function YS(e){return e.reduce(function(t,n,r){return r===0?n:n===Om?"".concat(t,"[]"):"".concat(t,"[").concat(n,"]")},"")}function KS(e){if(typeof e=="number"||typeof e=="string")return e.toString();if(e===!0)return"true";if(e===!1)return"false";throw"Don't know how to serialize param value ".concat(JSON.stringify(e))}function Qu(e,t){t===void 0&&(t=[]);var n=[];if(typeof e=="number"||typeof e=="string"||typeof e=="boolean")n.push([YS(t),KS(e)]);else if(typeof e=="object"){if(Array.isArray(e))for(var r=0,i=e;r<i.length;r++)for(var o=i[r],a=0,u=Qu(o,io(io([],t,!0),[Om],!1));a<u.length;a++){var l=u[a];n.push(l)}else if(e)for(var s=0,c=Object.entries(e);s<c.length;s++)for(var d=c[s],f=d[0],o=d[1],h=0,p=Qu(o,io(io([],t,!0),[f],!1));h<p.length;h++){var l=p[h];n.push(l)}}return n}var Ft=function(){return Ft=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},Ft.apply(this,arguments)},QS=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},XS=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},JS=typeof window<"u"&&typeof window.document<"u",ZS=5,it;(function(e){e[e.NONE=0]="NONE",e[e.BASIC=1]="BASIC",e[e.BODY=2]="BODY",e[e.BODY_AND_HEADERS=3]="BODY_AND_HEADERS"})(it||(it={}));function eE(e){var t={};return e.forEach(function(n,r){t[r]=n}),t}function rd(e,t,n,r,i,o,a){return{request:{url:t,method:e,headers:n,body:r},response:{status:i.status,statusText:i.statusText,headers:eE(i.headers),body:o},preCallStack:a}}function tE(e,t,n,r,i){return{request:{url:t,method:e,headers:n,body:r},preCallStack:i}}function nE(e,t,n,r,i,o,a){return{request:{url:t,method:e,headers:n,body:r},response:{status:i,statusText:"N/A",headers:{},body:o},preCallStack:a}}function rE(e){return typeof e=="object"&&!!e&&"code"in e}function iE(e){return Object.fromEntries(Object.entries(e).map(function(t){var n=t[0],r=t[1];return[n.toLowerCase(),r]}))}var id=1;function Oo(e){var t;return QS(this,void 0,void 0,function(){var n,r,i,o,a,u,l,s,c,d,f,h,p,v,E,m,j,V,y,g,w,O,b,x,P,R,j,V,q,U,ee,X,K,re;return XS(this,function(I){switch(I.label){case 0:if(n=id,id+=1,r=e.fetchFn||(typeof fetch>"u"?void 0:fetch)||(typeof globalThis>"u"?void 0:globalThis.fetch),typeof r>"u")throw new Error("fetch() is not available: either polyfill it globally, or provide it as fetchFn option.");if(i=e.preCallStack,o=e.userAgent||"@datocms/rest-client-utils",a=e.retryCount||1,u=e.logLevel||it.NONE,l="autoRetry"in e?e.autoRetry:!0,s=e.logFn||function(){return!0},c=Ft({"content-type":"application/json",accept:"application/json",authorization:"Bearer ".concat(e.apiToken),"user-agent":o},e.extraHeaders?iE(e.extraHeaders):{}),JS&&delete c["user-agent"],d=e.baseUrl.replace(/\/$/,""),f=e.body?JSON.stringify(e.body,null,2):void 0,h=e.queryParams&&Object.keys(e.queryParams).length>0?"?".concat(new URLSearchParams(Qu(e.queryParams)).toString()):"",p="".concat(d).concat(e.url).concat(h),u>=it.BASIC){if(s("[".concat(n,"] ").concat(e.method," ").concat(p)),u>=it.BODY_AND_HEADERS)for(v=0,E=Object.entries(c||{});v<E.length;v++)m=E[v],j=m[0],V=m[1],s("[".concat(n,"] ").concat(j,": ").concat(V));u>=it.BODY&&f&&s("[".concat(n,"] ").concat(f))}I.label=1;case 1:return I.trys.push([1,12,,16]),y=Ka(r(p,{method:e.method,headers:c,body:f})),g=setTimeout(function(){y.cancel()},e.requestTimeout||3e4),[4,y];case 2:if(w=I.sent(),clearTimeout(g),O=w.headers.get("Content-Type"),b=O&&!O.includes("application/json"),!(w.status===429||b))return[3,4];if(!l||b&&e.method!=="GET")throw new oi(rd(e.method,p,c,e.body,w,void 0,i));return x=w.headers.has("X-RateLimit-Reset")?Number.parseInt(w.headers.get("X-RateLimit-Reset"),10):a,u>=it.BASIC&&(w.status===429?s("[".concat(n,"] Rate limit exceeded, wait ").concat(x," seconds then retry...")):s("[".concat(n,'] Invalid response content type "').concat(O,'" (status ').concat(w.status,"). Wait ").concat(x," seconds then retry..."))),[4,bo(x*1e3)];case 3:return I.sent(),[2,Oo(Ft(Ft({},e),{retryCount:a+1}))];case 4:if(u>=it.BASIC&&(s("[".concat(n,"] Status: ").concat(w.status," (").concat(w.statusText,")")),u>=it.BODY_AND_HEADERS))for(P=0,R=["x-api-version","x-environment","x-queue-time","x-ratelimit-remaining","x-request-id","cf-ray"];P<R.length;P++)j=R[P],V=w.headers.get(j),V&&s("[".concat(n,"] ").concat(j,": ").concat(V));return w.status!==204?[3,5]:(U=void 0,[3,7]);case 5:return[4,w.json()];case 6:U=I.sent(),I.label=7;case 7:return q=U,u>=it.BODY&&q&&s("[".concat(n,"] ").concat(JSON.stringify(q,null,2))),w.status!==202?[3,9]:[4,e.fetchJobResult(q.data.id)];case 8:if(ee=I.sent(),ee.status<200||ee.status>=300)throw new oi(nE(e.method,p,c,e.body,ee.status,ee.payload,i));q=ee.payload,I.label=9;case 9:return w.status>=200&&w.status<300?[2,q]:(X=new oi(rd(e.method,p,c,e.body,w,q,i)),K=(t=X.errors.find(function(D){return D.attributes.transient}))===null||t===void 0?void 0:t.attributes.code,l&&K?(u>=it.BASIC&&s("[".concat(n,"] ").concat(K,", wait ").concat(a," seconds then retry...")),[4,bo(a*1e3)]):[3,11]);case 10:return I.sent(),[2,Oo(Ft(Ft({},e),{retryCount:a+1}))];case 11:throw X;case 12:return re=I.sent(),re instanceof Ya||rE(re)&&re.code.includes("ETIMEDOUT")?l&&a<ZS?(u>=it.BASIC&&s("[".concat(n,"] Timeout error, wait ").concat(a," seconds then retry...")),[4,bo(a*1e3)]):[3,14]:[3,15];case 13:return I.sent(),[2,Oo(Ft(Ft({},e),{retryCount:a+1}))];case 14:throw new jS(tE(e.method,p,c,e.body,i));case 15:throw re;case 16:return[2]}})})}var bn=function(){return bn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},bn.apply(this,arguments)},oE=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function Co(e){return typeof e=="object"&&!!e&&"id"in e&&"type"in e}function Rs(e){return Array.isArray(e)&&e.every(Co)}function M(e,t){if(typeof e!="object"||!e)throw new Error("Invalid body!");if(Array.isArray(e))return{data:e.map(function(P){var R;return(R=M(P,t))===null||R===void 0?void 0:R.data})};var n=e,r=n.id,i=n.type,o=n.meta,a=oE(n,["id","type","meta"]),u={},l={};if(t.attributes==="*")for(var s=0,c=Object.entries(a);s<c.length;s++){var d=c[s],f=d[0],h=d[1];if(t.relationships.includes(f))if(Co(h)){var p=h.id,v=h.type;l[f]={data:{id:p,type:v}}}else Rs(h)?l[f]={data:h.map(function(P){var R=P.id,j=P.type;return{id:R,type:j}})}:l[f]={data:null};else u[f]=h}else if(t.relationships==="*")for(var E=0,m=Object.entries(a);E<m.length;E++){var y=m[E],f=y[0],h=y[1];if(t.attributes.includes(f))u[f]=h;else if(Co(h)){var g=h.id,v=h.type;l[f]={data:{id:g,type:v}}}else Rs(h)?l[f]={data:h.map(function(j){var V=j.id,q=j.type;return{id:V,type:q}})}:l[f]={data:null}}else{for(var w=0,O=Object.entries(a);w<O.length;w++){var b=O[w],f=b[0],h=b[1];if(t.attributes.includes(f))u[f]=h;else if(t.relationships.includes(f))if(Co(h)){var x=h.id,v=h.type;l[f]={data:{id:x,type:v}}}else Rs(h)?l[f]={data:h.map(function(j){var V=j.id,q=j.type;return{id:V,type:q}})}:l[f]={data:null}}t.attributes.includes("type")&&(u.type=i)}return{data:bn(bn(bn(bn(bn({},r||t.id?{id:r||t.id}:{}),{type:t.type}),Object.keys(u).length>0?{attributes:u}:{}),Object.keys(l).length>0?{relationships:l}:{}),o?{meta:o}:{})}}function C(e){return typeof e=="string"?e:e.id}var B=function(){function e(t){this.client=t}return e}(),aE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),sE=function(e){aE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"role",attributes:["name","can_edit_favicon","can_edit_site","can_edit_schema","can_manage_menu","can_edit_environment","can_promote_environments","environments_access","can_manage_users","can_manage_shared_filters","can_manage_upload_collections","can_manage_build_triggers","can_manage_webhooks","can_manage_environments","can_manage_sso","can_access_audit_log","can_manage_workflows","can_manage_access_tokens","can_perform_site_search","can_access_build_events_log","positive_item_type_permissions","negative_item_type_permissions","positive_upload_permissions","negative_upload_permissions","positive_build_trigger_permissions","negative_build_trigger_permissions"],relationships:["inherits_permissions_from"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/roles",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"role",attributes:["name","can_edit_favicon","can_edit_site","can_edit_schema","can_manage_menu","can_edit_environment","can_promote_environments","environments_access","can_manage_users","can_manage_shared_filters","can_manage_upload_collections","can_manage_build_triggers","can_manage_webhooks","can_manage_environments","can_manage_sso","can_access_audit_log","can_manage_workflows","can_manage_access_tokens","can_perform_site_search","can_access_build_events_log","positive_item_type_permissions","negative_item_type_permissions","positive_upload_permissions","negative_upload_permissions","positive_build_trigger_permissions","negative_build_trigger_permissions"],relationships:["inherits_permissions_from"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/roles/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/roles"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/roles/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/roles/".concat(n)})},t.prototype.duplicate=function(n){return this.rawDuplicate(C(n)).then(function(r){return S(r)})},t.prototype.rawDuplicate=function(n){return this.client.request({method:"POST",url:"/roles/".concat(n,"/duplicate")})},t.TYPE="role",t}(B),uE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),jn=function(){return jn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},jn.apply(this,arguments)},lE=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},cE=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},od=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))};function ad(e,t){return e==null&&t==null?!0:e===t}function fE(e,t){for(var n in e)if(!ad(e[n],t[n]))return!1;for(var n in t)if(!ad(e[n],t[n]))return!1;return!0}function oo(e,t,n,r){if(!t)return e;var i=t.add,o=t.remove;return od(od([],o?o.reduce(function(a,u){var l=jn(jn({},u),{environment:n}),s=a.find(function(c){return fE(c,l)});if(!s)throw new Error("Cannot find rule ".concat(JSON.stringify(l)," to remove in ").concat(r,"!"));return a.filter(function(c){return c!==s})},e):e,!0),i?i.map(function(a){return jn({environment:n},a)}):[],!0)}var dE=function(e){uE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.updateCurrentEnvironmentPermissions=function(n,r){return lE(this,void 0,void 0,function(){var i,o,a,u,l,s;return cE(this,function(c){switch(c.label){case 0:return o=this.client.config.environment,o?[3,2]:[4,this.client.environments.list()];case 1:o=c.sent().find(function(d){return d.meta.primary}).id,c.label=2;case 2:return i=o,[4,this.find(n)];case 3:return a=c.sent(),u=!!(r.positive_item_type_permissions||r.negative_item_type_permissions),l=!!(r.positive_upload_permissions||r.negative_upload_permissions),s=jn(jn({},u?{positive_item_type_permissions:oo(a.positive_item_type_permissions,r.positive_item_type_permissions,i,"positive_item_type_permissions"),negative_item_type_permissions:oo(a.negative_item_type_permissions,r.negative_item_type_permissions,i,"negative_item_type_permissions")}:{}),l?{positive_upload_permissions:oo(a.positive_upload_permissions,r.positive_upload_permissions,i,"positive_upload_permissions"),negative_upload_permissions:oo(a.negative_upload_permissions,r.negative_upload_permissions,i,"negative_upload_permissions")}:{}),[2,this.update(n,s)]}})})},t}(sE),pE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),hE=function(e){pE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"user",attributes:["is_active"],relationships:["role"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/users/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/users"})},t.prototype.find=function(n,r){return this.rawFind(C(n),r).then(function(i){return S(i)})},t.prototype.rawFind=function(n,r){return this.client.request({method:"GET",url:"/users/".concat(n),queryParams:r})},t.prototype.findMe=function(n){return this.rawFindMe(n).then(function(r){return S(r)})},t.prototype.rawFindMe=function(n){return this.client.request({method:"GET",url:"/users/me",queryParams:n})},t.prototype.destroy=function(n,r){return this.rawDestroy(C(n),r).then(function(i){return S(i)})},t.prototype.rawDestroy=function(n,r){return this.client.request({method:"DELETE",url:"/users/".concat(n),queryParams:r})},t.TYPE="user",t}(B),mE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),yE=function(e){mE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/sso-users"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/sso-users/".concat(n)})},t.prototype.copyUsers=function(){return this.rawCopyUsers().then(function(n){return S(n)})},t.prototype.rawCopyUsers=function(){return this.client.request({method:"POST",url:"/sso-users/copy-users"})},t.prototype.destroy=function(n,r){return this.rawDestroy(C(n),r).then(function(i){return S(i)})},t.prototype.rawDestroy=function(n,r){return this.client.request({method:"DELETE",url:"/sso-users/".concat(n),queryParams:r})},t.TYPE="sso_user",t}(B),vE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),gE=function(e){vE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.query=function(n){return this.rawQuery(M(n,{type:"audit_log_query",attributes:["filter","next_token","detailed_log"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawQuery=function(n){return this.client.request({method:"POST",url:"/audit-log-events/query",body:n})},t.TYPE="audit_log_event",t}(B),_E=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),wE=function(e){_E(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"menu_item",attributes:["label","external_url","position","open_in_new_tab"],relationships:["item_type","item_type_filter","parent"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/menu-items",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"menu_item",attributes:["label","external_url","position","open_in_new_tab"],relationships:["item_type","item_type_filter","parent"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/menu-items/".concat(n),body:r})},t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/menu-items",queryParams:n})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/menu-items/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/menu-items/".concat(n)})},t.prototype.reorder=function(n){return this.rawReorder(M(n,{type:"menu_item",attributes:["position"],relationships:["parent"]})).then(function(r){return S(r)})},t.prototype.rawReorder=function(n){return this.client.request({method:"POST",url:"/menu-items/reorder",body:n})},t.TYPE="menu_item",t}(B),SE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),EE=function(e){SE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"schema_menu_item",attributes:["label","position","kind"],relationships:["item_type","parent"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/schema-menu-items",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"schema_menu_item",attributes:["label","position","kind"],relationships:["item_type","parent","children"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/schema-menu-items/".concat(n),body:r})},t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/schema-menu-items",queryParams:n})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/schema-menu-items/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/schema-menu-items/".concat(n)})},t.prototype.reorder=function(n){return this.rawReorder(M(n,{type:"schema_menu_item",attributes:["position"],relationships:["parent"]})).then(function(r){return S(r)})},t.prototype.rawReorder=function(n){return this.client.request({method:"POST",url:"/schema-menu-items/reorder",body:n})},t.TYPE="schema_menu_item",t}(B),xE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),bE=function(e){xE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"upload_collection",attributes:["label","position"],relationships:["parent"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/upload-collections",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"upload_collection",attributes:["label","position"],relationships:["parent","children"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/upload-collections/".concat(n),body:r})},t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/upload-collections",queryParams:n})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/upload-collections/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/upload-collections/".concat(n)})},t.prototype.reorder=function(n){return this.rawReorder(M(n,{type:"upload_collection",attributes:["position"],relationships:["parent"]})).then(function(r){return S(r)})},t.prototype.rawReorder=function(n){return this.client.request({method:"POST",url:"/upload-collections/reorder",body:n})},t.TYPE="upload_collection",t}(B),OE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),CE=function(e){OE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(M(n,{type:"item_type",attributes:["name","api_key","singleton","all_locales_required","sortable","modular_block","draft_mode_active","draft_saving_active","tree","ordering_direction","ordering_meta","collection_appeareance","collection_appearance","hint","inverse_relationships_enabled"],relationships:["ordering_field","presentation_title_field","presentation_image_field","title_field","image_preview_field","excerpt_field","workflow"]}),r).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/item-types",body:n,queryParams:r})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"item_type",attributes:["name","api_key","collection_appeareance","collection_appearance","singleton","all_locales_required","sortable","modular_block","draft_mode_active","draft_saving_active","tree","ordering_direction","ordering_meta","has_singleton_item","hint","inverse_relationships_enabled"],relationships:["ordering_field","presentation_title_field","presentation_image_field","title_field","image_preview_field","excerpt_field","workflow"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/item-types/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/item-types"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/item-types/".concat(n)})},t.prototype.duplicate=function(n){return this.rawDuplicate(C(n)).then(function(r){return S(r)})},t.prototype.rawDuplicate=function(n){return this.client.request({method:"POST",url:"/item-types/".concat(n,"/duplicate")})},t.prototype.destroy=function(n,r){return this.rawDestroy(C(n),r).then(function(i){return S(i)})},t.prototype.rawDestroy=function(n,r){return this.client.request({method:"DELETE",url:"/item-types/".concat(n),queryParams:r})},t.prototype.rawReorderFieldsAndFieldsets=function(n,r){return this.client.request({method:"POST",url:"/item-types/".concat(n,"/reorder-fields-and-fieldsets"),body:r})},t.TYPE="item_type",t}(B),PE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),TE=function(e){PE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(C(n),M(r,{type:"field",attributes:["label","field_type","api_key","localized","validators","appeareance","appearance","position","hint","default_value","deep_filtering_enabled"],relationships:["fieldset"]})).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/item-types/".concat(n,"/fields"),body:r})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"field",attributes:["default_value","label","api_key","localized","validators","appeareance","appearance","position","field_type","hint","deep_filtering_enabled"],relationships:["fieldset"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/fields/".concat(n),body:r})},t.prototype.list=function(n){return this.rawList(C(n)).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/item-types/".concat(n,"/fields")})},t.prototype.referencing=function(n){return this.rawReferencing(C(n)).then(function(r){return S(r)})},t.prototype.rawReferencing=function(n){return this.client.request({method:"GET",url:"/item-types/".concat(n,"/fields/referencing")})},t.prototype.related=function(n){return this.rawRelated(C(n)).then(function(r){return S(r)})},t.prototype.rawRelated=function(n){return this.client.request({method:"GET",url:"/item-types/".concat(n,"/fields/related")})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/fields/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/fields/".concat(n)})},t.prototype.duplicate=function(n){return this.rawDuplicate(C(n)).then(function(r){return S(r)})},t.prototype.rawDuplicate=function(n){return this.client.request({method:"POST",url:"/fields/".concat(n,"/duplicate")})},t.TYPE="field",t}(B),kE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),IE=function(e){kE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(C(n),M(r,{type:"fieldset",attributes:["title","hint","position","collapsible","start_collapsed"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/item-types/".concat(n,"/fieldsets"),body:r})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"fieldset",attributes:["title","hint","position","collapsible","start_collapsed"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/fieldsets/".concat(n),body:r})},t.prototype.list=function(n){return this.rawList(C(n)).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/item-types/".concat(n,"/fieldsets")})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/fieldsets/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/fieldsets/".concat(n)})},t.TYPE="fieldset",t}(B),LE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),jE=function(e){LE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"email_credentials",attributes:["email","password","otp_code"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/sessions",body:n})},t.TYPE="session",t}(B),RE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),NE=function(e){RE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"access_token",attributes:["name","can_access_cda","can_access_cda_preview","can_access_cma"],relationships:["role"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/access_tokens",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"access_token",attributes:["name","can_access_cda","can_access_cda_preview","can_access_cma"],relationships:["role"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/access_tokens/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/access_tokens"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/access_tokens/".concat(n)})},t.prototype.regenerateToken=function(n){return this.rawRegenerateToken(C(n)).then(function(r){return S(r)})},t.prototype.rawRegenerateToken=function(n){return this.client.request({method:"POST",url:"/access_tokens/".concat(n,"/regenerate_token")})},t.prototype.destroy=function(n,r){return this.rawDestroy(C(n),r).then(function(i){return S(i)})},t.prototype.rawDestroy=function(n,r){return this.client.request({method:"DELETE",url:"/access_tokens/".concat(n),queryParams:r})},t.TYPE="access_token",t}(B),FE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ME=function(e){FE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"plugin",attributes:["package_name","name","description","url","permissions","plugin_type","field_types","parameter_definitions","package_version"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/plugins",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"plugin",attributes:["name","description","url","parameters","package_version","permissions"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/plugins/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/plugins"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/plugins/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/plugins/".concat(n)})},t.prototype.fields=function(n){return this.rawFields(C(n)).then(function(r){return S(r)})},t.prototype.rawFields=function(n){return this.client.request({method:"GET",url:"/plugins/".concat(n,"/fields")})},t.TYPE="plugin",t}(B),DE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),AE=function(e){DE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/job-results/".concat(n)})},t.TYPE="job_result",t}(B),zE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),$E=function(e){zE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/subscription-limits"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/subscription-limits/".concat(n)})},t.TYPE="subscription_limit",t}(B),VE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),UE=function(e){VE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/subscription-features"})},t.TYPE="subscription_feature",t}(B),qE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),BE=function(e){qE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/build-events"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/build-events/".concat(n)})},t.TYPE="build_event",t}(B),HE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),sa=function(){return sa=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},sa.apply(this,arguments)},GE=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},WE=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},hr=function(e){return this instanceof hr?(this.v=e,this):new hr(e)},YE=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof hr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},KE=function(e){HE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/items",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return YE(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return GE(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=WE(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,hr(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,hr(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,hr(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:30,maxLimit:500},function(o){return i.rawList(sa(sa({},n),{page:o}))},r)},t.prototype.validateExisting=function(n,r){return this.rawValidateExisting(C(n),M(r,{id:C(n),type:"item",attributes:"*",relationships:["item_type","creator"]}))},t.prototype.rawValidateExisting=function(n,r){return this.client.request({method:"POST",url:"/items/".concat(n,"/validate"),body:r})},t.prototype.validateNew=function(n){return this.rawValidateNew(M(n,{type:"item",attributes:"*",relationships:["item_type","creator"]}))},t.prototype.rawValidateNew=function(n){return this.client.request({method:"POST",url:"/items/validate",body:n})},t.prototype.create=function(n){return this.rawCreate(M(n,{type:"item",attributes:"*",relationships:["item_type","creator"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/items",body:n})},t.prototype.duplicate=function(n){return this.rawDuplicate(C(n)).then(function(r){return S(r)})},t.prototype.rawDuplicate=function(n){return this.client.request({method:"POST",url:"/items/".concat(n,"/duplicate")})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"item",attributes:"*",relationships:["item_type","creator"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/items/".concat(n),body:r})},t.prototype.references=function(n,r){return this.rawReferences(C(n),r).then(function(i){return S(i)})},t.prototype.rawReferences=function(n,r){return this.client.request({method:"GET",url:"/items/".concat(n,"/references"),queryParams:r})},t.prototype.find=function(n,r){return this.rawFind(C(n),r).then(function(i){return S(i)})},t.prototype.rawFind=function(n,r){return this.client.request({method:"GET",url:"/items/".concat(n),queryParams:r})},t.prototype.currentVsPublishedState=function(n){return this.rawCurrentVsPublishedState(C(n)).then(function(r){return S(r)})},t.prototype.rawCurrentVsPublishedState=function(n){return this.client.request({method:"GET",url:"/items/".concat(n,"/current-vs-published-state")})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/items/".concat(n)})},t.prototype.batchDestroy=function(n){return this.rawBatchDestroy(n).then(function(r){return S(r)})},t.prototype.rawBatchDestroy=function(n){return this.client.request({method:"DELETE",url:"/items",queryParams:n})},t.prototype.batchPublish=function(n){return this.rawBatchPublish(n).then(function(r){return S(r)})},t.prototype.rawBatchPublish=function(n){return this.client.request({method:"PUT",url:"/items/publish",queryParams:n})},t.prototype.batchUnpublish=function(n){return this.rawBatchUnpublish(n).then(function(r){return S(r)})},t.prototype.rawBatchUnpublish=function(n){return this.client.request({method:"PUT",url:"/items/unpublish",queryParams:n})},t.prototype.publish=function(n,r,i){return this.rawPublish(C(n),r?M(r,{type:"selective_publish_operation",attributes:["content_in_locales","non_localized_content"],relationships:[]}):null,i).then(function(o){return S(o)})},t.prototype.rawPublish=function(n,r,i){return this.client.request({method:"PUT",url:"/items/".concat(n,"/publish"),body:r,queryParams:i})},t.prototype.unpublish=function(n,r,i){return this.rawUnpublish(C(n),r?M(r,{type:"selective_unpublish_operation",attributes:["content_in_locales"],relationships:[]}):null,i).then(function(o){return S(o)})},t.prototype.rawUnpublish=function(n,r,i){return this.client.request({method:"PUT",url:"/items/".concat(n,"/unpublish"),body:r,queryParams:i})},t.prototype.bulkPublish=function(n){return this.rawBulkPublish(M(n,{type:"item_bulk_publish_operation",attributes:[],relationships:["items"]})).then(function(r){return S(r)})},t.prototype.rawBulkPublish=function(n){return this.client.request({method:"POST",url:"/items/bulk/publish",body:n})},t.prototype.bulkUnpublish=function(n){return this.rawBulkUnpublish(M(n,{type:"item_bulk_unpublish_operation",attributes:[],relationships:["items"]})).then(function(r){return S(r)})},t.prototype.rawBulkUnpublish=function(n){return this.client.request({method:"POST",url:"/items/bulk/unpublish",body:n})},t.prototype.bulkDestroy=function(n){return this.rawBulkDestroy(M(n,{type:"item_bulk_destroy_operation",attributes:[],relationships:["items"]})).then(function(r){return S(r)})},t.prototype.rawBulkDestroy=function(n){return this.client.request({method:"POST",url:"/items/bulk/destroy",body:n})},t.prototype.bulkMoveToStage=function(n){return this.rawBulkMoveToStage(M(n,{type:"item_bulk_move_to_stage_operation",attributes:["stage"],relationships:["items"]})).then(function(r){return S(r)})},t.prototype.rawBulkMoveToStage=function(n){return this.client.request({method:"POST",url:"/items/bulk/move-to-stage",body:n})},t.TYPE="item",t}(B),QE=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ua=function(){return ua=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ua.apply(this,arguments)},XE=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},JE=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},mr=function(e){return this instanceof mr?(this.v=e,this):new mr(e)},ZE=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof mr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},ex=function(e){QE(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.restore=function(n){return this.rawRestore(C(n)).then(function(r){return S(r)})},t.prototype.rawRestore=function(n){return this.client.request({method:"POST",url:"/versions/".concat(n,"/restore")})},t.prototype.list=function(n,r){return this.rawList(C(n),r).then(function(i){return S(i)})},t.prototype.rawList=function(n,r){return this.client.request({method:"GET",url:"/items/".concat(n,"/versions"),queryParams:r})},t.prototype.listPagedIterator=function(n,r,i){return ZE(this,arguments,function(){var a,u,l,s,c,d,f,h,p;return XE(this,function(v){switch(v.label){case 0:v.trys.push([0,9,10,15]),a=!0,u=JE(this.rawListPagedIterator(C(n),r,i)),v.label=1;case 1:return[4,mr(u.next())];case 2:if(l=v.sent(),d=l.done,!!d)return[3,8];p=l.value,a=!1,v.label=3;case 3:return v.trys.push([3,,6,7]),s=p,[4,mr(Gt(s))];case 4:return[4,v.sent()];case 5:return v.sent(),[3,7];case 6:return a=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return c=v.sent(),f={error:c},[3,15];case 10:return v.trys.push([10,,13,14]),!a&&!d&&(h=u.return)?[4,mr(h.call(u))]:[3,12];case 11:v.sent(),v.label=12;case 12:return[3,14];case 13:if(f)throw f.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r,i){var o=this;return Hn(r),Bn({defaultLimit:15,maxLimit:50},function(a){return o.rawList(n,ua(ua({},r),{page:a}))},i)},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/versions/".concat(n)})},t.TYPE="item_version",t}(B),tx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),la=function(){return la=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},la.apply(this,arguments)},nx=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},rx=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},yr=function(e){return this instanceof yr?(this.v=e,this):new yr(e)},ix=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof yr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},Cm=function(e){tx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"upload",attributes:["path","copyright","author","notes","default_field_metadata","tags"],relationships:["upload_collection"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/uploads",body:n})},t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/uploads",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return ix(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return nx(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=rx(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,yr(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,yr(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,yr(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:30,maxLimit:500},function(o){return i.rawList(la(la({},n),{page:o}))},r)},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/uploads/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/uploads/".concat(n)})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"upload",attributes:["path","basename","copyright","author","notes","tags","default_field_metadata"],relationships:["creator","upload_collection"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/uploads/".concat(n),body:r})},t.prototype.batchAddTags=function(n,r){return this.rawBatchAddTags(M(n,{type:"upload",attributes:["tags"],relationships:[]}),r).then(function(i){return S(i)})},t.prototype.rawBatchAddTags=function(n,r){return this.client.request({method:"PUT",url:"/uploads/batch-add-tags",body:n,queryParams:r})},t.prototype.batchDestroy=function(n){return this.rawBatchDestroy(n).then(function(r){return S(r)})},t.prototype.rawBatchDestroy=function(n){return this.client.request({method:"DELETE",url:"/uploads/batch-destroy",queryParams:n})},t.prototype.references=function(n,r){return this.rawReferences(C(n),r).then(function(i){return S(i)})},t.prototype.rawReferences=function(n,r){return this.client.request({method:"GET",url:"/uploads/".concat(n,"/references"),queryParams:r})},t.prototype.bulkTag=function(n){return this.rawBulkTag(M(n,{type:"upload_bulk_tag_operation",attributes:["tags"],relationships:["uploads"]})).then(function(r){return S(r)})},t.prototype.rawBulkTag=function(n){return this.client.request({method:"POST",url:"/uploads/bulk/tag",body:n})},t.prototype.bulkSetUploadCollection=function(n){return this.rawBulkSetUploadCollection(M(n,{type:"upload_bulk_set_upload_collection_operation",attributes:[],relationships:["upload_collection","uploads"]})).then(function(r){return S(r)})},t.prototype.rawBulkSetUploadCollection=function(n){return this.client.request({method:"POST",url:"/uploads/bulk/set-upload-collection",body:n})},t.prototype.bulkDestroy=function(n){return this.rawBulkDestroy(M(n,{type:"upload_bulk_destroy_operation",attributes:[],relationships:["uploads"]})).then(function(r){return S(r)})},t.prototype.rawBulkDestroy=function(n){return this.client.request({method:"POST",url:"/uploads/bulk/destroy",body:n})},t.TYPE="upload",t}(B),ox=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ax=function(e){ox(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"upload_request",attributes:["filename"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/upload-requests",body:n})},t.TYPE="upload_request",t}(B),sx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ux=function(e){sx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(C(n),M(r,{type:"upload_track",attributes:["url_or_upload_request_id","type","name","language_code","closed_captions"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/uploads/".concat(n,"/tracks"),body:r})},t.prototype.list=function(n){return this.rawList(C(n)).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/uploads/".concat(n,"/tracks")})},t.prototype.destroy=function(n,r){return this.rawDestroy(C(n),C(r)).then(function(i){return S(i)})},t.prototype.rawDestroy=function(n,r){return this.client.request({method:"DELETE",url:"/uploads/".concat(n,"/tracks/").concat(r)})},t.prototype.generateSubtitles=function(n,r){return this.rawGenerateSubtitles(C(n),M(r,{type:"upload_track",attributes:["name","language_code"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawGenerateSubtitles=function(n,r){return this.client.request({method:"POST",url:"/uploads/".concat(n,"/tracks/generate-subtitles"),body:r})},t.TYPE="upload_track",t}(B),lx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),cx=function(e){lx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(C(n),M(r,{type:"scheduled_publication",attributes:["publication_scheduled_at","selective_publication"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/items/".concat(n,"/scheduled-publication"),body:r})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/items/".concat(n,"/scheduled-publication")})},t.TYPE="scheduled_publication",t}(B),fx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),dx=function(e){fx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n,r){return this.rawCreate(C(n),M(r,{type:"scheduled_unpublishing",attributes:["unpublishing_scheduled_at","content_in_locales"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawCreate=function(n,r){return this.client.request({method:"POST",url:"/items/".concat(n,"/scheduled-unpublishing"),body:r})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/items/".concat(n,"/scheduled-unpublishing")})},t.TYPE="scheduled_unpublishing",t}(B),px=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ca=function(){return ca=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ca.apply(this,arguments)},hx=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},mx=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},vr=function(e){return this instanceof vr?(this.v=e,this):new vr(e)},yx=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof vr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},vx=function(e){px(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/search-results",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return yx(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return hx(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=mx(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,vr(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,vr(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,vr(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:20,maxLimit:100},function(o){return i.rawList(ca(ca({},n),{page:o}))},r)},t.TYPE="search_result",t}(B),gx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),_x=function(e){gx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.fork=function(n,r,i){return this.rawFork(C(n),M(r,{id:C(n),type:"environment",attributes:[],relationships:[]}),i).then(function(o){return S(o)})},t.prototype.rawFork=function(n,r,i){return this.client.request({method:"POST",url:"/environments/".concat(n,"/fork"),body:r,queryParams:i})},t.prototype.promote=function(n){return this.rawPromote(C(n)).then(function(r){return S(r)})},t.prototype.rawPromote=function(n){return this.client.request({method:"PUT",url:"/environments/".concat(n,"/promote")})},t.prototype.rename=function(n,r){return this.rawRename(C(n),M(r,{id:C(n),type:"environment",attributes:[],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawRename=function(n,r){return this.client.request({method:"PUT",url:"/environments/".concat(n,"/rename"),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/environments"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/environments/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/environments/".concat(n)})},t.TYPE="environment",t}(B),wx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Sx=function(e){wx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(){return this.rawFind().then(function(n){return S(n)})},t.prototype.rawFind=function(){return this.client.request({method:"GET",url:"/maintenance-mode"})},t.prototype.activate=function(n){return this.rawActivate(n).then(function(r){return S(r)})},t.prototype.rawActivate=function(n){return this.client.request({method:"PUT",url:"/maintenance-mode/activate",queryParams:n})},t.prototype.deactivate=function(){return this.rawDeactivate().then(function(n){return S(n)})},t.prototype.rawDeactivate=function(){return this.client.request({method:"PUT",url:"/maintenance-mode/deactivate"})},t.TYPE="maintenance_mode",t}(B),Ex=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),xx=function(e){Ex(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"webhook",attributes:["name","url","custom_payload","headers","events","http_basic_user","http_basic_password","enabled","payload_api_version","nested_items_in_payload","auto_retry"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/webhooks",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"webhook",attributes:["name","url","custom_payload","headers","events","http_basic_user","http_basic_password","enabled","payload_api_version","nested_items_in_payload","auto_retry"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/webhooks/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/webhooks"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/webhooks/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/webhooks/".concat(n)})},t.TYPE="webhook",t}(B),bx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),fa=function(){return fa=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},fa.apply(this,arguments)},Ox=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},Cx=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},gr=function(e){return this instanceof gr?(this.v=e,this):new gr(e)},Px=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof gr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},Tx=function(e){bx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/webhook_calls",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return Px(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return Ox(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=Cx(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,gr(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,gr(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,gr(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:30,maxLimit:500},function(o){return i.rawList(fa(fa({},n),{page:o}))},r)},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/webhook_calls/".concat(n)})},t.prototype.resendWebhook=function(n){return this.rawResendWebhook(C(n))},t.prototype.rawResendWebhook=function(n){return this.client.request({method:"POST",url:"/webhook_calls/".concat(n,"/resend_webhook")})},t.TYPE="webhook_call",t}(B),kx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ix=function(e){kx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/build-triggers"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/build-triggers/".concat(n)})},t.prototype.create=function(n){return this.rawCreate(M(n,{type:"build_trigger",attributes:["name","webhook_token","adapter","indexing_enabled","frontend_url","autotrigger_on_scheduled_publications","adapter_settings"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/build-triggers",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"build_trigger",attributes:["name","adapter","indexing_enabled","frontend_url","autotrigger_on_scheduled_publications","adapter_settings"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/build-triggers/".concat(n),body:r})},t.prototype.trigger=function(n){return this.rawTrigger(C(n))},t.prototype.rawTrigger=function(n){return this.client.request({method:"POST",url:"/build-triggers/".concat(n,"/trigger")})},t.prototype.abort=function(n){return this.rawAbort(C(n))},t.prototype.rawAbort=function(n){return this.client.request({method:"DELETE",url:"/build-triggers/".concat(n,"/abort")})},t.prototype.abortIndexing=function(n){return this.rawAbortIndexing(C(n))},t.prototype.rawAbortIndexing=function(n){return this.client.request({method:"DELETE",url:"/build-triggers/".concat(n,"/abort_indexing")})},t.prototype.reindex=function(n){return this.rawReindex(C(n))},t.prototype.rawReindex=function(n){return this.client.request({method:"PUT",url:"/build-triggers/".concat(n,"/reindex")})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/build-triggers/".concat(n)})},t.TYPE="build_trigger",t}(B),Lx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),jx=function(e){Lx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"item_type_filter",attributes:["name","filter","columns","order_by","shared"],relationships:["item_type"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/item-type-filters",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"item_type_filter",attributes:["name","columns","order_by","shared","filter"],relationships:["item_type"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/item-type-filters/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/item-type-filters"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/item-type-filters/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/item-type-filters/".concat(n)})},t.TYPE="item_type_filter",t}(B),Rx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Nx=function(e){Rx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"upload_filter",attributes:["name","filter","shared"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/upload-filters",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"upload_filter",attributes:["name","shared","filter"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/upload-filters/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/upload-filters"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/upload-filters/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/upload-filters/".concat(n)})},t.TYPE="upload_filter",t}(B),Fx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Mx=function(e){Fx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"site_invitation",attributes:["email"],relationships:["role"]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/site-invitations",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"site_invitation",attributes:[],relationships:["role"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/site-invitations/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/site-invitations"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/site-invitations/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/site-invitations/".concat(n)})},t.prototype.resend=function(n){return this.rawResend(C(n)).then(function(r){return S(r)})},t.prototype.rawResend=function(n){return this.client.request({method:"POST",url:"/site-invitations/".concat(n,"/resend")})},t.TYPE="site_invitation",t}(B),Dx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ax=function(e){Dx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/editing-sessions"})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/editing-sessions/".concat(n),body:r})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/editing-sessions/".concat(n)})},t.TYPE="editing_session",t}(B),zx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),$x=function(e){zx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/sso-groups"})},t.prototype.copyRoles=function(n){return this.rawCopyRoles(C(n)).then(function(r){return S(r)})},t.prototype.rawCopyRoles=function(n){return this.client.request({method:"POST",url:"/sso-groups/".concat(n,"/copy-roles")})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"sso_group",attributes:["priority"],relationships:["role"]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/sso-groups/".concat(n),body:r})},t.prototype.destroy=function(n){return this.rawDestroy(C(n)).then(function(r){return S(r)})},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/sso-groups/".concat(n)})},t.TYPE="sso_group",t}(B),Vx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ux=function(e){Vx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(){return this.rawFind().then(function(n){return S(n)})},t.prototype.rawFind=function(){return this.client.request({method:"GET",url:"/sso-settings"})},t.prototype.generateToken=function(){return this.rawGenerateToken().then(function(n){return S(n)})},t.prototype.rawGenerateToken=function(){return this.client.request({method:"PUT",url:"/sso-settings/generate-token"})},t.prototype.update=function(n){return this.rawUpdate(M(n,{type:"sso_settings",attributes:["idp_saml_metadata_url","idp_saml_metadata_xml"],relationships:["default_role"]})).then(function(r){return S(r)})},t.prototype.rawUpdate=function(n){return this.client.request({method:"PUT",url:"/sso-settings",body:n})},t.TYPE="sso_settings",t}(B),qx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Bx=function(e){qx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(n){return this.rawFind(n).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/emoji-suggestions",queryParams:n})},t.TYPE="emoji_suggestions",t}(B),Hx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Gx=function(e){Hx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(){return this.rawFind().then(function(n){return S(n)})},t.prototype.rawFind=function(){return this.client.request({method:"GET",url:"/white-label-settings"})},t.prototype.update=function(n){return this.rawUpdate(M(n,{type:"white_label_settings",attributes:["custom_i18n_messages_template_url"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawUpdate=function(n){return this.client.request({method:"PUT",url:"/white-label-settings",body:n})},t.TYPE="white_label_settings",t}(B),Wx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Yx=function(e){Wx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(){return this.rawFind().then(function(n){return S(n)})},t.prototype.rawFind=function(){return this.client.request({method:"GET",url:"/public-info"})},t.TYPE="public_info",t}(B),Kx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Qx=function(e){Kx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/daily-site-usages"})},t.TYPE="daily_usage",t}(B),Xx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Jx=function(e){Xx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(n,r){return this.rawFind(C(n),r).then(function(i){return S(i)})},t.prototype.rawFind=function(n,r){return this.client.request({method:"GET",url:"/usage-log-counters/".concat(n),queryParams:r})},t.TYPE="usage_counter",t}(B),Zx=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),da=function(){return da=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},da.apply(this,arguments)},eb=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},tb=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},_r=function(e){return this instanceof _r?(this.v=e,this):new _r(e)},nb=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof _r?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},rb=function(e){Zx(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/upload-tags",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return nb(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return eb(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=tb(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,_r(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,_r(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,_r(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:50,maxLimit:500},function(o){return i.rawList(da(da({},n),{page:o}))},r)},t.prototype.create=function(n){return this.rawCreate(M(n,{type:"upload_tag",attributes:["name"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/upload-tags",body:n})},t.TYPE="upload_tag",t}(B),ib=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),pa=function(){return pa=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},pa.apply(this,arguments)},ob=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},ab=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(u,l){a=e[o](a),i(u,l,a.done,a.value)})}}function i(o,a,u,l){Promise.resolve(l).then(function(s){o({value:s,done:u})},a)}},wr=function(e){return this instanceof wr?(this.v=e,this):new wr(e)},sb=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){r[f]&&(i[f]=function(h){return new Promise(function(p,v){o.push([f,h,p,v])>1||u(f,h)})})}function u(f,h){try{l(r[f](h))}catch(p){d(o[0][3],p)}}function l(f){f.value instanceof wr?Promise.resolve(f.value.v).then(s,c):d(o[0][2],f)}function s(f){u("next",f)}function c(f){u("throw",f)}function d(f,h){f(h),o.shift(),o.length&&u(o[0][0],o[0][1])}},ub=function(e){ib(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.list=function(n){return this.rawList(n).then(function(r){return S(r)})},t.prototype.rawList=function(n){return this.client.request({method:"GET",url:"/upload-smart-tags",queryParams:n})},t.prototype.listPagedIterator=function(n,r){return sb(this,arguments,function(){var o,a,u,l,s,c,d,f,h;return ob(this,function(p){switch(p.label){case 0:p.trys.push([0,9,10,15]),o=!0,a=ab(this.rawListPagedIterator(n,r)),p.label=1;case 1:return[4,wr(a.next())];case 2:if(u=p.sent(),c=u.done,!!c)return[3,8];h=u.value,o=!1,p.label=3;case 3:return p.trys.push([3,,6,7]),l=h,[4,wr(Gt(l))];case 4:return[4,p.sent()];case 5:return p.sent(),[3,7];case 6:return o=!0,[7];case 7:return[3,1];case 8:return[3,15];case 9:return s=p.sent(),d={error:s},[3,15];case 10:return p.trys.push([10,,13,14]),!o&&!c&&(f=a.return)?[4,wr(f.call(a))]:[3,12];case 11:p.sent(),p.label=12;case 12:return[3,14];case 13:if(d)throw d.error;return[7];case 14:return[7];case 15:return[2]}})})},t.prototype.rawListPagedIterator=function(n,r){var i=this;return Hn(n),Bn({defaultLimit:50,maxLimit:500},function(o){return i.rawList(pa(pa({},n),{page:o}))},r)},t.TYPE="upload_smart_tag",t}(B),lb=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),cb=function(e){lb(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.find=function(n){return this.rawFind(n).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/site",queryParams:n})},t.prototype.update=function(n){return this.rawUpdate(M(n,{type:"site",attributes:["no_index","favicon","global_seo","name","theme","locales","timezone","require_2fa","ip_tracking_enabled","force_use_of_sandbox_environments"],relationships:["sso_default_role"]})).then(function(r){return S(r)})},t.prototype.rawUpdate=function(n){return this.client.request({method:"PUT",url:"/site",body:n})},t.prototype.activateImprovedTimezoneManagement=function(){return this.rawActivateImprovedTimezoneManagement().then(function(n){return S(n)})},t.prototype.rawActivateImprovedTimezoneManagement=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-timezone-management"})},t.prototype.activateImprovedHexManagement=function(){return this.rawActivateImprovedHexManagement().then(function(n){return S(n)})},t.prototype.rawActivateImprovedHexManagement=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-hex-management"})},t.prototype.activateImprovedGqlMultilocaleFields=function(){return this.rawActivateImprovedGqlMultilocaleFields().then(function(n){return S(n)})},t.prototype.rawActivateImprovedGqlMultilocaleFields=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-gql-multilocale-fields"})},t.prototype.activateImprovedGqlVisibilityControl=function(){return this.rawActivateImprovedGqlVisibilityControl().then(function(n){return S(n)})},t.prototype.rawActivateImprovedGqlVisibilityControl=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-gql-visibility-control"})},t.prototype.activateImprovedBooleanFields=function(){return this.rawActivateImprovedBooleanFields().then(function(n){return S(n)})},t.prototype.rawActivateImprovedBooleanFields=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-boolean-fields"})},t.prototype.activateDraftModeAsDefault=function(){return this.rawActivateDraftModeAsDefault().then(function(n){return S(n)})},t.prototype.rawActivateDraftModeAsDefault=function(){return this.client.request({method:"PUT",url:"/site/activate-draft-mode-as-default"})},t.prototype.activateImprovedValidationAtPublishing=function(){return this.rawActivateImprovedValidationAtPublishing().then(function(n){return S(n)})},t.prototype.rawActivateImprovedValidationAtPublishing=function(){return this.client.request({method:"PUT",url:"/site/activate-improved-validation-at-publishing"})},t.prototype.updateAssetsCdnDefaultSettings=function(n){return this.rawUpdateAssetsCdnDefaultSettings(M(n,{type:"assets-cdn-default-settings",attributes:["assets_cdn_default_settings"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawUpdateAssetsCdnDefaultSettings=function(n){return this.client.request({method:"PUT",url:"/site/assets-cdn-default-settings",body:n})},t.TYPE="site",t}(B),fb=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),db=function(e){fb(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.create=function(n){return this.rawCreate(M(n,{type:"workflow",attributes:["name","api_key","stages"],relationships:[]})).then(function(r){return S(r)})},t.prototype.rawCreate=function(n){return this.client.request({method:"POST",url:"/workflows",body:n})},t.prototype.update=function(n,r){return this.rawUpdate(C(n),M(r,{id:C(n),type:"workflow",attributes:["name","api_key","stages"],relationships:[]})).then(function(i){return S(i)})},t.prototype.rawUpdate=function(n,r){return this.client.request({method:"PUT",url:"/workflows/".concat(n),body:r})},t.prototype.list=function(){return this.rawList().then(function(n){return S(n)})},t.prototype.rawList=function(){return this.client.request({method:"GET",url:"/workflows"})},t.prototype.find=function(n){return this.rawFind(C(n)).then(function(r){return S(r)})},t.prototype.rawFind=function(n){return this.client.request({method:"GET",url:"/workflows/".concat(n)})},t.prototype.destroy=function(n){return this.rawDestroy(C(n))},t.prototype.rawDestroy=function(n){return this.client.request({method:"DELETE",url:"/workflows/".concat(n)})},t.TYPE="workflow",t}(B),Zt=function(){return Zt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},Zt.apply(this,arguments)},pb=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},hb=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},mb=function(){function e(t){this.config=t,this.roles=new dE(this),this.users=new hE(this),this.ssoUsers=new yE(this),this.auditLogEvents=new gE(this),this.menuItems=new wE(this),this.schemaMenuItems=new EE(this),this.uploadCollections=new bE(this),this.itemTypes=new CE(this),this.fields=new TE(this),this.fieldsets=new IE(this),this.session=new jE(this),this.accessTokens=new NE(this),this.plugins=new ME(this),this.jobResults=new AE(this),this.subscriptionLimits=new $E(this),this.subscriptionFeatures=new UE(this),this.buildEvents=new BE(this),this.items=new KE(this),this.itemVersions=new ex(this),this.uploads=new Cm(this),this.uploadRequest=new ax(this),this.uploadTracks=new ux(this),this.scheduledPublication=new cx(this),this.scheduledUnpublishing=new dx(this),this.searchResults=new vx(this),this.environments=new _x(this),this.maintenanceMode=new Sx(this),this.webhooks=new xx(this),this.webhookCalls=new Tx(this),this.buildTriggers=new Ix(this),this.itemTypeFilters=new jx(this),this.uploadFilters=new Nx(this),this.siteInvitations=new Mx(this),this.editingSessions=new Ax(this),this.ssoGroups=new $x(this),this.ssoSettings=new Ux(this),this.emojiSuggestions=new Bx(this),this.whiteLabelSettings=new Gx(this),this.publicInfo=new Yx(this),this.dailyUsages=new Qx(this),this.usageCounters=new Jx(this),this.uploadTags=new rb(this),this.uploadSmartTags=new ub(this),this.site=new cb(this),this.workflows=new db(this)}return Object.defineProperty(e.prototype,"baseUrl",{get:function(){return this.config.baseUrl||e.defaultBaseUrl},enumerable:!1,configurable:!0}),e.prototype.request=function(t){var n=this;return Oo(Zt(Zt(Zt({},this.config),t),{logFn:this.config.logFn||console.log,userAgent:"@datocms/cma-client v3.4.5",baseUrl:this.baseUrl,preCallStack:new Error().stack,extraHeaders:Zt(Zt(Zt({},this.config.extraHeaders||{}),this.config.environment?{"X-Environment":this.config.environment}:{}),{"X-API-Version":"3"}),fetchJobResult:function(r){return n.jobResultsFetcher?n.jobResultsFetcher(r):MS(function(){return n.jobResults.find(r)})}}))},e.prototype.eventsChannelName=function(){return pb(this,void 0,void 0,function(){var t;return hb(this,function(n){switch(n.label){case 0:return this.cachedEventsChannelName?[2,this.cachedEventsChannelName]:[4,this.site.rawFind()];case 1:return t=n.sent().data,this.cachedEventsChannelName=this.config.environment?"private-site-".concat(t.id,"-environment-").concat(this.config.environment):"private-site-".concat(t.id),[2,this.cachedEventsChannelName]}})})},e.defaultBaseUrl="https://site-api.datocms.com",e}();function yb(e,t,n){var r=n===void 0?{}:n,i=r.onProgress,o=r.additionalHeaders,a=new XMLHttpRequest;return Ka(new Promise(function(u,l){if(i&&a.upload&&(a.upload.onprogress=function(p){p.lengthComputable&&i({type:"UPLOADING_FILE",payload:{progress:Math.round(p.loaded/p.total*100)}})}),a.onreadystatechange=function(){a.readyState===4&&(a.status===200?u():l(new Error("Status ".concat(a.status))))},a.addEventListener("error",l,!1),a.open("PUT",t,!0),o)for(var s=0,c=Object.entries(o);s<c.length;s++){var d=c[s],f=d[0],h=d[1];a.setRequestHeader(f,h)}a.send(e)}),function(){a.onreadystatechange=null,a.abort()})}var ha=function(){return ha=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ha.apply(this,arguments)},vb=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},gb=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};function _b(e,t,n){var r=this;n===void 0&&(n={});var i=n.filename||("name"in t?t.name:void 0);if(!i)throw new Error("Missing filename, please provide it as an option!");var o=!1,a=void 0;return Ka(function(){return vb(r,void 0,void 0,function(){var u,l,s,c;return gb(this,function(d){switch(d.label){case 0:return n.onProgress&&(n==null||n.onProgress({type:"REQUESTING_UPLOAD_URL",payload:{filename:i}})),[4,e.uploadRequest.create({filename:i})];case 1:if(u=d.sent(),l=u.id,s=u.url,c=u.request_headers,o)throw new Ya;return n.onProgress&&n.onProgress({type:"UPLOADING_FILE",payload:{progress:0}}),a=yb(t,s,ha(ha({},n),{additionalHeaders:c})),[4,a];case 2:return d.sent(),[2,l]}})})},function(){a?a.cancel():o=!0})}var wb=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ma=function(){return ma=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ma.apply(this,arguments)},Sb=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function u(c){try{s(r.next(c))}catch(d){a(d)}}function l(c){try{s(r.throw(c))}catch(d){a(d)}}function s(c){c.done?o(c.value):i(c.value).then(u,l)}s((r=r.apply(e,t||[])).next())})},Eb=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1],o=s;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(s);break}o[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(c){s=[6,c],i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},xb=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},bb=function(e){wb(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.createFromFileOrBlob=function(n){var r=this,i=!1,o;return Ka(function(){return Sb(r,void 0,void 0,function(){var a,u,l,s,c;return Eb(this,function(d){switch(d.label){case 0:if(i)throw new Ya;return a=n.fileOrBlob,u=n.filename,l=n.onProgress,s=xb(n,["fileOrBlob","filename","onProgress"]),o=_b(this.client,a,{filename:u,onProgress:l}),[4,o];case 1:return c=d.sent(),l&&l({type:"CREATING_UPLOAD_OBJECT"}),[2,this.create(ma(ma({},s),{path:c}))]}})})},function(){o?o.cancel():i=!0})},t}(Cm),Ob=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Cb=function(e){Ob(t,e);function t(n){var r=e.call(this,n)||this;return r.uploads=new bb(r),r}return t}(mb);function Pb(e){return new Cb(e)}const Tb="_assetListCard_1g8hn_23",kb="_assetListHeader_1g8hn_43",Ib="_assetListHeaderTitle_1g8hn_52",Lb="_categoryBadge_1g8hn_67",jb="_badgeGreen_1g8hn_81",Rb="_badgeRed_1g8hn_85",Nb="_badgeGray_1g8hn_89",Fb="_badgeBlue_1g8hn_93",Mb="_noAssetsMessage_1g8hn_97",Db="_assetList_1g8hn_23",Ab="_assetListItem_1g8hn_112",zb="_assetItemContent_1g8hn_126",$b="_assetIcon_1g8hn_132",Vb="_fileIconWrapper_1g8hn_136",Ub="_assetDetails_1g8hn_149",qb="_assetPath_1g8hn_154",Bb="_optimizationStats_1g8hn_161",Hb="_sizeInfo_1g8hn_169",Gb="_sizeBefore_1g8hn_176",Wb="_sizeAfter_1g8hn_176",Yb="_sizeLabel_1g8hn_182",Kb="_sizeValue_1g8hn_187",Qb="_sizeArrow_1g8hn_200",Xb="_savingsBadge_1g8hn_205",Jb="_assetActions_1g8hn_215",Zb="_container_1g8hn_226",eO="_optimizingContainer_1g8hn_290",tO="_statusText_1g8hn_302",nO="_percentageText_1g8hn_308",rO="_progressBar_1g8hn_315",iO="_progressBarFill_1g8hn_326",oO="_logWrapper_1g8hn_359",aO="_logHeader_1g8hn_369",sO="_logsContainer_1g8hn_381",uO="_logs_1g8hn_381",lO="_logEntry_1g8hn_397",cO="_sizeComparison_1g8hn_410",fO="_originalSize_1g8hn_568",dO="_optimizedSize_1g8hn_578",pO="_sizeSavings_1g8hn_583",hO="_settingsContainer_1g8hn_628",mO="_settingsForm_1g8hn_634",yO="_fieldRow_1g8hn_659",vO="_field_1g8hn_659",gO="_formActionContainer_1g8hn_670",_O="_buttonGroup_1g8hn_674",wO="_resultsContainer_1g8hn_718",SO="_optimizationSummaryTitle_1g8hn_727",EO="_statsCardGrid_1g8hn_735",xO="_statsCard_1g8hn_735",bO="_clickableStatsCard_1g8hn_752",OO="_statsCardTitle_1g8hn_792",CO="_statsCardValue_1g8hn_800",PO="_optimizedValue_1g8hn_806",TO="_skippedValue_1g8hn_810",kO="_failedValue_1g8hn_814",IO="_statsCardLabel_1g8hn_818",LO="_savingsSummary_1g8hn_823",jO="_savingsCard_1g8hn_827",RO="_savingsRow_1g8hn_834",NO="_savingsLabel_1g8hn_846",FO="_savingsValue_1g8hn_851",MO="_actionsContainer_1g8hn_857",DO="_infoText_1g8hn_866",AO="_hintWithDoc_1g8hn_882",zO="_plainHint_1g8hn_896",$O="_docLinkIcon_1g8hn_909",VO="_currentAssetPreview_1g8hn_973",UO="_assetPreviewImage_1g8hn_984",qO="_assetPreviewInfo_1g8hn_1001",BO="_assetPreviewTitle_1g8hn_1006",HO="_assetPreviewMeta_1g8hn_1016",GO="_advancedOptionsGroup_1g8hn_1025",WO="_optionsGrid_1g8hn_1035",YO="_optionItem_1g8hn_1042",KO="_paramTooltip_1g8hn_1049",QO="_tooltipText_1g8hn_1054",T={assetListCard:Tb,assetListHeader:kb,assetListHeaderTitle:Ib,categoryBadge:Lb,badgeGreen:jb,badgeRed:Rb,badgeGray:Nb,badgeBlue:Fb,noAssetsMessage:Mb,assetList:Db,assetListItem:Ab,assetItemContent:zb,assetIcon:$b,fileIconWrapper:Vb,assetDetails:Ub,assetPath:qb,optimizationStats:Bb,sizeInfo:Hb,sizeBefore:Gb,sizeAfter:Wb,sizeLabel:Yb,sizeValue:Kb,sizeArrow:Qb,savingsBadge:Xb,assetActions:Jb,container:Zb,optimizingContainer:eO,statusText:tO,percentageText:nO,progressBar:rO,progressBarFill:iO,logWrapper:oO,logHeader:aO,logsContainer:sO,logs:uO,logEntry:lO,sizeComparison:cO,originalSize:fO,optimizedSize:dO,sizeSavings:pO,settingsContainer:hO,settingsForm:mO,fieldRow:yO,field:vO,formActionContainer:gO,buttonGroup:_O,resultsContainer:wO,optimizationSummaryTitle:SO,statsCardGrid:EO,statsCard:xO,clickableStatsCard:bO,statsCardTitle:OO,statsCardValue:CO,optimizedValue:PO,skippedValue:TO,failedValue:kO,statsCardLabel:IO,savingsSummary:LO,savingsCard:jO,savingsRow:RO,savingsLabel:NO,savingsValue:FO,actionsContainer:MO,infoText:DO,hintWithDoc:AO,plainHint:zO,docLinkIcon:$O,currentAssetPreview:VO,assetPreviewImage:UO,assetPreviewInfo:qO,assetPreviewTitle:BO,assetPreviewMeta:HO,advancedOptionsGroup:GO,optionsGrid:WO,optionItem:YO,paramTooltip:KO,tooltipText:QO},Pm={largeAssetThreshold:3,veryLargeAssetThreshold:8,qualityLarge:85,qualityVeryLarge:80,resizeDimensionLarge:2400,resizeDimensionVeryLarge:2e3,minimumReduction:10,targetFormat:"avif",preserveOriginalFormat:!1,resizeLargeImages:!0,useAutoCompress:!0,useDpr:!0,useLossless:!1,useChromaSubsampling:!1,preserveColorProfile:!0};function XO(e,t){if(!e.is_image)return null;const n=t.largeAssetThreshold*1024*1024,r=t.veryLargeAssetThreshold*1024*1024,i=e.size>=n,o=e.size>=r;let a="?";if(t.useAutoCompress&&(a+="auto=compress"),o)a+=a.length>1?"&":"",a+=`q=${t.qualityVeryLarge}`;else if(i)a+=a.length>1?"&":"",a+=`q=${t.qualityLarge}`;else return null;if(t.resizeLargeImages&&e.width&&e.height){const u=Math.max(e.width,e.height),l=o?t.resizeDimensionVeryLarge:i?t.resizeDimensionLarge:null;l&&u>l&&(e.width>=e.height?(a+=a.length>1?"&":"",a+=`max-w=${l}`):(a+=a.length>1?"&":"",a+=`h=${l}`))}return t.targetFormat&&!t.preserveOriginalFormat&&(a+=a.length>1?"&":"",a+=`fm=${t.targetFormat}`),o&&t.useDpr&&(a+=a.length>1?"&":"",a+="dpr=2"),t.useLossless&&(a+=a.length>1?"&":"",a+="lossless=1"),t.useChromaSubsampling&&(a+=a.length>1?"&":"",a+="chromasub=444"),t.preserveColorProfile&&(a+=a.length>1?"&":"",a+="cs=origin"),a}var JO="Expected a function",sd=NaN,ZO="[object Symbol]",eC=/^\s+|\s+$/g,tC=/^[-+]0x[0-9a-f]+$/i,nC=/^0b[01]+$/i,rC=/^0o[0-7]+$/i,iC=parseInt,oC=typeof Ot=="object"&&Ot&&Ot.Object===Object&&Ot,aC=typeof self=="object"&&self&&self.Object===Object&&self,sC=oC||aC||Function("return this")(),uC=Object.prototype,lC=uC.toString,cC=Math.max,fC=Math.min,Ns=function(){return sC.Date.now()};function dC(e,t,n){var r,i,o,a,u,l,s=0,c=!1,d=!1,f=!0;if(typeof e!="function")throw new TypeError(JO);t=ud(t)||0,Xu(n)&&(c=!!n.leading,d="maxWait"in n,o=d?cC(ud(n.maxWait)||0,t):o,f="trailing"in n?!!n.trailing:f);function h(b){var x=r,P=i;return r=i=void 0,s=b,a=e.apply(P,x),a}function p(b){return s=b,u=setTimeout(m,t),c?h(b):a}function v(b){var x=b-l,P=b-s,R=t-x;return d?fC(R,o-P):R}function E(b){var x=b-l,P=b-s;return l===void 0||x>=t||x<0||d&&P>=o}function m(){var b=Ns();if(E(b))return y(b);u=setTimeout(m,v(b))}function y(b){return u=void 0,f&&r?h(b):(r=i=void 0,a)}function g(){u!==void 0&&clearTimeout(u),s=0,r=l=i=u=void 0}function w(){return u===void 0?a:y(Ns())}function O(){var b=Ns(),x=E(b);if(r=arguments,i=this,l=b,x){if(u===void 0)return p(l);if(d)return u=setTimeout(m,t),h(l)}return u===void 0&&(u=setTimeout(m,t)),a}return O.cancel=g,O.flush=w,O}function Xu(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function pC(e){return!!e&&typeof e=="object"}function hC(e){return typeof e=="symbol"||pC(e)&&lC.call(e)==ZO}function ud(e){if(typeof e=="number")return e;if(hC(e))return sd;if(Xu(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Xu(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(eC,"");var n=nC.test(e);return n||rC.test(e)?iC(e.slice(2),n?2:8):tC.test(e)?sd:+e}var mC=dC;const yC=ya(mC),tt=({children:e,paramName:t,paramValue:n})=>{const i=n==null?`${t}`:typeof n=="boolean"?n?`${t}=1`:"":`${t}=${n}`;return i?_.jsxs("div",{className:T.paramTooltip,children:[e,_.jsx("span",{className:T.tooltipText,children:i})]}):_.jsx(_.Fragment,{children:e})},jt=({hint:e,url:t})=>{const n=`Learn more about ${e}`,r=()=>{window.open(t,"_blank","noopener,noreferrer")};return _.jsxs("button",{className:T.hintWithDoc,onClick:r,type:"button","aria-label":n,children:[_.jsx("span",{children:e}),_.jsx("span",{className:T.docLinkIcon,children:"ℹ"})]})},Yn=({hint:e})=>_.jsx("div",{className:T.plainHint,children:_.jsx("span",{children:e})}),Rt={format:"https://docs.imgix.com/apis/rendering/format/fm",auto:"https://docs.imgix.com/apis/rendering/automatic",resize:"https://docs.imgix.com/apis/rendering/size/w",quality:"https://docs.imgix.com/apis/rendering/format/q",dpr:"https://docs.imgix.com/apis/rendering/pixel-density/dpr",lossless:"https://docs.imgix.com/apis/rendering/format/lossless",chroma:"https://docs.imgix.com/apis/rendering/format/chroma-subsampling",colorSpace:"https://docs.imgix.com/apis/rendering/format/color-space"},vC=({settings:e,onSettingsChange:t,onStartOptimization:n,ctx:r})=>{const i=k.useRef(null);k.useEffect(()=>(i.current=yC(async c=>{try{await r.updatePluginParameters({optimization_settings:JSON.stringify(c)}),console.log("Settings saved to plugin parameters:",c)}catch(d){console.error("Error saving settings:",d)}},500),()=>{i.current&&i.current.cancel()}),[r]),k.useEffect(()=>{i.current&&i.current(e)},[e]);const o=c=>d=>{const f=Number.parseFloat(d);if(!Number.isNaN(f)){let h=f;(c==="qualityLarge"||c==="qualityVeryLarge")&&(h=Math.min(Math.max(0,f),100)),c==="minimumReduction"&&(h=Math.min(Math.max(0,f),100)),(c==="largeAssetThreshold"||c==="veryLargeAssetThreshold")&&(h=Math.max(.1,f)),(c==="resizeDimensionLarge"||c==="resizeDimensionVeryLarge")&&(h=Math.max(1,f)),t({...e,[c]:h})}},a=c=>d=>{t({...e,[c]:d})},u=c=>(d,f)=>{d&&typeof d=="object"&&!Array.isArray(d)&&"value"in d&&t({...e,[c]:d.value})},l=[{label:"WebP",value:"webp"},{label:"AVIF",value:"avif"}],s=l.find(c=>c.value===e.targetFormat)||l[0];return _.jsxs(u_,{className:T.settingsForm,children:[_.jsxs(Vr,{children:[_.jsx("h4",{children:"Size Thresholds"}),_.jsxs("div",{className:T.fieldRow,children:[_.jsxs("div",{className:T.field,children:[_.jsx(wn,{id:"largeAssetThreshold",name:"largeAssetThreshold",label:"Large Asset (MB)",value:e.largeAssetThreshold.toString(),onChange:o("largeAssetThreshold")}),_.jsx(Yn,{hint:`Assets above ${e.largeAssetThreshold}MB will be optimized`})]}),_.jsxs("div",{className:T.field,children:[_.jsx(wn,{id:"veryLargeAssetThreshold",name:"veryLargeAssetThreshold",label:"Very Large Asset (MB)",value:e.veryLargeAssetThreshold.toString(),onChange:o("veryLargeAssetThreshold")}),_.jsx(Yn,{hint:`Assets above ${e.veryLargeAssetThreshold}MB get stronger optimization`})]})]}),_.jsxs("div",{className:T.field,children:[_.jsx(wn,{id:"minimumReduction",name:"minimumReduction",label:"Minimum Size Reduction (%)",value:e.minimumReduction.toString(),onChange:o("minimumReduction")}),_.jsx(Yn,{hint:"Only replace if reduced by at least this percentage"})]})]}),_.jsxs(Vr,{children:[_.jsx("h4",{children:"Basic Optimization"}),_.jsxs("div",{className:T.fieldRow,children:[_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"fm",paramValue:e.preserveOriginalFormat?void 0:e.targetFormat,children:_.jsx(_n,{id:"preserveOriginalFormat",name:"preserveOriginalFormat",label:"Preserve Original Format",value:e.preserveOriginalFormat,onChange:a("preserveOriginalFormat")})}),_.jsx(jt,{hint:"Keep original image format (JPG, PNG, etc.)",url:Rt.format})]}),_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"auto",paramValue:"compress",children:_.jsx(_n,{id:"useAutoCompress",name:"useAutoCompress",label:"Auto Compress",value:e.useAutoCompress,onChange:a("useAutoCompress")})}),_.jsx(jt,{hint:"Use Imgix's auto compression features",url:Rt.auto})]})]}),!e.preserveOriginalFormat&&_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"fm",paramValue:e.targetFormat,children:_.jsx(h_,{id:"targetFormat",name:"targetFormat",label:"Target Format",value:s,onChange:u("targetFormat"),selectInputProps:{options:l}})}),_.jsx(Yn,{hint:"Format to convert images to"})]}),_.jsxs("p",{className:T.infoText,children:[_.jsx("strong",{children:"Format Settings:"})," ",e.preserveOriginalFormat?"Original image formats will be preserved while optimizing quality and file size.":`Images will be converted to ${e.targetFormat.toUpperCase()} format for better compression.`,e.useAutoCompress&&_.jsx("span",{children:" Auto compression is enabled, letting Imgix automatically optimize each image."})]}),_.jsx("div",{className:T.fieldRow,children:_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"max-w",paramValue:e.resizeLargeImages?"value":void 0,children:_.jsx(_n,{id:"resizeLargeImages",name:"resizeLargeImages",label:"Resize Large Images",value:e.resizeLargeImages,onChange:a("resizeLargeImages")})}),_.jsx(jt,{hint:"Reduce image dimensions to save space",url:Rt.resize})]})})]}),e.resizeLargeImages&&_.jsxs(Vr,{children:[_.jsx("h4",{children:"Resize Dimensions"}),_.jsxs("div",{className:T.fieldRow,children:[_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"max-w",paramValue:e.resizeDimensionLarge,children:_.jsx(wn,{id:"resizeDimensionLarge",name:"resizeDimensionLarge",label:"Large Image Max Width (px)",value:e.resizeDimensionLarge.toString(),onChange:o("resizeDimensionLarge")})}),_.jsx(Yn,{hint:"Max dimension for large images"})]}),_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"max-w",paramValue:e.resizeDimensionVeryLarge,children:_.jsx(wn,{id:"resizeDimensionVeryLarge",name:"resizeDimensionVeryLarge",label:"Very Large Image Max Width (px)",value:e.resizeDimensionVeryLarge.toString(),onChange:o("resizeDimensionVeryLarge")})}),_.jsx(Yn,{hint:"Max dimension for very large images"})]})]})]}),_.jsxs(Vr,{children:[_.jsx("h4",{children:"Compression Settings"}),!e.useLossless&&_.jsxs("div",{className:T.fieldRow,children:[_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"q",paramValue:e.qualityLarge,children:_.jsx(wn,{id:"qualityLarge",name:"qualityLarge",label:"Large Image Quality",value:e.qualityLarge.toString(),onChange:o("qualityLarge")})}),_.jsx(jt,{hint:"Quality for large images (0-100)",url:Rt.quality})]}),_.jsxs("div",{className:T.field,children:[_.jsx(tt,{paramName:"q",paramValue:e.qualityVeryLarge,children:_.jsx(wn,{id:"qualityVeryLarge",name:"qualityVeryLarge",label:"Very Large Image Quality",value:e.qualityVeryLarge.toString(),onChange:o("qualityVeryLarge")})}),_.jsx(jt,{hint:"Quality for very large images (0-100)",url:Rt.quality})]})]}),e.useLossless&&_.jsxs("p",{className:T.infoText,style:{marginBottom:0},children:[_.jsx("strong",{children:"Lossless Mode:"})," Standard quality settings are disabled when using Lossless Mode."]})]}),_.jsxs(Vr,{className:T.advancedOptionsGroup,children:[_.jsx("h4",{children:"Advanced Options"}),_.jsxs("div",{className:T.optionsGrid,children:[_.jsxs("div",{className:T.optionItem,children:[_.jsx(tt,{paramName:"lossless",paramValue:e.useLossless?1:void 0,children:_.jsx(_n,{id:"useLossless",name:"useLossless",label:"Use Lossless Compression",value:e.useLossless,onChange:a("useLossless")})}),_.jsx(jt,{hint:"Use lossless compression when possible",url:Rt.lossless})]}),_.jsxs("div",{className:T.optionItem,children:[_.jsx(tt,{paramName:"dpr",paramValue:e.useDpr?2:void 0,children:_.jsx(_n,{id:"useDpr",name:"useDpr",label:"Use DPR Optimization",value:e.useDpr,onChange:a("useDpr")})}),_.jsx(jt,{hint:"Optimize for high-resolution displays (Retina)",url:Rt.dpr})]}),_.jsxs("div",{className:T.optionItem,children:[_.jsx(tt,{paramName:"chromasub",paramValue:e.useChromaSubsampling?444:void 0,children:_.jsx(_n,{id:"useChromaSubsampling",name:"useChromaSubsampling",label:"Enhanced Chroma Sampling",value:e.useChromaSubsampling,onChange:a("useChromaSubsampling")})}),_.jsx(jt,{hint:"Use higher quality chroma subsampling (444) for JPEGs",url:Rt.chroma})]}),_.jsxs("div",{className:T.optionItem,children:[_.jsx(tt,{paramName:"cs",paramValue:e.preserveColorProfile?"origin":void 0,children:_.jsx(_n,{id:"preserveColorProfile",name:"preserveColorProfile",label:"Preserve Color Profiles",value:e.preserveColorProfile,onChange:a("preserveColorProfile")})}),_.jsx(jt,{hint:"Maintain accurate colors from original image",url:Rt.colorSpace})]})]})]}),_.jsx("div",{className:T.formActionContainer,children:_.jsxs("div",{className:T.buttonGroup,children:[_.jsx(kn,{buttonType:"muted",buttonSize:"l",onClick:()=>t({...Pm}),children:"Restore Defaults"}),_.jsx(kn,{buttonType:"primary",buttonSize:"l",onClick:n,fullWidth:!0,children:"Start Optimization"})]})})]})};function Rn(e){return e<1024?`${e} bytes`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const gC=({log:e})=>{if(e.length===0)return null;const t=k.useRef(null);return k.useEffect(()=>{if(t.current){const{scrollHeight:n,clientHeight:r}=t.current;t.current.scrollTop=n-r}},[]),_.jsxs("div",{className:T.logWrapper,children:[_.jsxs("div",{className:T.logHeader,children:[_.jsx("h3",{children:"Activity Log"}),_.jsxs("span",{children:[e.length," entries"]})]}),_.jsx("div",{className:T.logsContainer,ref:t,children:_.jsx("div",{className:T.logs,children:e.map((n,r)=>_.jsxs("div",{className:T.logEntry,children:[_.jsx("span",{children:n.text}),n.originalSize&&n.optimizedSize&&_.jsxs("span",{className:T.sizeComparison,children:[_.jsx("span",{className:T.originalSize,children:Rn(n.originalSize)}),_.jsx("span",{className:T.sizeArrow,children:"→"}),_.jsx("span",{className:T.optimizedSize,children:Rn(n.optimizedSize)}),_.jsxs("span",{className:T.sizeSavings,children:["(-",n.savingsPercentage,"%)"]})]})]},`log-${r}-${n.text.substring(0,10)}`))})})]})},_C=({current:e,total:t,isVisible:n,assetSizeCategory:r="large",currentAsset:i})=>{var a;if(!n)return null;const o=t>0?Math.min(100,Math.max(0,Math.round(e/t*100))):0;return _.jsxs("div",{className:T.optimizingContainer,children:[i&&_.jsxs("div",{className:T.currentAssetPreview,children:[_.jsx("div",{className:T.assetPreviewImage,children:_.jsx("img",{src:`${i.url}?w=120&h=80&fit=crop&auto=format`,alt:i.basename})}),_.jsxs("div",{className:T.assetPreviewInfo,children:[_.jsx("div",{className:T.assetPreviewTitle,children:i.basename}),_.jsxs("div",{className:T.assetPreviewMeta,children:[(a=i.path.split(".").pop())==null?void 0:a.toUpperCase()," • ",(i.size/(1024*1024)).toFixed(2)," MB • ",i.width,"×",i.height,"px"]})]})]}),_.jsxs("div",{className:T.statusText,children:[_.jsx(mS,{size:16})," ",_.jsxs("span",{children:["Processing ",r," assets: ",e," of ",t]})]}),_.jsx("div",{className:T.percentageText,children:_.jsxs("span",{children:[o,"%"]})}),_.jsx("div",{className:T.progressBar,children:_.jsx("div",{className:T.progressBarFill,style:{width:`${o}%`}})})]})},wC=({result:e,setSelectedCategory:t,resetState:n,largeAssetThreshold:r})=>{if(!e)return null;const{optimized:i,skipped:o,failed:a,totalAssets:u,optimizedAssets:l}=e,s=l.reduce((p,v)=>p+(v.originalSize-v.optimizedSize),0),c=l.length>0?Math.round(l.reduce((p,v)=>p+(v.originalSize-v.optimizedSize)/v.originalSize*100,0)/l.length):0,d=()=>s<1024?`${s} bytes`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`,f=(p,v)=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),t(v))},h=()=>{n?n():t(null)};return _.jsxs("div",{className:T.resultsContainer,children:[_.jsx("h2",{className:T.optimizationSummaryTitle,children:"Optimization Summary"}),u===0&&r&&_.jsx("div",{className:`${T.infoBox}`,style:{margin:"0 0 16px 0",padding:"16px",backgroundColor:"var(--light-bg-color)",borderRadius:"4px"},children:_.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[_.jsx("div",{style:{marginRight:"8px",color:"var(--accent-color)",display:"flex"},children:_.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[_.jsx("title",{children:"Information"}),_.jsx("path",{d:"M12 22C6.477 22 2 17.523 2 12C2 6.477 6.477 2 12 2C17.523 2 22 6.477 22 12C22 17.523 17.523 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 7H13V9H11V7ZM11 11H13V17H11V11Z",fill:"currentColor"})]})}),_.jsxs("p",{style:{margin:0,color:"var(--base-body-color)"},children:["No images in your project are larger than ",_.jsxs("strong",{children:[r,"MB"]}),". Try lowering the minimum size threshold to optimize more assets."]})]})}),_.jsxs("div",{className:T.statsCardGrid,children:[_.jsxs("div",{className:T.statsCard,children:[_.jsx("h3",{className:T.statsCardTitle,children:"Total Assets"}),_.jsx("div",{className:T.statsCardValue,children:u}),_.jsx("div",{className:T.statsCardLabel,children:u>0?"Total":"No assets found"})]}),_.jsxs("div",{className:`${T.statsCard} ${i>0?T.clickableStatsCard:""}`,onClick:()=>i>0?t("optimized"):null,onKeyDown:p=>i>0?f(p,"optimized"):null,role:i>0?"button":void 0,tabIndex:i>0?0:void 0,children:[_.jsx("h3",{className:T.statsCardTitle,children:"Optimized"}),_.jsx("div",{className:`${T.statsCardValue} ${T.optimizedValue}`,children:i}),_.jsx("div",{className:T.statsCardLabel,children:i>0?"Click to view":"No optimized assets"})]}),_.jsxs("div",{className:`${T.statsCard} ${o>0?T.clickableStatsCard:""}`,onClick:()=>o>0?t("skipped"):null,onKeyDown:p=>o>0?f(p,"skipped"):null,role:o>0?"button":void 0,tabIndex:o>0?0:void 0,children:[_.jsx("h3",{className:T.statsCardTitle,children:"Skipped"}),_.jsx("div",{className:`${T.statsCardValue} ${T.skippedValue}`,children:o}),_.jsx("div",{className:T.statsCardLabel,children:o>0?"Click to view":"No skipped assets"})]}),_.jsxs("div",{className:`${T.statsCard} ${a>0?T.clickableStatsCard:""}`,onClick:()=>a>0?t("failed"):null,onKeyDown:p=>a>0?f(p,"failed"):null,role:a>0?"button":void 0,tabIndex:a>0?0:void 0,children:[_.jsx("h3",{className:T.statsCardTitle,children:"Failed"}),_.jsx("div",{className:`${T.statsCardValue} ${T.failedValue}`,children:a}),_.jsx("div",{className:T.statsCardLabel,children:a>0?"Click to view":"No failed assets"})]})]}),_.jsx("div",{className:T.savingsSummary,children:_.jsxs("div",{className:T.savingsCard,children:[_.jsxs("div",{className:T.savingsRow,children:[_.jsx("div",{className:T.savingsLabel,children:"Total Storage Saved"}),_.jsx("div",{className:T.savingsValue,children:d()})]}),_.jsxs("div",{className:T.savingsRow,children:[_.jsx("div",{className:T.savingsLabel,children:"Average Optimization per Asset"}),_.jsxs("div",{className:T.savingsValue,children:[c,"%"]})]})]})}),_.jsx("div",{className:T.actionsContainer,children:_.jsx(kn,{buttonType:"primary",buttonSize:"l",onClick:h,fullWidth:!0,children:"New Optimization"})})]})},SC=({assets:e,category:t,onClose:n,ctx:r})=>{const i=()=>{switch(t){case"optimized":return T.badgeGreen;case"failed":return T.badgeRed;case"skipped":return T.badgeGray;default:return T.badgeBlue}};return _.jsxs("div",{className:T.assetListCard,children:[_.jsxs("div",{className:T.assetListHeader,children:[_.jsxs("div",{className:T.assetListHeaderTitle,children:[_.jsx("div",{className:`${T.categoryBadge} ${i()}`,children:e.length}),_.jsxs("h3",{children:[t.charAt(0).toUpperCase()+t.slice(1)," Assets"]})]}),n&&_.jsx(kn,{buttonType:"negative",buttonSize:"xs",onClick:n,children:"Close"})]}),e.length===0?_.jsxs("div",{className:T.noAssetsMessage,children:["No ",t," assets to display."]}):_.jsx("ul",{className:T.assetList,children:e.map(o=>{const a={id:o.id,path:o.path,url:o.url,size:"size"in o?o.size:"originalSize"in o?o.originalSize:0,basename:"basename"in o?o.basename:"",originalSize:"originalSize"in o?o.originalSize:void 0,optimizedSize:"optimizedSize"in o?o.optimizedSize:void 0},u=a.originalSize&&a.optimizedSize?Math.round((a.originalSize-a.optimizedSize)/a.originalSize*100):null,l=a.path.split(".").pop()||"";return _.jsx("li",{className:T.assetListItem,children:_.jsxs("div",{className:T.assetItemContent,children:[_.jsx("div",{className:T.assetIcon,children:_.jsx("div",{className:T.fileIconWrapper,children:l.toUpperCase()})}),_.jsxs("div",{className:T.assetDetails,children:[_.jsx("p",{className:T.assetPath,children:a.path}),t==="optimized"&&a.originalSize&&a.optimizedSize&&_.jsxs("div",{className:T.optimizationStats,children:[_.jsxs("div",{className:T.sizeInfo,children:[_.jsxs("div",{className:T.sizeBefore,children:[_.jsx("span",{className:T.sizeLabel,children:"Original:"}),_.jsx("span",{className:T.sizeValue,children:Rn(a.originalSize)})]}),_.jsx("div",{className:T.sizeArrow,children:"→"}),_.jsxs("div",{className:T.sizeAfter,children:[_.jsx("span",{className:T.sizeLabel,children:"Optimized:"}),_.jsx("span",{className:T.sizeValue,children:Rn(a.optimizedSize)})]})]}),u&&_.jsxs("div",{className:`${T.savingsBadge} ${T.badgeGreen}`,children:[u,"% savings"]})]})]}),_.jsxs("div",{className:T.assetActions,children:[_.jsx(kn,{buttonSize:"xxs",buttonType:"primary",onClick:()=>window.open(a.url,"_blank"),children:"View Asset"}),_.jsx(kn,{buttonSize:"xxs",buttonType:"muted",style:{marginLeft:"8px"},onClick:()=>window.open(`https://${r.site.attributes.internal_domain}/media/assets/${a.id}`,"_blank"),children:"Media Area"})]})]})},a.id)})})]})};async function EC(e,t,n=60,r=2e3){var u;const i="https://site-api.datocms.com",o={Authorization:`Bearer ${t}`,"Content-Type":"application/json",Accept:"application/json","X-Api-Version":"3"};let a=0;for(;a<n;){a++;try{const l=await fetch(`${i}/job-results/${e}`,{headers:o});if(l.status===200){const s=await l.json();if(((u=s.data.attributes)==null?void 0:u.status)===200)return console.log(`Job ${e} completed successfully`),s}console.log(`Job ${e} still processing (attempt ${a}/${n})...`),await new Promise(s=>setTimeout(s,r))}catch(l){console.error(`Error checking job status: ${l}`)}}throw new Error(`Job ${e} did not complete after ${n} attempts`)}async function xC(e,t,n,r){var i,o;if(console.log(`Replacing DatoCMS asset ID ${e} with image from URL: ${t}`),!e||!n)throw new Error("Missing required parameters: assetId and apiToken are required");try{const a="https://site-api.datocms.com",u={Authorization:`Bearer ${n}`,"Content-Type":"application/json",Accept:"application/json","X-Api-Version":"3"},l=await fetch(`${a}/upload-requests`,{method:"POST",headers:u,body:JSON.stringify({data:{type:"upload_request",attributes:{filename:r||"optimized-image.jpg"}}})});if(!l.ok){const w=await l.text();throw new Error(`Failed to create upload request: ${l.status} ${w}`)}const s=await l.json(),{id:c,attributes:{url:d,request_headers:f}}=s.data,h=await fetch(t);if(!h.ok)throw new Error(`Failed to fetch image from URL: ${h.status} ${h.statusText}`);const v=await(await h.blob()).arrayBuffer(),E=new Uint8Array(v),m=await fetch(d,{method:"PUT",headers:{...f,"Content-Length":E.length.toString()},body:E});if(!m.ok)throw new Error(`Failed to upload file to S3: ${m.status} ${m.statusText}`);const y=await fetch(`${a}/uploads/${e}`,{method:"PUT",headers:u,body:JSON.stringify({data:{id:e,type:"upload",attributes:{path:c}}})});if(!y.ok){const w=await y.text();throw new Error(`Failed to update asset metadata: ${y.status} ${w}`)}const g=await y.json();if(g.data&&g.data.type==="job"){const w=g.data.id;console.log(`Asset update initiated as job ${w}, waiting for completion...`);const O=await EC(w,n);if(((i=O.data.attributes)==null?void 0:i.status)!==200)throw new Error(`Job completed with error status: ${(o=O.data.attributes)==null?void 0:o.status}`);return O.data.attributes.payload}return console.log("Asset replaced successfully:",g),g}catch(a){throw console.error("Error replacing asset:",a),a}}function bC(e){var t,n,r,i,o,a;return{id:e.id,is_image:e.is_image||!1,size:e.size||0,url:e.url||"",path:e.path||"",basename:e.basename||"",width:e.width||void 0,height:e.height||void 0,alt:((n=(t=e.default_field_metadata)==null?void 0:t.en)==null?void 0:n.alt)||void 0,title:((i=(r=e.default_field_metadata)==null?void 0:r.en)==null?void 0:i.title)||void 0,customData:((a=(o=e.default_field_metadata)==null?void 0:o.en)==null?void 0:a.custom_data)||{},tags:e.tags||[]}}function ao(e){return{id:e.id,path:e.path,url:e.url}}function OC(e,t,n){return{id:e.id,path:e.path,url:e.url,originalSize:t,optimizedSize:n}}const CC=({ctx:e})=>{const[t,n]=k.useState(!1),[r,i]=k.useState(0),[o,a]=k.useState(0),[u,l]=k.useState(null),[s,c]=k.useState([]),[d,f]=k.useState({...Pm}),[h,p]=k.useState(void 0),[v,E]=k.useState(null);k.useEffect(()=>{(async()=>{try{const b=e.plugin.attributes.parameters;if(b&&typeof b.optimization_settings=="string")try{const x=JSON.parse(b.optimization_settings);f(x),console.log("Loaded settings from plugin parameters:",x)}catch(x){console.error("Error parsing saved settings:",x)}else console.log("No saved settings found, using defaults")}catch(b){console.error("Error accessing plugin parameters:",b)}})()},[e]),k.useEffect(()=>{const O=b=>{if(t){const x="Optimization is in progress. Leaving the page now may cause you to lose assets! Are you sure you want to leave?";return b.preventDefault(),b.returnValue=x,x}};return window.addEventListener("beforeunload",O),()=>{window.removeEventListener("beforeunload",O)}},[t]);const m=O=>{c(b=>[{text:`[${new Date().toISOString()}] ${O}`},...b])},y=(O,b,x)=>{const P=b-x,R=Math.round(P/b*100);c(j=>[{text:`[${new Date().toISOString()}] Successfully optimized asset: ${O} `,originalSize:b,optimizedSize:x,savingsPercentage:R},...j])},g=async()=>{try{if(await e.openConfirm({title:"Confirm Asset Optimization",content:"WARNING: This is a destructive action that will permanently replace all assets that fall into the optimization thresholds. This action is non-reversible and original assets cannot be recovered once replaced. Are you sure you want to proceed?",choices:[{label:"Proceed to Final Confirmation",value:"confirm",intent:"positive"}],cancel:{label:"Cancel",value:!1}})!=="confirm"||await e.openConfirm({title:"Final Confirmation Required",content:"ARE YOU ABSOLUTELY SURE? This will immediately replace your original assets with optimized versions. Your original assets will be PERMANENTLY DELETED and CANNOT be recovered. This may affect the visual quality of your images if not configured correctly.",choices:[{label:"Yes, Replace My Assets",value:"confirm",intent:"positive"}],cancel:{label:"No, Cancel Operation",value:!1}})!=="confirm")return;w(),n(!0),m("Starting asset optimization process...");const x=Pb({apiToken:e.currentUserAccessToken??"",environment:e.environment});m("Fetching assets from DatoCMS...");const P=d.largeAssetThreshold*1024*1024,R=[];let j=0;for await(const D of x.uploads.listPagedIterator({filter:{fields:{type:{eq:"image"},size:{gte:P}}}}))j++,R.push(bC(D));m(`Found ${j} assets larger than ${d.largeAssetThreshold}MB.`),m(`Found ${R.length} optimizable images.`),a(R.length);let V=0,q=0,U=0;const ee=[],X=[],K=[];let re=0,I=0;for(let D=0;D<R.length;D++){const N=R[D];i(D+1),p(N);try{m(`Processing asset: ${N.path} (${Rn(N.size)})`),re+=N.size;const Y=XO(N,d);if(!Y){m(`Skipping asset ${N.path}: No suitable optimization parameters found.`),X.push(ao(N)),q++;continue}const G=`${N.url}${Y}`;m(`Optimizing with parameters: ${Y}`);const he=await fetch(G);if(!he.ok)throw new Error(`Failed to fetch optimized image: ${he.statusText}`);const ce=await he.blob();m(`Optimized image size: ${Rn(ce.size)}`);const $e=N.size*(1-d.minimumReduction/100);if(ce.size>$e){m(`Optimization not significant enough for ${N.path}. Skipping.`),X.push(ao(N)),q++;continue}m(`Replacing asset ${N.path}...`);try{const oe=e.currentUserAccessToken;if(!oe)throw new Error("Failed to get API token");const Fe=`${N.url}${Y}`;await xC(N.id,Fe,oe,N.basename),ee.push(OC(N,N.size,ce.size)),I+=ce.size,V++,y(N.path,N.size,ce.size),m(`Successfully replaced asset ${N.path}`)}catch(oe){m(`Error replacing asset: ${oe instanceof Error?oe.message:String(oe)}`),K.push(ao(N)),U++}}catch(Y){m(`Error optimizing asset ${N.path}: ${Y instanceof Error?Y.message:String(Y)}`),K.push(ao(N)),U++}}l({optimized:V,skipped:q,failed:U,totalAssets:j,optimizedAssets:ee,skippedAssets:X,failedAssets:K}),m(`Optimization complete. Optimized: ${V}, Skipped: ${q}, Failed: ${U}`),V>0&&m(`Total size savings: ${Rn(re-I)} (${Math.round((re-I)/re*100)}%)`),m("Asset optimization process completed!"),e.notice("Asset optimization process completed!")}catch(O){m(`Error during optimization process: ${O instanceof Error?O.message:String(O)}`),e.alert(`Error during optimization process: ${O instanceof Error?O.message:String(O)}`)}finally{n(!1)}},w=()=>{l(null),c([]),i(0),a(0),p(void 0)};return _.jsx(xd,{ctx:e,children:_.jsxs("div",{className:T.container,children:[_.jsx("h1",{className:T.title,children:"Asset Optimization"}),!t&&!u&&_.jsx("div",{className:T.settingsContainer,children:_.jsx(vC,{settings:d,onSettingsChange:f,onStartOptimization:g,ctx:e})}),_.jsx(_C,{current:r,total:o,isVisible:t,assetSizeCategory:d.veryLargeAssetThreshold>0?"large and very large":"large",currentAsset:h}),u&&_.jsxs(_.Fragment,{children:[_.jsx(wC,{result:u,setSelectedCategory:E,resetState:w,largeAssetThreshold:d.largeAssetThreshold}),v&&_.jsx(SC,{assets:v==="optimized"?u.optimizedAssets:v==="skipped"?u.skippedAssets:u.failedAssets,category:v,onClose:()=>E(null),ctx:e})]}),_.jsx(gC,{log:s})]})})};var Tm,ld=Oh;Tm=ld.createRoot,ld.hydrateRoot;const PC=document.getElementById("root"),TC=Tm(PC);function cd(e){TC.render(_.jsx(k.StrictMode,{children:e}))}Dy({renderConfigScreen(e){return cd(_.jsx(kS,{ctx:e}))},settingsAreaSidebarItemGroups(e){return e.currentRole.attributes.can_edit_schema?[{label:"Asset Management",items:[{label:"Optimize assets",icon:"images",pointsTo:{pageId:"optimize-assets"}}]}]:[]},renderPage(e,t){switch(e){case"optimize-assets":return cd(_.jsx(CC,{ctx:t}))}}});
|
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta charset="UTF-8" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>DatoCMS Plugin</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-D-wiKUz0.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-hUEE8hR4.css">
|
|
10
10
|
</head>
|
|
11
11
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A plugin that allows you to mass apply optimizations to your DatoCMS assets.",
|
|
4
4
|
"homepage": "https://github.com/marcelofinamorvieira/datocms-plugin-asset-optimization",
|
|
5
5
|
"private": false,
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.3.0",
|
|
7
7
|
"author": "marcelofinamorvieira <marcelofinamorvieira@gmail.com>",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"keywords": [
|