@kizenapps/cli 1.0.0 → 1.1.0-431518c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/viewer/assets/CodeStepsPage-nECzIPiV.js +1 -0
- package/dist/viewer/assets/ConfigurationPage-D0tcJxje.js +1 -0
- package/dist/viewer/assets/SandboxPage-Bnp6YAtk.js +1 -0
- package/dist/viewer/assets/{WhenBadge-P9aN2Qd7.js → WhenBadge-pfupnVMz.js} +1 -1
- package/dist/viewer/assets/{calendarSource.worker-C9iglnKD.js → calendarSource.worker-DGRTJYHs.js} +4 -4
- package/dist/viewer/assets/configStorage-TfZCyGrB.js +10 -0
- package/dist/viewer/assets/floatingFrame.worker-CKAMagoG.js +23 -0
- package/dist/viewer/assets/{generic.worker-DRXu0-5B.js → generic.worker-Bzr3c9PO.js} +4 -4
- package/dist/viewer/assets/{index-BXPMaCXm.js → index-BVpA7WNR.js} +2 -2
- package/dist/viewer/assets/{recordDetail.worker-C0-mQTaj.js → recordDetail.worker-B-1qFS5m.js} +6 -6
- package/dist/viewer/assets/useCriticalExceptionDialog-FcLgRoVH.js +5 -0
- package/dist/viewer/index.html +1 -1
- package/package.json +2 -2
- package/dist/viewer/assets/CodeStepsPage-bUqixBkt.js +0 -1
- package/dist/viewer/assets/ConfigurationPage-egBHLNoe.js +0 -1
- package/dist/viewer/assets/SandboxPage-CWOkZs5g.js +0 -1
- package/dist/viewer/assets/configStorage-DcQWEL9-.js +0 -10
- package/dist/viewer/assets/floatingFrame.worker-CWLtchq3.js +0 -23
- package/dist/viewer/assets/useCriticalExceptionDialog-BI_gNDBK.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{A as t,j as n}from"./fa-core-BoBqCOD3.js";import{t as r}from"./Tooltip-tpqNw0op.js";import{
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{A as t,j as n}from"./fa-core-BoBqCOD3.js";import{t as r}from"./Tooltip-tpqNw0op.js";import{u as i}from"./configStorage-TfZCyGrB.js";var a=e(n(),1),o=t(),s=({when:e,whenState:t})=>{let[n,s]=(0,a.useState)(null);return(0,a.useEffect)(()=>{i(e,t).then(s).catch(()=>{s(null)})},[e,t]),n===null?null:(0,o.jsx)(r,{text:e,children:(0,o.jsxs)(`span`,{className:`font-mono text-[10px] ${n?`text-green-600`:`text-amber-600`}`,children:[n?`enabled`:`disabled`,` by condition`]})})};export{s as t};
|
package/dist/viewer/assets/{calendarSource.worker-C9iglnKD.js → calendarSource.worker-DGRTJYHs.js}
RENAMED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
this.__setup();
|
|
17
17
|
this.onError({ message: "The script has a syntax error and could not be parsed" });
|
|
18
18
|
this.__cleanup();
|
|
19
|
-
`;return{fn:new l(e),functionBody:e}}},d=class{promises;isDebug;constructor({isDebug:e=!1}){this.promises=new Map,this.isDebug=e}delete(e){this.isDebug&&console.log(`Deleting promise ${e}`),this.promises.delete(e)}get(e){return this.isDebug&&console.log(`Getting promise ${e}`),this.promises.get(e)}set(e,t,n){this.promises.set(e,{resolve:t,reject:n})}id(){return c()}register(e,t){let n=this.id();return this.set(n,e,t),n}resolve(e,t){this.get(e)?.resolve(t),this.delete(e)}reject(e,t){this.get(e)?.reject(t),this.delete(e)}},f=e=>({key:`action__${e.api_name}`,type:`custom_object`,label:e.name,allow_multiple:!0}),
|
|
20
|
-
return ${`(${e.toString()})({ state: {{${t}}}, args: ${JSON.stringify(n)}, utils: __kizen_utils })`}; })()`,
|
|
19
|
+
`;return{fn:new l(e),functionBody:e}}},d=class{promises;isDebug;constructor({isDebug:e=!1}){this.promises=new Map,this.isDebug=e}delete(e){this.isDebug&&console.log(`Deleting promise ${e}`),this.promises.delete(e)}get(e){return this.isDebug&&console.log(`Getting promise ${e}`),this.promises.get(e)}set(e,t,n){this.promises.set(e,{resolve:t,reject:n})}id(){return c()}register(e,t){let n=this.id();return this.set(n,e,t),n}resolve(e,t){this.get(e)?.resolve(t),this.delete(e)}reject(e,t){this.get(e)?.reject(t),this.delete(e)}},f=class e extends Error{proxyStatus;upstreamStatus;upstreamResponse;constructor(t,n,r,i){super(i??r?.error?.message??(n?`Request failed with status code ${String(n)}`:`Request failed with proxy status code ${String(t)}`)),this.name=`KizenRequestError`,this.proxyStatus=t,this.upstreamStatus=n,this.upstreamResponse=r,Object.setPrototypeOf(this,e.prototype)}},p=e=>({key:`action__${e.api_name}`,type:`custom_object`,label:e.name,allow_multiple:!0}),m=(e,t)=>{let n=(e.fields??[]).filter(e=>e.type!==`container`&&e.type!==`description`).map(e=>({...e,when:t?`(${t}) && (${e.when??`true`})`:e.when})),r=(e.fields??[]).filter(e=>e.type===`container`).flatMap(e=>m(e,e.when)),i=e.actions?.filter(e=>e.hint_object_name)??[];return[...n,...r,...i.map(e=>({...p(e),match_hint:e.hint_object_name??``}))]},h=(e,t)=>{let n=m(e).reduce((e,t)=>({...e,[t.key]:t}),{}),r=Object.keys(t),i={};return r.forEach(e=>{let r=t[e],a=n[e];if(a?.type){switch(a.type){case`boolean`:let t=r;if(!t)return;i[e]=t.value;return;case`custom_object`:{let t=r;if(!t)return;i[e]={objectId:t.value?.id,objectName:t.value?.objectName};return}case`field`:{let t=r;if(!t?.value)return;Array.isArray(t.value)?i[e]=t.value.map(e=>({fieldId:e.value,fieldName:e.label,objectId:t.associatedObject?.id,objectName:t.associatedObject?.name})):typeof t.value==`object`&&typeof t.associatedObject==`object`&&(i[e]={fieldId:t.value.value,fieldName:t.value.label,objectId:t.associatedObject.id,objectName:t.associatedObject.name});return}case`number`:{let t=r;if(!t)return;try{let n=Number(t.value);if(!n&&n!==0)return;i[e]=n}catch{i[e]=NaN}return}case`select`:{let t=r;if(!t)return;i[e]=t.value;return}case`text`:{let t=r?.value;if(t){i[e]=t;return}let n=a.default;n&&(i[e]=n);return}case`description`:case`container`:return}return r?.value}}),i},g=(t,n)=>r=>async(i,a,o)=>new Promise((s,c)=>{let l=n.register(s,c);t.postMessage(JSON.stringify({action:e.QUERY_REQUEST,id:l,method:r,url:i,payload:a,options:o}))}),_=(t,n)=>(r,i,a=!0)=>new Promise((o,s)=>{let c=n.register(o,s);t.postMessage(JSON.stringify({action:e.POSTFORMDATA_REQUEST,url:r,id:c,payload:i,createNewTab:a}))}),v=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.PROMPT_REQUEST,id:o,config:r}))}),y=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.DYNAMIC_PROMPT_REQUEST,id:o,config:r}))}),b=(e,n,r)=>{switch(e){case t.QUERY_RESPONSE:{let{id:e,data:t,error:i}=JSON.parse(n.data);if(i){let t=typeof i==`object`&&`__kizenError`in i?new f(i.proxyStatus,i.upstreamStatus,i.upstreamResponse,i.message):i;r.reject(e,t)}else r.resolve(e,t);break}case t.POSTFORMDATA_RESPONSE:{let{id:e,success:t}=JSON.parse(n.data);t?r.resolve(e):r.reject(e);break}case t.UPLOADFILE_RESPONSE:{let{id:e,data:t,error:i}=JSON.parse(n.data);t?r.resolve(e,t):r.reject(e,i);break}case t.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);t.success?r.resolve(e,t):r.reject(e);break}case t.PROMPT_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);r.resolve(e,t);break}case t.CREATE_RECORD_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);r.resolve(e,t);break}case t.CREATE_RELATED_RECORD_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);r.resolve(e,t);break}case t.REFRESH_ENTITY_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);t.success?r.resolve(e,!0):r.reject(e);break}}},x=`integration:${n.RUN_FRAME_SCRIPT}`,S=class{instance;constructor(e){this.instance=e}runFrameScript(t,r,i){this.instance.postMessage(JSON.stringify({action:e.COMMUNICATE,type:n.RUN_FRAME_SCRIPT,eventName:x,recipient:{frame:t,script:r},args:i}))}sendMessageToOwnFrame(t,r){this.instance.postMessage(JSON.stringify({action:e.COMMUNICATE,type:n.SEND_MESSAGE_TO_FRAME,args:{payload:t,path:r}}))}},C=async e=>{let t=null;try{t=await e.json()}catch{}return{status:e.status,statusText:e.statusText,body:t}},w=(e,t,n={},r=``)=>`(function() { ${r}
|
|
20
|
+
return ${`(${e.toString()})({ state: {{${t}}}, args: ${JSON.stringify(n)}, utils: __kizen_utils })`}; })()`,T=class{user;teamMember;business;clientObject;appPath;dataCache=new Map;queryOptions={};api;postFormData;executionTimer=0;setupExecutions=0;cleanupExecutions=0;isDebug=!1;scriptBody;internalState={indicator:`none`};console=console;instance;breakOnException=!1;args;communicate;shouldPreserve=!1;uploadFileHandler;internalSessionData;pluginComponentId;installThirdPartyScriptHandler;promptHandler;dynamicPromptHandler;refreshEntityHandler;openCreateRecordHandler;openCreateRelatedRecordHandler;runnerType;pluginApiName;tempPromptState={};partialLocation;constructor({user:e,teamMember:t,business:n,clientObject:r,appPath:i,isDebug:a,kizenRequest:o,postFormData:s,scriptBody:c,instance:l,args:u,uploadFile:d,sessionData:f,pluginComponentId:p,installThirdPartyScript:m,prompt:h,refreshEntity:g,openCreateRecord:_,openCreateRelatedRecord:v,pluginApiName:y,dynamicPrompt:b,location:x}){this.user=e,this.teamMember=t,this.business=n,this.clientObject=r,this.partialLocation=x,this.appPath=i,this.isDebug=a??!1,this.api={get:o(`get`),post:o(`post`),put:o(`put`),delete:o(`delete`),patch:o(`patch`)},this.postFormData=s,this.scriptBody=c,this.instance=l,this.communicate=new S(l),this.uploadFileHandler=d,this.internalSessionData=f??{},this.pluginComponentId=p,this.installThirdPartyScriptHandler=m,this.promptHandler=h,this.refreshEntityHandler=g,this.openCreateRecordHandler=_,this.openCreateRelatedRecordHandler=v,this.runnerType=`base`,this.pluginApiName=y,this.dynamicPromptHandler=b;try{this.args=JSON.parse(u??`{}`)}catch{this.args={}}}onError(e){if(this.breakOnException)debugger;this.instance.postMessage(JSON.stringify({action:t.ERROR,error:e?.message}))}set debug(e){this.isDebug=e,this.breakOnException=e}set preserve(e){this.shouldPreserve=e}get preserve(){return this.shouldPreserve}parseDate(e){return e.split(`-`)}parsePhone(e){return e.replace(/\+/g,``)}openWindow(t,n=`_blank`){this.instance.postMessage(JSON.stringify({action:e.OPEN_WINDOW,url:t,target:n,features:`noopener noreferrer`}))}authorize(t,n={}){if(!t)throw Error(`Service name is required to authorize`);this.instance.postMessage(JSON.stringify({action:e.AUTHORIZE,serviceName:t,config:{successRedirectPath:n.successRedirectPath??`/marketplace/${this.pluginApiName}/auth`,errorRedirectPath:n.errorRedirectPath??`/marketplace/${this.pluginApiName}/auth`}}))}getServiceUrl(e,t){if(!e)throw Error(`Service name is required to get a service url`);let n=`/external-integrations/proxy/${this.pluginApiName}/${e}`;return t.startsWith(`/`)?`${n}${t}`:`${n}/${t}`}get currentBusiness(){return this.business}get applicationPath(){return this.appPath}get currentUser(){return{profile:{id:this.teamMember?.id??``,full_name:this.teamMember?.full_name??``,first_name:this.teamMember?.first_name??``,last_name:this.teamMember?.last_name??``,email:this.teamMember?.email??``,phone:this.teamMember?.phone??``,created:this.teamMember?.created??``,crm_client_id:this.user?.crm_client_id??``}}}get sessionData(){return this.internalSessionData}get config(){return this.args.__kizen_clean_config?new Proxy(this.args.__kizen_clean_config??{},{get:(e,t)=>{if(Reflect.has(e,t))return Reflect.get(e,t)}}):{}}get location(){return new Proxy(this.partialLocation,{get:(e,t)=>{if(t===`toJSON`)return()=>this.partialLocation;if(Reflect.has(e,t))return Reflect.get(e,t);throw Error(`Property ${String(t)} is not available on location object for plugin apps`)}})}get userConfig(){let e=this.args.__kizen_user_config?.__kizen_clean_config;return e?new Proxy(e,{get:(e,t)=>{if(Reflect.has(e,t))return Reflect.get(e,t)}}):{}}setSessionData(t){if(typeof t!=`object`)throw Error(`Invalid session update with type ${typeof t}`);if(Array.isArray(t))throw Error(`Invalid session update with type array`);this.internalSessionData={...this.internalSessionData,...t},this.instance.postMessage(JSON.stringify({action:e.UPDATE_SESSION_DATA,update:t}))}async get(e,t){try{if(this.isRelativeUrl(e)){let n=this.dataCache.get(e);if(n&&!t?.ignoreCache)return t?.returnErrors?[n.data,null]:n.data;let{data:r}=await this.api.get(e,{...this.queryOptions,headers:this.buildHeaders(t?.headers)});return this.dataCache.set(e,{ts:Date.now(),data:r}),t?.returnErrors?[r,null]:r}else{let n=await fetch(e,{method:`GET`,headers:new Headers(t?.headers),credentials:t?.credentials??`same-origin`});if(!n.ok)throw await C(n);let r=await n.json();return t?.returnErrors?[r,null]:r}}catch(e){if(t?.returnErrors)return[null,e];this.onError(e)}}async getWithErrors(e,t){return this.get(e,{...t,returnErrors:!0})}async getUserConfig(){if(!this.args.pluginId||!this.pluginComponentId)throw Error(`User config is not available for scripts not associated to a plugin or plugin component`);return(await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0})).config?.[this.pluginComponentId]??{}}async setUserConfig(e){if(!this.args.pluginId||!this.pluginComponentId)throw Error(`User config is not available for scripts not associated to a plugin or plugin component`);let t=await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0});return await this.post(`/employee/mine/configs/plugins/${this.args.pluginId}`,{config:{...t?.config,[this.pluginComponentId]:{...t?.config?.[this.pluginComponentId],...e}}})}async patch(e,t,n){try{if(this.isRelativeUrl(e)){let{data:r}=await this.api.patch(e,t,{...this.queryOptions,headers:n?.headers});return n?.returnErrors?[r,null]:r}else{let r=await fetch(e,{method:`PATCH`,body:t?JSON.stringify(t):null,headers:new Headers(n?.headers),credentials:n?.credentials??`same-origin`});if(!r.ok)throw await C(r);let i=await r.json();return n?.returnErrors?[i,null]:i}}catch(e){if(n?.returnErrors)return[null,e];this.onError(e)}}async patchWithErrors(e,t,n){return this.patch(e,t,{...n,returnErrors:!0})}async post(e,t,n){try{if(this.isRelativeUrl(e)){let{data:r}=await this.api.post(e,t,{...this.queryOptions,headers:this.buildHeaders(n?.headers)});return n?.returnErrors?[r,null]:r}else{let r=await fetch(e,{method:`POST`,body:t?JSON.stringify(t):null,headers:new Headers(n?.headers),credentials:n?.credentials??`same-origin`});if(!r.ok)throw await C(r);let i=await r.json();return n?.returnErrors?[i,null]:i}}catch(e){if(n?.returnErrors)return[null,e];this.onError(e)}}async postWithErrors(e,t,n){return this.post(e,t,{...n,returnErrors:!0})}async delete(e,t){try{if(this.isRelativeUrl(e)){let{data:n}=await this.api.delete(e,{...this.queryOptions,headers:this.buildHeaders(t?.headers)});return t?.returnErrors?[n,null]:n}else{let n=await fetch(e,{method:`DELETE`,headers:new Headers(t?.headers),credentials:t?.credentials??`same-origin`});if(!n.ok)throw await C(n);let r=null;return n.status!==204&&(r=await n.json()),t?.returnErrors?[r,null]:r}}catch(e){if(t?.returnErrors)return[null,e];this.onError(e)}}async deleteWithErrors(e,t){return this.delete(e,{...t,returnErrors:!0})}async openCreateRecordModal(e){return this.openCreateRecordHandler(e)}async openCreateRelatedRecordModal(e,t){return this.openCreateRelatedRecordHandler(e,t)}showToast(t,n){this.instance.postMessage(JSON.stringify({action:e.SHOW_TOAST,message:t,toastOptions:n}))}clearToasts(){this.instance.postMessage(JSON.stringify({action:e.CLEAR_TOASTS}))}outputUI(t){this.instance.postMessage(JSON.stringify({action:e.UI_OUTPUT,markup:t}))}prompt(e){return this.promptHandler(e)}async dynamicPrompt(e){let t=`__kizen_state`,n=`const __kizen_utils = {};
|
|
21
21
|
`;if(e.registerUtils){let t=Object.keys(e.registerUtils);n+=t.map(t=>{let n=e.registerUtils?.[t];if(typeof n!=`function`)throw Error(`Registered util ${t} is not a function, got ${typeof n}`);return`__kizen_utils["${t}"] = (${n.toString()});`}).join(`
|
|
22
|
-
`)}let r=e.content?.map(e=>{let r=``;`optionMapper`in e&&(r=
|
|
22
|
+
`)}let r=e.content?.map(e=>{let r=``;`optionMapper`in e&&(r=w(e.optionMapper,t,e.args,n));let i=``;`getFetchUrl`in e&&(i=w(e.getFetchUrl,t,e.args,n));let a=``;`getHeaders`in e&&(a=w(e.getHeaders,t,e.args,n));let o=``;return`getBody`in e&&(o=w(e.getBody,t,e.args,n)),{...e,optionMapper:r,getFetchUrl:i,getHeaders:a,getBody:o}}),i={...e,content:r},a={fields:i.content},o=await this.dynamicPromptHandler(i),s=h(a,o.values);return{...o,values:s}}outputIframe(t,n,r){this.instance.postMessage(JSON.stringify({action:e.IFRAME_OUTPUT,url:t,allow:n,sandbox:r,preserve:this.preserve}))}getBase64EncodedBlob(e){return new Promise((t,n)=>{let r=new FileReader;r.readAsDataURL(e),r.onload=()=>{t(r.result)},r.onerror=e=>{n(e)}})}async uploadFile(e,t,n=!1){let r=await this.getBase64EncodedBlob(e);return await this.uploadFileHandler({file:r,fileName:t??`file_`+String(Date.now()),isPublic:n})}afterSetup(){}__setup(){if(this.setupExecutions!==0)throw Error(`Setup must be called exactly once, and should never be called by a script directly.`);if(this.cleanupExecutions!==0)throw Error(`Setup was called after cleanup`);this.isDebug&&this.console.log(`Running script:
|
|
23
23
|
|
|
24
|
-
${this.scriptBody}`),this.setupExecutions++,this.executionTimer=performance.now(),this.afterSetup()}__cleanup(e){if(this.cleanupExecutions!==0)throw Error(`Cleanup must be called exactly once, and should never be called by a script directly.`);if(this.setupExecutions!==1)throw Error(`Cleanup was called before setup`);this.cleanupExecutions++,this.setIndicator(`none`);let t=performance.now();this.isDebug&&this.console.log(`Script execution took ${String(t-this.executionTimer)}ms`),this.done(this.preserve,e)}setIndicator(e=`none`){this.internalState.indicator=e,this.setState({indicator:e})}wait(e){return new Promise(t=>setTimeout(t,e))}done(t,n){this.instance.postMessage(JSON.stringify({action:e.DONE,result:n,preserve:t}))}setState(t){this.instance.postMessage(JSON.stringify({action:e.SETSTATE,state:t}))}isRelativeUrl(e){return e.startsWith(`/`)}buildHeaders(e={}){return{...e,"X-Request-Type":`kizen-ui-scripting-api`}}refreshTimelineForId(t){t&&this.instance.postMessage(JSON.stringify({action:e.REFRESH_TIMELINE,entityId:t}))}refreshEntityForId(e){if(e)return this.refreshEntityHandler(e)}async installThirdPartyScript(e){try{let t=await this.installThirdPartyScriptHandler(e,this.args);return new s(this.instance,t.url)}catch{this.onError(Error(`Third party script ${e} could not be installed.`))}}releaseBlockingScript(){this.instance.postMessage(JSON.stringify({action:e.RELEASE_BLOCKING_SCRIPT}))}copyToClipboard(t){this.instance.postMessage(JSON.stringify({action:e.COPY_TO_CLIPBOARD,text:t}))}createDateObject(e){if(typeof e!=`string`)throw Error(`Invalid date string ${String(e)}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw Error(`Date string ${e} is not in the format YYYY-MM-DD`);let t=e.split(`-`).map(e=>parseInt(e,10));if(t.length<3)throw Error(`Date string ${e} could not be parsed into valid date parts`);return new Date(t[0],t[1]-1,t[2])}formatDateForResponse(e){return e.getTime()}},
|
|
24
|
+
${this.scriptBody}`),this.setupExecutions++,this.executionTimer=performance.now(),this.afterSetup()}__cleanup(e){if(this.cleanupExecutions!==0)throw Error(`Cleanup must be called exactly once, and should never be called by a script directly.`);if(this.setupExecutions!==1)throw Error(`Cleanup was called before setup`);this.cleanupExecutions++,this.setIndicator(`none`);let t=performance.now();this.isDebug&&this.console.log(`Script execution took ${String(t-this.executionTimer)}ms`),this.done(this.preserve,e)}setIndicator(e=`none`){this.internalState.indicator=e,this.setState({indicator:e})}wait(e){return new Promise(t=>setTimeout(t,e))}done(t,n){this.instance.postMessage(JSON.stringify({action:e.DONE,result:n,preserve:t}))}setState(t){this.instance.postMessage(JSON.stringify({action:e.SETSTATE,state:t}))}isRelativeUrl(e){return e.startsWith(`/`)}buildHeaders(e={}){return{...e,"X-Request-Type":`kizen-ui-scripting-api`}}refreshTimelineForId(t){t&&this.instance.postMessage(JSON.stringify({action:e.REFRESH_TIMELINE,entityId:t}))}refreshEntityForId(e){if(e)return this.refreshEntityHandler(e)}async installThirdPartyScript(e){try{let t=await this.installThirdPartyScriptHandler(e,this.args);return new s(this.instance,t.url)}catch{this.onError(Error(`Third party script ${e} could not be installed.`))}}releaseBlockingScript(){this.instance.postMessage(JSON.stringify({action:e.RELEASE_BLOCKING_SCRIPT}))}copyToClipboard(t){this.instance.postMessage(JSON.stringify({action:e.COPY_TO_CLIPBOARD,text:t}))}createDateObject(e){if(typeof e!=`string`)throw Error(`Invalid date string ${String(e)}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw Error(`Date string ${e} is not in the format YYYY-MM-DD`);let t=e.split(`-`).map(e=>parseInt(e,10));if(t.length<3)throw Error(`Date string ${e} could not be parsed into valid date parts`);return new Date(t[0],t[1]-1,t[2])}formatDateForResponse(e){return e.getTime()}},E=new d({isDebug:!1}),D=null,O=e=>()=>new Promise((t,n)=>{n(Error(`${e} is not supported in calendar source scripts`))});self.onmessage=async t=>{let{action:n,script:r,setup:i,args:a,sessionData:o={},pluginComponentId:s,pluginApiName:c,location:l}=JSON.parse(t.data);if(n===e.RUN&&i&&r){let{fn:e,functionBody:t}=u(r);D=new T({user:i.user,teamMember:i.teamMember,business:i.business,clientObject:i.clientObject,isDebug:i.isDebug,appPath:i.appPath,scriptBody:r,functionBody:t,instance:self,kizenRequest:g(self,E),postFormData:_(self,E),uploadFile:O(`uploadFile`),installThirdPartyScript:O(`installThirdPartyScript`),args:a??``,sessionData:o,pluginComponentId:s,prompt:v(self,E),dynamicPrompt:y(self,E),refreshEntity:O(`refreshEntity`),openCreateRecord:O(`openCreateRecord`),openCreateRelatedRecord:O(`openCreateRelatedRecord`),pluginApiName:c,location:l}),await e.bind(D)()}else b(n,t,E)}})();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{a as e,i as t}from"./storageKeys-C6c8YF5Y.js";var n={QUERY_REQUEST:`query:request`,UI_OUTPUT:`outputui`,IFRAME_OUTPUT:`iframeoutput`,POSTFORMDATA_REQUEST:`postformdata:request`,SETSTATE:`setstate`,DONE:`done`,RUN:`run`,OPEN_WINDOW:`openwindow`,COMMUNICATE:`communicate`,HIDE:`hide`,SHOW:`show`,EXPAND:`expand`,COLLAPSE:`collapse`,HIDE_HEADER:`hideheader`,SHOW_HEADER:`showheader`,OPEN_CREATE_RECORD_MODAL_REQUEST:`opencreaterecordmodal:request`,OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST:`opencreaterelatedrecordmodal:request`,SHOW_TOAST:`showtoast`,CLEAR_TOASTS:`cleartoasts`,REFRESH_TIMELINE:`refreshtimeline`,REFRESH_ENTITY:`refreshentity`,UPLOADFILE_REQUEST:`uploadfile:request`,UPDATE_SESSION_DATA:`updatesessiondata`,INSTALL_THIRD_PARTY_SCRIPT_REQUEST:`installthirdpartyscript:request`,PROMPT_REQUEST:`prompt:request`,DYNAMIC_PROMPT_REQUEST:`dynamicprompt:request`,RELEASE_BLOCKING_SCRIPT:`releaseblockingscript`,AUTHORIZE:`authorize`,COPY_TO_CLIPBOARD:`copytoclipboard`},r={QUERY_RESPONSE:`query:response`,POSTFORMDATA_RESPONSE:`postformdata:response`,ERROR:`error`,UPLOADFILE_RESPONSE:`uploadfile:response`,UPLOADFILE_PROGRESS:`uploadfile:progress`,INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:`installthirdpartyscript:response`,PROMPT_RESPONSE:`prompt:response`,REFRESH_ENTITY_RESPONSE:`refreshentity:response`,CREATE_RECORD_RESPONSE:`createrecord:response`,CREATE_RELATED_RECORD_RESPONSE:`createrelatedrecord:response`},i={RUN_FRAME_SCRIPT:`runframescript`,SEND_MESSAGE_TO_FRAME:`sendmessagetoframe`,CALL_THIRD_PARTY_SCRIPT:`callthirdpartyscript`},a=`integration:route-change`,o=`kizen-route-change`,s=`kzn-integration-frame`,c=[`__plugin_engine`,`1.3.0`],l={CALENDAR_SOURCE_CALENDAR_LIST:(e,t)=>[...c,`calendar-source`,`calendar-list`,e,t],CALENDAR_SOURCE_EVENTS:(e,t,n,r)=>[...c,`calendar-source`,`events`,e,t,n,r]},u=/https:\/\/.*widget\.freshworks\.com\/.*\.js/,d=/https:\/\/widget\.intercom\.io\/widget\/[a-z0-9]+/,f={FRESHWORKS:`freshworks`,INTERCOM:`intercom`},p=e=>{if(u.test(e))return f.FRESHWORKS;if(d.test(e))return f.INTERCOM},m={[f.FRESHWORKS]:`FreshworksWidget`,[f.INTERCOM]:`Intercom`},h={[f.FRESHWORKS]:e=>{window.fwSettings={widget_id:e.widgetId},(function(...e){if(typeof window[m[f.FRESHWORKS]]!=`function`){let t=function(){t.q.push(...e)};t.__kizen_pending=!0,t.q=[],window[m[f.FRESHWORKS]]=t}})()},[f.INTERCOM]:()=>{(function(){if(typeof window[m[f.INTERCOM]]!=`function`){let e=window,t=function(){t.c(arguments)};t.q=[],t.c=function(e){t.q.push(e)},t.__kizen_pending=!0,e[m[f.INTERCOM]]=t}})()}},g={[f.FRESHWORKS]:()=>window[m[f.FRESHWORKS]]?.__kizen_pending!==!0,[f.INTERCOM]:()=>window[m[f.INTERCOM]]?.__kizen_pending!==!0},_=()=>({host:window.location.host,hash:window.location.hash,href:window.location.href,origin:window.location.origin,pathname:window.location.pathname,search:window.location.search,port:window.location.port,protocol:window.location.protocol}),v=()=>{let e=new Date().getTime();return typeof performance<`u`&&typeof performance.now==`function`&&(e+=performance.now()),`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let n=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t===`x`?n:n&3|8).toString(16)})};Object.getPrototypeOf(async function(){}).constructor;var y=e=>`${e?.plugin_api_name??``}-${e?.id??``}-${e?.api_name??``}-${e?.script_id??``}`,b=class e extends Error{proxyStatus;upstreamStatus;upstreamResponse;constructor(t,n,r,i){super(i??r?.error?.message??(n?`Request failed with status code ${String(n)}`:`Request failed with proxy status code ${String(t)}`)),this.name=`KizenRequestError`,this.proxyStatus=t,this.upstreamStatus=n,this.upstreamResponse=r,Object.setPrototypeOf(this,e.prototype)}},x=Object.create,S=Object.defineProperty,C=Object.getOwnPropertyDescriptor,w=Object.getOwnPropertyNames,T=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty,E=(e,t)=>function(){return t||(0,e[w(e)[0]])((t={exports:{}}).exports,t),t.exports},te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of w(t))!ee.call(e,i)&&i!==n&&S(e,i,{get:()=>t[i],enumerable:!(r=C(t,i))||r.enumerable});return e},D=(e,t,n)=>(n=e==null?{}:x(T(e)),te(t||!e||!e.__esModule?S(n,`default`,{value:e,enumerable:!0}):n,e)),{entries:O,setPrototypeOf:k,isFrozen:A,getPrototypeOf:j,getOwnPropertyDescriptor:ne}=Object,{freeze:M,seal:N,create:P}=Object,{apply:re,construct:ie}=typeof Reflect<`u`&&Reflect;M||=function(e){return e},N||=function(e){return e},re||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},ie||=function(e){return new e(...[...arguments].slice(1))};var ae=L(Array.prototype.forEach),oe=L(Array.prototype.lastIndexOf),se=L(Array.prototype.pop),ce=L(Array.prototype.push),le=L(Array.prototype.splice),ue=L(String.prototype.toLowerCase),de=L(String.prototype.toString),fe=L(String.prototype.match),pe=L(String.prototype.replace),me=L(String.prototype.indexOf),he=L(String.prototype.trim),F=L(Object.prototype.hasOwnProperty),I=L(RegExp.prototype.test),ge=_e(TypeError);function L(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return re(e,t,n)}}function _e(e){return function(){return ie(e,[...arguments])}}function R(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ue;k&&k(e,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(A(t)||(t[r]=e),i=e)}e[i]=!0}return e}function z(e){for(let t=0;t<e.length;t++)F(e,t)||(e[t]=null);return e}function B(e){let t=P(null);for(let[n,r]of O(e))F(e,n)&&(Array.isArray(r)?t[n]=z(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=B(r):t[n]=r);return t}function ve(e,t){for(;e!==null;){let n=ne(e,t);if(n){if(n.get)return L(n.get);if(typeof n.value==`function`)return L(n.value)}e=j(e)}function n(){return null}return n}var ye=M(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),be=M(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),xe=M([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Se=M([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Ce=M(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),we=M([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Te=M([`#text`]),Ee=M(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns.slot`.split(`.`)),De=M(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Oe=M(`accent.accentunder.align.bevelled.close.columnsalign.columnlines.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lspace.lquote.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),ke=M([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Ae=N(/\{\{[\w\W]*|[\w\W]*\}\}/gm),V=N(/<%[\w\W]*|[\w\W]*%>/gm),je=N(/\$\{[\w\W]*/gm),Me=N(/^data-[\-\w.\u00B7-\uFFFF]+$/),H=N(/^aria-[\-\w]+$/),Ne=N(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Pe=N(/^(?:\w+script|data):/i),Fe=N(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ie=N(/^html$/i),Le=N(/^[a-z][.\w]*(-[.\w]+)+$/i),Re=Object.freeze({__proto__:null,ARIA_ATTR:H,ATTR_WHITESPACE:Fe,CUSTOM_ELEMENT:Le,DATA_ATTR:Me,DOCTYPE_NAME:Ie,ERB_EXPR:V,IS_ALLOWED_URI:Ne,IS_SCRIPT_OR_DATA:Pe,MUSTACHE_EXPR:Ae,TMPLIT_EXPR:je}),ze={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Be=function(){return typeof window>`u`?null:window},Ve=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},He=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ue(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Be(),t=e=>Ue(e);if(t.version=`3.3.3`,t.removed=[],!e||!e.document||e.document.nodeType!==ze.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e,r=n,i=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:c,NodeFilter:l,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,m=c.prototype,h=ve(m,`cloneNode`),g=ve(m,`remove`),_=ve(m,`nextSibling`),v=ve(m,`childNodes`),y=ve(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let b,x=``,{implementation:S,createNodeIterator:C,createDocumentFragment:w,getElementsByTagName:T}=n,{importNode:ee}=r,E=He();t.isSupported=typeof O==`function`&&typeof y==`function`&&S&&S.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:te,ERB_EXPR:D,TMPLIT_EXPR:k,DATA_ATTR:A,ARIA_ATTR:j,IS_SCRIPT_OR_DATA:ne,ATTR_WHITESPACE:N,CUSTOM_ELEMENT:re}=Re,{IS_ALLOWED_URI:ie}=Re,L=null,_e=R({},[...ye,...be,...xe,...Ce,...Te]),z=null,Ae=R({},[...Ee,...De,...Oe,...ke]),V=Object.seal(P(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),je=null,Me=null,H=Object.seal(P(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Pe=!0,Fe=!0,Le=!1,We=!0,U=!1,Ge=!0,W=!1,Ke=!1,qe=!1,G=!1,Je=!1,Ye=!1,Xe=!0,Ze=!1,Qe=!0,$e=!1,K={},q=null,et=R({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),tt=null,nt=R({},[`audio`,`video`,`img`,`source`,`image`,`track`]),rt=null,it=R({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),at=`http://www.w3.org/1998/Math/MathML`,ot=`http://www.w3.org/2000/svg`,J=`http://www.w3.org/1999/xhtml`,st=J,ct=!1,lt=null,ut=R({},[at,ot,J],de),dt=R({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),ft=R({},[`annotation-xml`]),pt=R({},[`title`,`style`,`font`,`a`,`script`]),mt=null,ht=[`application/xhtml+xml`,`text/html`],Y=null,X=null,gt=n.createElement(`form`),_t=function(e){return e instanceof RegExp||e instanceof Function},vt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(X&&X===e)){if((!e||typeof e!=`object`)&&(e={}),e=B(e),mt=ht.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Y=mt===`application/xhtml+xml`?de:ue,L=F(e,`ALLOWED_TAGS`)?R({},e.ALLOWED_TAGS,Y):_e,z=F(e,`ALLOWED_ATTR`)?R({},e.ALLOWED_ATTR,Y):Ae,lt=F(e,`ALLOWED_NAMESPACES`)?R({},e.ALLOWED_NAMESPACES,de):ut,rt=F(e,`ADD_URI_SAFE_ATTR`)?R(B(it),e.ADD_URI_SAFE_ATTR,Y):it,tt=F(e,`ADD_DATA_URI_TAGS`)?R(B(nt),e.ADD_DATA_URI_TAGS,Y):nt,q=F(e,`FORBID_CONTENTS`)?R({},e.FORBID_CONTENTS,Y):et,je=F(e,`FORBID_TAGS`)?R({},e.FORBID_TAGS,Y):B({}),Me=F(e,`FORBID_ATTR`)?R({},e.FORBID_ATTR,Y):B({}),K=F(e,`USE_PROFILES`)?e.USE_PROFILES:!1,Pe=e.ALLOW_ARIA_ATTR!==!1,Fe=e.ALLOW_DATA_ATTR!==!1,Le=e.ALLOW_UNKNOWN_PROTOCOLS||!1,We=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,U=e.SAFE_FOR_TEMPLATES||!1,Ge=e.SAFE_FOR_XML!==!1,W=e.WHOLE_DOCUMENT||!1,G=e.RETURN_DOM||!1,Je=e.RETURN_DOM_FRAGMENT||!1,Ye=e.RETURN_TRUSTED_TYPE||!1,qe=e.FORCE_BODY||!1,Xe=e.SANITIZE_DOM!==!1,Ze=e.SANITIZE_NAMED_PROPS||!1,Qe=e.KEEP_CONTENT!==!1,$e=e.IN_PLACE||!1,ie=e.ALLOWED_URI_REGEXP||Ne,st=e.NAMESPACE||J,dt=e.MATHML_TEXT_INTEGRATION_POINTS||dt,ft=e.HTML_INTEGRATION_POINTS||ft,V=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&_t(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(V.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&_t(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(V.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements==`boolean`&&(V.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),U&&(Fe=!1),Je&&(G=!0),K&&(L=R({},Te),z=P(null),K.html===!0&&(R(L,ye),R(z,Ee)),K.svg===!0&&(R(L,be),R(z,De),R(z,ke)),K.svgFilters===!0&&(R(L,xe),R(z,De),R(z,ke)),K.mathMl===!0&&(R(L,Ce),R(z,Oe),R(z,ke))),F(e,`ADD_TAGS`)||(H.tagCheck=null),F(e,`ADD_ATTR`)||(H.attributeCheck=null),e.ADD_TAGS&&(typeof e.ADD_TAGS==`function`?H.tagCheck=e.ADD_TAGS:(L===_e&&(L=B(L)),R(L,e.ADD_TAGS,Y))),e.ADD_ATTR&&(typeof e.ADD_ATTR==`function`?H.attributeCheck=e.ADD_ATTR:(z===Ae&&(z=B(z)),R(z,e.ADD_ATTR,Y))),e.ADD_URI_SAFE_ATTR&&R(rt,e.ADD_URI_SAFE_ATTR,Y),e.FORBID_CONTENTS&&(q===et&&(q=B(q)),R(q,e.FORBID_CONTENTS,Y)),e.ADD_FORBID_CONTENTS&&(q===et&&(q=B(q)),R(q,e.ADD_FORBID_CONTENTS,Y)),Qe&&(L[`#text`]=!0),W&&R(L,[`html`,`head`,`body`]),L.table&&(R(L,[`tbody`]),delete je.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw ge(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw ge(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);b=e.TRUSTED_TYPES_POLICY,x=b.createHTML(``)}else b===void 0&&(b=Ve(p,i)),b!==null&&typeof x==`string`&&(x=b.createHTML(``));M&&M(e),X=e}},yt=R({},[...be,...xe,...Se]),bt=R({},[...Ce,...we]),xt=function(e){let t=y(e);(!t||!t.tagName)&&(t={namespaceURI:st,tagName:`template`});let n=ue(e.tagName),r=ue(t.tagName);return lt[e.namespaceURI]?e.namespaceURI===ot?t.namespaceURI===J?n===`svg`:t.namespaceURI===at?n===`svg`&&(r===`annotation-xml`||dt[r]):!!yt[n]:e.namespaceURI===at?t.namespaceURI===J?n===`math`:t.namespaceURI===ot?n===`math`&&ft[r]:!!bt[n]:e.namespaceURI===J?t.namespaceURI===ot&&!ft[r]||t.namespaceURI===at&&!dt[r]?!1:!bt[n]&&(pt[n]||!yt[n]):!!(mt===`application/xhtml+xml`&<[e.namespaceURI]):!1},Z=function(e){ce(t.removed,{element:e});try{y(e).removeChild(e)}catch{g(e)}},Q=function(e,n){try{ce(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{ce(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(G||Je)try{Z(n)}catch{}else try{n.setAttribute(e,``)}catch{}},St=function(e){let t=null,r=null;if(qe)e=`<remove></remove>`+e;else{let t=fe(e,/^[\r\n\t ]+/);r=t&&t[0]}mt===`application/xhtml+xml`&&st===J&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=b?b.createHTML(e):e;if(st===J)try{t=new f().parseFromString(i,mt)}catch{}if(!t||!t.documentElement){t=S.createDocument(st,`template`,null);try{t.documentElement.innerHTML=ct?x:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),st===J?T.call(t,W?`html`:`body`)[0]:W?t.documentElement:a},Ct=function(e){return C.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},wt=function(e){return e instanceof d&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof u)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},Tt=function(e){return typeof s==`function`&&e instanceof s};function $(e,n,r){ae(e,e=>{e.call(t,n,r,X)})}let Et=function(e){let n=null;if($(E.beforeSanitizeElements,e,null),wt(e))return Z(e),!0;let r=Y(e.nodeName);if($(E.uponSanitizeElement,e,{tagName:r,allowedTags:L}),Ge&&e.hasChildNodes()&&!Tt(e.firstElementChild)&&I(/<[/\w!]/g,e.innerHTML)&&I(/<[/\w!]/g,e.textContent)||e.nodeType===ze.progressingInstruction||Ge&&e.nodeType===ze.comment&&I(/<[/\w]/g,e.data))return Z(e),!0;if(!(H.tagCheck instanceof Function&&H.tagCheck(r))&&(!L[r]||je[r])){if(!je[r]&&Ot(r)&&(V.tagNameCheck instanceof RegExp&&I(V.tagNameCheck,r)||V.tagNameCheck instanceof Function&&V.tagNameCheck(r)))return!1;if(Qe&&!q[r]){let t=y(e)||e.parentNode,n=v(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=h(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,_(e))}}}return Z(e),!0}return e instanceof c&&!xt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&I(/<\/no(script|embed|frames)/i,e.innerHTML)?(Z(e),!0):(U&&e.nodeType===ze.text&&(n=e.textContent,ae([te,D,k],e=>{n=pe(n,e,` `)}),e.textContent!==n&&(ce(t.removed,{element:e.cloneNode()}),e.textContent=n)),$(E.afterSanitizeElements,e,null),!1)},Dt=function(e,t,r){if(Me[t]||Xe&&(t===`id`||t===`name`)&&(r in n||r in gt))return!1;if(!(Fe&&!Me[t]&&I(A,t))&&!(Pe&&I(j,t))&&!(H.attributeCheck instanceof Function&&H.attributeCheck(t,e))){if(!z[t]||Me[t]){if(!(Ot(e)&&(V.tagNameCheck instanceof RegExp&&I(V.tagNameCheck,e)||V.tagNameCheck instanceof Function&&V.tagNameCheck(e))&&(V.attributeNameCheck instanceof RegExp&&I(V.attributeNameCheck,t)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(t,e))||t===`is`&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&I(V.tagNameCheck,r)||V.tagNameCheck instanceof Function&&V.tagNameCheck(r))))return!1}else if(!rt[t]&&!I(ie,pe(r,N,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&me(r,`data:`)===0&&tt[e])&&!(Le&&!I(ne,pe(r,N,``)))&&r)return!1}return!0},Ot=function(e){return e!==`annotation-xml`&&fe(e,re)},kt=function(e){$(E.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||wt(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:z,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=Y(a),l=s,u=a===`value`?l:he(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,$(E.uponSanitizeAttribute,e,r),u=r.attrValue,Ze&&(c===`id`||c===`name`)&&(Q(a,e),u=`user-content-`+u),Ge&&I(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){Q(a,e);continue}if(c===`attributename`&&fe(u,`href`)){Q(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){Q(a,e);continue}if(!We&&I(/\/>/i,u)){Q(a,e);continue}U&&ae([te,D,k],e=>{u=pe(u,e,` `)});let d=Y(e.nodeName);if(!Dt(d,c,u)){Q(a,e);continue}if(b&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=b.createHTML(u);break;case`TrustedScriptURL`:u=b.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),wt(e)?Z(e):se(t.removed)}catch{Q(a,e)}}$(E.afterSanitizeAttributes,e,null)},At=function e(t){let n=null,r=Ct(t);for($(E.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)$(E.uponSanitizeShadowNode,n,null),Et(n),kt(n),n.content instanceof a&&e(n.content);$(E.afterSanitizeShadowDOM,t,null)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,c=null,l=null;if(ct=!e,ct&&(e=`<!-->`),typeof e!=`string`&&!Tt(e))if(typeof e.toString==`function`){if(e=e.toString(),typeof e!=`string`)throw ge(`dirty is not a string, aborting`)}else throw ge(`toString is not a function`);if(!t.isSupported)return e;if(Ke||vt(n),t.removed=[],typeof e==`string`&&($e=!1),$e){if(e.nodeName){let t=Y(e.nodeName);if(!L[t]||je[t])throw ge(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=St(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===ze.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!G&&!U&&!W&&e.indexOf(`<`)===-1)return b&&Ye?b.createHTML(e):e;if(i=St(e),!i)return G?null:Ye?x:``}i&&qe&&Z(i.firstChild);let u=Ct($e?e:i);for(;c=u.nextNode();)Et(c),kt(c),c.content instanceof a&&At(c.content);if($e)return e;if(G){if(Je)for(l=w.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(z.shadowroot||z.shadowrootmode)&&(l=ee.call(r,l,!0)),l}let d=W?i.outerHTML:i.innerHTML;return W&&L[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&I(Ie,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
2
|
+
`+d),U&&ae([te,D,k],e=>{d=pe(d,e,` `)}),b&&Ye?b.createHTML(d):d},t.setConfig=function(){vt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),Ke=!0},t.clearConfig=function(){X=null,Ke=!1},t.isValidAttribute=function(e,t,n){return X||vt({}),Dt(Y(e),Y(t),n)},t.addHook=function(e,t){typeof t==`function`&&ce(E[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=oe(E[e],t);return n===-1?void 0:le(E[e],n,1)[0]}return se(E[e])},t.removeHooks=function(e){E[e]=[]},t.removeAllHooks=function(){E=He()},t}var We=Ue(),U=E({"node_modules/.pnpm/jsonify@0.0.1/node_modules/jsonify/lib/parse.js"(e,t){var n,r,i={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
|
|
3
|
+
`,r:`\r`,t:` `},a;function o(e){throw{name:`SyntaxError`,message:e,at:n,text:a}}function s(e){return e&&e!==r&&o(`Expected '`+e+`' instead of '`+r+`'`),r=a.charAt(n),n+=1,r}function c(){var e,t=``;for(r===`-`&&(t=`-`,s(`-`));r>=`0`&&r<=`9`;)t+=r,s();if(r===`.`)for(t+=`.`;s()&&r>=`0`&&r<=`9`;)t+=r;if(r===`e`||r===`E`)for(t+=r,s(),(r===`-`||r===`+`)&&(t+=r,s());r>=`0`&&r<=`9`;)t+=r,s();return e=Number(t),isFinite(e)||o(`Bad number`),e}function l(){var e,t,n=``,a;if(r===`"`)for(;s();)if(r===`"`)return s(),n;else if(r===`\\`)if(s(),r===`u`){for(a=0,t=0;t<4&&(e=parseInt(s(),16),isFinite(e));t+=1)a=a*16+e;n+=String.fromCharCode(a)}else if(typeof i[r]==`string`)n+=i[r];else break;else n+=r;o(`Bad string`)}function u(){for(;r&&r<=` `;)s()}function d(){switch(r){case`t`:return s(`t`),s(`r`),s(`u`),s(`e`),!0;case`f`:return s(`f`),s(`a`),s(`l`),s(`s`),s(`e`),!1;case`n`:return s(`n`),s(`u`),s(`l`),s(`l`),null;default:o(`Unexpected '`+r+`'`)}}function f(){var e=[];if(r===`[`){if(s(`[`),u(),r===`]`)return s(`]`),e;for(;r;){if(e.push(m()),u(),r===`]`)return s(`]`),e;s(`,`),u()}}o(`Bad array`)}function p(){var e,t={};if(r===`{`){if(s(`{`),u(),r===`}`)return s(`}`),t;for(;r;){if(e=l(),u(),s(`:`),Object.prototype.hasOwnProperty.call(t,e)&&o(`Duplicate key "`+e+`"`),t[e]=m(),u(),r===`}`)return s(`}`),t;s(`,`),u()}}o(`Bad object`)}function m(){switch(u(),r){case`{`:return p();case`[`:return f();case`"`:return l();case`-`:return c();default:return r>=`0`&&r<=`9`?c():d()}}t.exports=function(e,t){var i;return a=e,n=0,r=` `,i=m(),u(),r&&o(`Syntax error`),typeof t==`function`?(function e(n,r){var i,a,o=n[r];if(o&&typeof o==`object`)for(i in m)Object.prototype.hasOwnProperty.call(o,i)&&(a=e(o,i),a===void 0?delete o[i]:o[i]=a);return t.call(n,r,o)})({"":i},``):i}}}),Ge=E({"node_modules/.pnpm/jsonify@0.0.1/node_modules/jsonify/lib/stringify.js"(e,t){var n=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,r,i,a={"\b":`\\b`," ":`\\t`,"\n":`\\n`,"\f":`\\f`,"\r":`\\r`,'"':`\\"`,"\\":`\\\\`},o;function s(e){return n.lastIndex=0,n.test(e)?`"`+e.replace(n,function(e){var t=a[e];return typeof t==`string`?t:`\\u`+(`0000`+e.charCodeAt(0).toString(16)).slice(-4)})+`"`:`"`+e+`"`}function c(e,t){var n,a,l,u,d=r,f,p=t[e];switch(p&&typeof p==`object`&&typeof p.toJSON==`function`&&(p=p.toJSON(e)),typeof o==`function`&&(p=o.call(t,e,p)),typeof p){case`string`:return s(p);case`number`:return isFinite(p)?String(p):`null`;case`boolean`:case`null`:return String(p);case`object`:if(!p)return`null`;if(r+=i,f=[],Object.prototype.toString.apply(p)===`[object Array]`){for(u=p.length,n=0;n<u;n+=1)f[n]=c(n,p)||`null`;return l=f.length===0?`[]`:r?`[
|
|
4
|
+
`+r+f.join(`,
|
|
5
|
+
`+r)+`
|
|
6
|
+
`+d+`]`:`[`+f.join(`,`)+`]`,r=d,l}if(o&&typeof o==`object`)for(u=o.length,n=0;n<u;n+=1)a=o[n],typeof a==`string`&&(l=c(a,p),l&&f.push(s(a)+(r?`: `:`:`)+l));else for(a in p)Object.prototype.hasOwnProperty.call(p,a)&&(l=c(a,p),l&&f.push(s(a)+(r?`: `:`:`)+l));return l=f.length===0?`{}`:r?`{
|
|
7
|
+
`+r+f.join(`,
|
|
8
|
+
`+r)+`
|
|
9
|
+
`+d+`}`:`{`+f.join(`,`)+`}`,r=d,l}}t.exports=function(e,t,n){var a;if(r=``,i=``,typeof n==`number`)for(a=0;a<n;a+=1)i+=` `;else typeof n==`string`&&(i=n);if(o=t,t&&typeof t!=`function`&&(typeof t!=`object`||typeof t.length!=`number`))throw Error(`JSON.stringify`);return c(``,{"":e})}}}),W=E({"node_modules/.pnpm/jsonify@0.0.1/node_modules/jsonify/index.js"(e){e.parse=U(),e.stringify=Ge()}}),Ke=E({"node_modules/.pnpm/isarray@2.0.5/node_modules/isarray/index.js"(e,t){var n={}.toString;t.exports=Array.isArray||function(e){return n.call(e)==`[object Array]`}}}),qe=E({"node_modules/.pnpm/object-keys@1.1.1/node_modules/object-keys/isArguments.js"(e,t){var n=Object.prototype.toString;t.exports=function(e){var t=n.call(e),r=t===`[object Arguments]`;return r||=t!==`[object Array]`&&typeof e==`object`&&!!e&&typeof e.length==`number`&&e.length>=0&&n.call(e.callee)===`[object Function]`,r}}}),G=E({"node_modules/.pnpm/object-keys@1.1.1/node_modules/object-keys/implementation.js"(e,t){var n;Object.keys||(r=Object.prototype.hasOwnProperty,i=Object.prototype.toString,a=qe(),o=Object.prototype.propertyIsEnumerable,s=!o.call({toString:null},`toString`),c=o.call(function(){},`prototype`),l=[`toString`,`toLocaleString`,`valueOf`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`constructor`],u=function(e){var t=e.constructor;return t&&t.prototype===e},d={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},f=(function(){if(typeof window>`u`)return!1;for(var e in window)try{if(!d[`$`+e]&&r.call(window,e)&&window[e]!==null&&typeof window[e]==`object`)try{u(window[e])}catch{return!0}}catch{return!0}return!1})(),p=function(e){if(typeof window>`u`||!f)return u(e);try{return u(e)}catch{return!1}},n=function(e){var t=typeof e==`object`&&!!e,n=i.call(e)===`[object Function]`,o=a(e),u=t&&i.call(e)===`[object String]`,d=[];if(!t&&!n&&!o)throw TypeError(`Object.keys called on a non-object`);var f=c&&n;if(u&&e.length>0&&!r.call(e,0))for(var m=0;m<e.length;++m)d.push(String(m));if(o&&e.length>0)for(var h=0;h<e.length;++h)d.push(String(h));else for(var g in e)!(f&&g===`prototype`)&&r.call(e,g)&&d.push(String(g));if(s)for(var _=p(e),v=0;v<l.length;++v)!(_&&l[v]===`constructor`)&&r.call(e,l[v])&&d.push(l[v]);return d});var r,i,a,o,s,c,l,u,d,f,p;t.exports=n}}),Je=E({"node_modules/.pnpm/object-keys@1.1.1/node_modules/object-keys/index.js"(e,t){var n=Array.prototype.slice,r=qe(),i=Object.keys,a=i?function(e){return i(e)}:G(),o=Object.keys;a.shim=function(){return Object.keys?(function(){var e=Object.keys(arguments);return e&&e.length===arguments.length})(1,2)||(Object.keys=function(e){return r(e)?o(n.call(e)):o(e)}):Object.keys=a,Object.keys||a},t.exports=a}}),Ye=E({"node_modules/.pnpm/es-object-atoms@1.1.1/node_modules/es-object-atoms/index.js"(e,t){t.exports=Object}}),Xe=E({"node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/index.js"(e,t){t.exports=Error}}),Ze=E({"node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/eval.js"(e,t){t.exports=EvalError}}),Qe=E({"node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/range.js"(e,t){t.exports=RangeError}}),$e=E({"node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/ref.js"(e,t){t.exports=ReferenceError}}),K=E({"node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/syntax.js"(e,t){t.exports=SyntaxError}}),q=E({"node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/type.js"(e,t){t.exports=TypeError}}),et=E({"node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/uri.js"(e,t){t.exports=URIError}}),tt=E({"node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/abs.js"(e,t){t.exports=Math.abs}}),nt=E({"node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/floor.js"(e,t){t.exports=Math.floor}}),rt=E({"node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/max.js"(e,t){t.exports=Math.max}}),it=E({"node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/min.js"(e,t){t.exports=Math.min}}),at=E({"node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/pow.js"(e,t){t.exports=Math.pow}}),ot=E({"node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/round.js"(e,t){t.exports=Math.round}}),J=E({"node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/isNaN.js"(e,t){t.exports=Number.isNaN||function(e){return e!==e}}}),st=E({"node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js"(e,t){var n=J();t.exports=function(e){return n(e)||e===0?e:e<0?-1:1}}}),ct=E({"node_modules/.pnpm/gopd@1.2.0/node_modules/gopd/gOPD.js"(e,t){t.exports=Object.getOwnPropertyDescriptor}}),lt=E({"node_modules/.pnpm/gopd@1.2.0/node_modules/gopd/index.js"(e,t){var n=ct();if(n)try{n([],`length`)}catch{n=null}t.exports=n}}),ut=E({"node_modules/.pnpm/es-define-property@1.0.1/node_modules/es-define-property/index.js"(e,t){var n=Object.defineProperty||!1;if(n)try{n({},`a`,{value:1})}catch{n=!1}t.exports=n}}),dt=E({"node_modules/.pnpm/has-symbols@1.1.0/node_modules/has-symbols/shams.js"(e,t){t.exports=function(){if(typeof Symbol!=`function`||typeof Object.getOwnPropertySymbols!=`function`)return!1;if(typeof Symbol.iterator==`symbol`)return!0;var e={},t=Symbol(`test`),n=Object(t);if(typeof t==`string`||Object.prototype.toString.call(t)!==`[object Symbol]`||Object.prototype.toString.call(n)!==`[object Symbol]`)return!1;var r=42;for(var i in e[t]=r,e)return!1;if(typeof Object.keys==`function`&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames==`function`&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor==`function`){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==r||o.enumerable!==!0)return!1}return!0}}}),ft=E({"node_modules/.pnpm/has-symbols@1.1.0/node_modules/has-symbols/index.js"(e,t){var n=typeof Symbol<`u`&&Symbol,r=dt();t.exports=function(){return typeof n!=`function`||typeof Symbol!=`function`||typeof n(`foo`)!=`symbol`||typeof Symbol(`bar`)!=`symbol`?!1:r()}}}),pt=E({"node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/Reflect.getPrototypeOf.js"(e,t){t.exports=typeof Reflect<`u`&&Reflect.getPrototypeOf||null}}),mt=E({"node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/Object.getPrototypeOf.js"(e,t){t.exports=Ye().getPrototypeOf||null}}),ht=E({"node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.js"(e,t){var n=`Function.prototype.bind called on incompatible `,r=Object.prototype.toString,i=Math.max,a=`[object Function]`,o=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n},s=function(e,t){for(var n=[],r=t,i=0;r<e.length;r+=1,i+=1)n[i]=e[r];return n},c=function(e,t){for(var n=``,r=0;r<e.length;r+=1)n+=e[r],r+1<e.length&&(n+=t);return n};t.exports=function(e){var t=this;if(typeof t!=`function`||r.apply(t)!==a)throw TypeError(n+t);for(var l=s(arguments,1),u,d=function(){if(this instanceof u){var n=t.apply(this,o(l,arguments));return Object(n)===n?n:this}return t.apply(e,o(l,arguments))},f=i(0,t.length-l.length),p=[],m=0;m<f;m++)p[m]=`$`+m;if(u=Function(`binder`,`return function (`+c(p,`,`)+`){ return binder.apply(this,arguments); }`)(d),t.prototype){var h=function(){};h.prototype=t.prototype,u.prototype=new h,h.prototype=null}return u}}}),Y=E({"node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.js"(e,t){var n=ht();t.exports=Function.prototype.bind||n}}),X=E({"node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionCall.js"(e,t){t.exports=Function.prototype.call}}),gt=E({"node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionApply.js"(e,t){t.exports=Function.prototype.apply}}),_t=E({"node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/reflectApply.js"(e,t){t.exports=typeof Reflect<`u`&&Reflect&&Reflect.apply}}),vt=E({"node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/actualApply.js"(e,t){var n=Y(),r=gt(),i=X();t.exports=_t()||n.call(i,r)}}),yt=E({"node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/index.js"(e,t){var n=Y(),r=q(),i=X(),a=vt();t.exports=function(e){if(e.length<1||typeof e[0]!=`function`)throw new r(`a function is required`);return a(n,i,e)}}}),bt=E({"node_modules/.pnpm/dunder-proto@1.0.1/node_modules/dunder-proto/get.js"(e,t){var n=yt(),r=lt(),i;try{i=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!=`object`||!(`code`in e)||e.code!==`ERR_PROTO_ACCESS`)throw e}var a=!!i&&r&&r(Object.prototype,`__proto__`),o=Object,s=o.getPrototypeOf;t.exports=a&&typeof a.get==`function`?n([a.get]):typeof s==`function`?(function(e){return s(e==null?e:o(e))}):!1}}),xt=E({"node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/index.js"(e,t){var n=pt(),r=mt(),i=bt();t.exports=n?function(e){return n(e)}:r?function(e){if(!e||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`getProto: not an object`);return r(e)}:i?function(e){return i(e)}:null}}),Z=E({"node_modules/.pnpm/hasown@2.0.2/node_modules/hasown/index.js"(e,t){var n=Function.prototype.call,r=Object.prototype.hasOwnProperty;t.exports=Y().call(n,r)}}),Q=E({"node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js"(e,t){var n,r=Ye(),i=Xe(),a=Ze(),o=Qe(),s=$e(),c=K(),l=q(),u=et(),d=tt(),f=nt(),p=rt(),m=it(),h=at(),g=ot(),_=st(),v=Function,y=function(e){try{return v(`"use strict"; return (`+e+`).constructor;`)()}catch{}},b=lt(),x=ut(),S=function(){throw new l},C=b?(function(){try{return arguments.callee,S}catch{try{return b(arguments,`callee`).get}catch{return S}}})():S,w=ft()(),T=xt(),ee=mt(),E=pt(),te=gt(),D=X(),O={},k=typeof Uint8Array>`u`||!T?n:T(Uint8Array),A={__proto__:null,"%AggregateError%":typeof AggregateError>`u`?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>`u`?n:ArrayBuffer,"%ArrayIteratorPrototype%":w&&T?T([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":O,"%AsyncGenerator%":O,"%AsyncGeneratorFunction%":O,"%AsyncIteratorPrototype%":O,"%Atomics%":typeof Atomics>`u`?n:Atomics,"%BigInt%":typeof BigInt>`u`?n:BigInt,"%BigInt64Array%":typeof BigInt64Array>`u`?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>`u`?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>`u`?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":a,"%Float16Array%":typeof Float16Array>`u`?n:Float16Array,"%Float32Array%":typeof Float32Array>`u`?n:Float32Array,"%Float64Array%":typeof Float64Array>`u`?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>`u`?n:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":O,"%Int8Array%":typeof Int8Array>`u`?n:Int8Array,"%Int16Array%":typeof Int16Array>`u`?n:Int16Array,"%Int32Array%":typeof Int32Array>`u`?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":w&&T?T(T([][Symbol.iterator]())):n,"%JSON%":typeof JSON==`object`?JSON:n,"%Map%":typeof Map>`u`?n:Map,"%MapIteratorPrototype%":typeof Map>`u`||!w||!T?n:T(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":r,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>`u`?n:Promise,"%Proxy%":typeof Proxy>`u`?n:Proxy,"%RangeError%":o,"%ReferenceError%":s,"%Reflect%":typeof Reflect>`u`?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>`u`?n:Set,"%SetIteratorPrototype%":typeof Set>`u`||!w||!T?n:T(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>`u`?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":w&&T?T(``[Symbol.iterator]()):n,"%Symbol%":w?Symbol:n,"%SyntaxError%":c,"%ThrowTypeError%":C,"%TypedArray%":k,"%TypeError%":l,"%Uint8Array%":typeof Uint8Array>`u`?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>`u`?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>`u`?n:Uint16Array,"%Uint32Array%":typeof Uint32Array>`u`?n:Uint32Array,"%URIError%":u,"%WeakMap%":typeof WeakMap>`u`?n:WeakMap,"%WeakRef%":typeof WeakRef>`u`?n:WeakRef,"%WeakSet%":typeof WeakSet>`u`?n:WeakSet,"%Function.prototype.call%":D,"%Function.prototype.apply%":te,"%Object.defineProperty%":x,"%Object.getPrototypeOf%":ee,"%Math.abs%":d,"%Math.floor%":f,"%Math.max%":p,"%Math.min%":m,"%Math.pow%":h,"%Math.round%":g,"%Math.sign%":_,"%Reflect.getPrototypeOf%":E};if(T)try{null.error}catch(e){j=T(T(e)),A[`%Error.prototype%`]=j}var j,ne=function e(t){var n;if(t===`%AsyncFunction%`)n=y(`async function () {}`);else if(t===`%GeneratorFunction%`)n=y(`function* () {}`);else if(t===`%AsyncGeneratorFunction%`)n=y(`async function* () {}`);else if(t===`%AsyncGenerator%`){var r=e(`%AsyncGeneratorFunction%`);r&&(n=r.prototype)}else if(t===`%AsyncIteratorPrototype%`){var i=e(`%AsyncGenerator%`);i&&T&&(n=T(i.prototype))}return A[t]=n,n},M={__proto__:null,"%ArrayBufferPrototype%":[`ArrayBuffer`,`prototype`],"%ArrayPrototype%":[`Array`,`prototype`],"%ArrayProto_entries%":[`Array`,`prototype`,`entries`],"%ArrayProto_forEach%":[`Array`,`prototype`,`forEach`],"%ArrayProto_keys%":[`Array`,`prototype`,`keys`],"%ArrayProto_values%":[`Array`,`prototype`,`values`],"%AsyncFunctionPrototype%":[`AsyncFunction`,`prototype`],"%AsyncGenerator%":[`AsyncGeneratorFunction`,`prototype`],"%AsyncGeneratorPrototype%":[`AsyncGeneratorFunction`,`prototype`,`prototype`],"%BooleanPrototype%":[`Boolean`,`prototype`],"%DataViewPrototype%":[`DataView`,`prototype`],"%DatePrototype%":[`Date`,`prototype`],"%ErrorPrototype%":[`Error`,`prototype`],"%EvalErrorPrototype%":[`EvalError`,`prototype`],"%Float32ArrayPrototype%":[`Float32Array`,`prototype`],"%Float64ArrayPrototype%":[`Float64Array`,`prototype`],"%FunctionPrototype%":[`Function`,`prototype`],"%Generator%":[`GeneratorFunction`,`prototype`],"%GeneratorPrototype%":[`GeneratorFunction`,`prototype`,`prototype`],"%Int8ArrayPrototype%":[`Int8Array`,`prototype`],"%Int16ArrayPrototype%":[`Int16Array`,`prototype`],"%Int32ArrayPrototype%":[`Int32Array`,`prototype`],"%JSONParse%":[`JSON`,`parse`],"%JSONStringify%":[`JSON`,`stringify`],"%MapPrototype%":[`Map`,`prototype`],"%NumberPrototype%":[`Number`,`prototype`],"%ObjectPrototype%":[`Object`,`prototype`],"%ObjProto_toString%":[`Object`,`prototype`,`toString`],"%ObjProto_valueOf%":[`Object`,`prototype`,`valueOf`],"%PromisePrototype%":[`Promise`,`prototype`],"%PromiseProto_then%":[`Promise`,`prototype`,`then`],"%Promise_all%":[`Promise`,`all`],"%Promise_reject%":[`Promise`,`reject`],"%Promise_resolve%":[`Promise`,`resolve`],"%RangeErrorPrototype%":[`RangeError`,`prototype`],"%ReferenceErrorPrototype%":[`ReferenceError`,`prototype`],"%RegExpPrototype%":[`RegExp`,`prototype`],"%SetPrototype%":[`Set`,`prototype`],"%SharedArrayBufferPrototype%":[`SharedArrayBuffer`,`prototype`],"%StringPrototype%":[`String`,`prototype`],"%SymbolPrototype%":[`Symbol`,`prototype`],"%SyntaxErrorPrototype%":[`SyntaxError`,`prototype`],"%TypedArrayPrototype%":[`TypedArray`,`prototype`],"%TypeErrorPrototype%":[`TypeError`,`prototype`],"%Uint8ArrayPrototype%":[`Uint8Array`,`prototype`],"%Uint8ClampedArrayPrototype%":[`Uint8ClampedArray`,`prototype`],"%Uint16ArrayPrototype%":[`Uint16Array`,`prototype`],"%Uint32ArrayPrototype%":[`Uint32Array`,`prototype`],"%URIErrorPrototype%":[`URIError`,`prototype`],"%WeakMapPrototype%":[`WeakMap`,`prototype`],"%WeakSetPrototype%":[`WeakSet`,`prototype`]},N=Y(),P=Z(),re=N.call(D,Array.prototype.concat),ie=N.call(te,Array.prototype.splice),ae=N.call(D,String.prototype.replace),oe=N.call(D,String.prototype.slice),se=N.call(D,RegExp.prototype.exec),ce=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,le=/\\(\\)?/g,ue=function(e){var t=oe(e,0,1),n=oe(e,-1);if(t===`%`&&n!==`%`)throw new c("invalid intrinsic syntax, expected closing `%`");if(n===`%`&&t!==`%`)throw new c("invalid intrinsic syntax, expected opening `%`");var r=[];return ae(e,ce,function(e,t,n,i){r[r.length]=n?ae(i,le,`$1`):t||e}),r},de=function(e,t){var n=e,r;if(P(M,n)&&(r=M[n],n=`%`+r[0]+`%`),P(A,n)){var i=A[n];if(i===O&&(i=ne(n)),i===void 0&&!t)throw new l(`intrinsic `+e+` exists, but is not available. Please file an issue!`);return{alias:r,name:n,value:i}}throw new c(`intrinsic `+e+` does not exist!`)};t.exports=function(e,t){if(typeof e!=`string`||e.length===0)throw new l(`intrinsic name must be a non-empty string`);if(arguments.length>1&&typeof t!=`boolean`)throw new l(`"allowMissing" argument must be a boolean`);if(se(/^%?[^%]*%?$/,e)===null)throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=ue(e),r=n.length>0?n[0]:``,i=de(`%`+r+`%`,t),a=i.name,o=i.value,s=!1,u=i.alias;u&&(r=u[0],ie(n,re([0,1],u)));for(var d=1,f=!0;d<n.length;d+=1){var p=n[d],m=oe(p,0,1),h=oe(p,-1);if((m===`"`||m===`'`||m==="`"||h===`"`||h===`'`||h==="`")&&m!==h)throw new c(`property names with quotes must have matching quotes`);if((p===`constructor`||!f)&&(s=!0),r+=`.`+p,a=`%`+r+`%`,P(A,a))o=A[a];else if(o!=null){if(!(p in o)){if(!t)throw new l(`base intrinsic for `+e+` exists, but the property is not available.`);return}if(b&&d+1>=n.length){var g=b(o,p);f=!!g,o=f&&`get`in g&&!(`originalValue`in g.get)?g.get:o[p]}else f=P(o,p),o=o[p];f&&!s&&(A[a]=o)}}return o}}}),St=E({"node_modules/.pnpm/define-data-property@1.1.4/node_modules/define-data-property/index.js"(e,t){var n=ut(),r=K(),i=q(),a=lt();t.exports=function(e,t,o){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`obj` must be an object or a function`");if(typeof t!=`string`&&typeof t!=`symbol`)throw new i("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!=`boolean`&&arguments[3]!==null)throw new i("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!=`boolean`&&arguments[4]!==null)throw new i("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!=`boolean`&&arguments[5]!==null)throw new i("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!=`boolean`)throw new i("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,u=arguments.length>6?arguments[6]:!1,d=!!a&&a(e,t);if(n)n(e,t,{configurable:l===null&&d?d.configurable:!l,enumerable:s===null&&d?d.enumerable:!s,value:o,writable:c===null&&d?d.writable:!c});else if(u||!s&&!c&&!l)e[t]=o;else throw new r(`This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.`)}}}),Ct=E({"node_modules/.pnpm/has-property-descriptors@1.0.2/node_modules/has-property-descriptors/index.js"(e,t){var n=ut(),r=function(){return!!n};r.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],`length`,{value:1}).length!==1}catch{return!0}},t.exports=r}}),wt=E({"node_modules/.pnpm/set-function-length@1.2.2/node_modules/set-function-length/index.js"(e,t){var n=Q(),r=St(),i=Ct()(),a=lt(),o=q(),s=n(`%Math.floor%`);t.exports=function(e,t){if(typeof e!=`function`)throw new o("`fn` is not a function");if(typeof t!=`number`||t<0||t>4294967295||s(t)!==t)throw new o("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],c=!0,l=!0;if(`length`in e&&a){var u=a(e,`length`);u&&!u.configurable&&(c=!1),u&&!u.writable&&(l=!1)}return(c||l||!n)&&(i?r(e,`length`,t,!0,!0):r(e,`length`,t)),e}}}),Tt=E({"node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/applyBind.js"(e,t){var n=Y(),r=gt(),i=vt();t.exports=function(){return i(n,r,arguments)}}}),$=E({"node_modules/.pnpm/call-bind@1.0.8/node_modules/call-bind/index.js"(e,t){var n=wt(),r=ut(),i=yt(),a=Tt();t.exports=function(e){var t=i(arguments),r=e.length-(arguments.length-1);return n(t,1+(r>0?r:0),!0)},r?r(t.exports,`apply`,{value:a}):t.exports.apply=a}}),Et=E({"node_modules/.pnpm/call-bound@1.0.4/node_modules/call-bound/index.js"(e,t){var n=Q(),r=yt(),i=r([n(`%String.prototype.indexOf%`)]);t.exports=function(e,t){var a=n(e,!!t);return typeof a==`function`&&i(e,`.prototype.`)>-1?r([a]):a}}}),Dt=D(E({"node_modules/.pnpm/json-stable-stringify@1.3.0/node_modules/json-stable-stringify/index.js"(e,t){var n=(typeof JSON<`u`?JSON:W()).stringify,r=Ke(),i=Je(),a=$(),o=Et(),s=o(`Array.prototype.join`),c=o(`Array.prototype.indexOf`),l=o(`Array.prototype.splice`),u=o(`Array.prototype.sort`),d=function(e,t){for(var n=``,r=0;r<e;r+=1)n+=t;return n},f=function(e,t,n){return n};t.exports=function(e){var t=arguments.length>1?arguments[1]:void 0,o=t&&t.space||``;typeof o==`number`&&(o=d(o,` `));var p=!!t&&typeof t.cycles==`boolean`&&t.cycles,m=t&&t.replacer?a(t.replacer):f;if(t&&t.collapseEmpty!==void 0&&typeof t.collapseEmpty!=`boolean`)throw TypeError("`collapseEmpty` must be a boolean, if provided");var h=!!t&&t.collapseEmpty,g=typeof t==`function`?t:t&&t.cmp,_=g&&function(e){var t=g.length>2&&function(t){return e[t]};return function(n,r){return g({key:n,value:e[n]},{key:r,value:e[r]},t?{__proto__:null,get:t}:void 0)}},v=[];return(function e(t,a,f,g){var y=o?`
|
|
10
|
+
`+d(g,o):``,b=o?`: `:`:`;if(f&&f.toJSON&&typeof f.toJSON==`function`&&(f=f.toJSON()),f=m(t,a,f),f!==void 0){if(typeof f!=`object`||!f)return n(f);var x=function(e,t){return h&&e.length===0?t:(t===`[]`?`[`:`{`)+s(e,`,`)+y+(t===`[]`?`]`:`}`)};if(r(f)){for(var S=[],C=0;C<f.length;C++){var w=e(f,C,f[C],g+1)||n(null);S[S.length]=y+o+w}return x(S,`[]`)}if(c(v,f)!==-1){if(p)return n(`__cycle__`);throw TypeError(`Converting circular structure to JSON`)}else v[v.length]=f;for(var T=u(i(f),_&&_(f)),S=[],C=0;C<T.length;C++){var a=T[C],ee=e(f,a,f[a],g+1);if(ee){var E=n(a)+b+ee;S[S.length]=y+o+E}}return l(v,c(v,f),1),x(S,`{}`)}})({"":e},``,e,0)}}})(),1),Ot=e=>localStorage.getItem(`kizen-flag-${e}`)===`true`,kt=(e=``)=>e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),At=e=>{try{return kt((0,Dt.default)(e))}catch(e){return Ot(`script-runner-logging`)&&console.warn(`Failed to stringify object for hashing:`,e),kt(String(Math.random()))}},jt=e=>e.startsWith(`/`),Mt=[`microphone`,`speaker-selection`,`autoplay`,`camera`,`display-capture`,`hid`],Nt=[`allow-popups`,`allow-scripts`,`allow-same-origin`],Pt=3e4,Ft=100,It=class{worker;scriptUIRef;onStateChange;done;onError;waitForFrame=!1;plugin;executionPlugin;frameId;onShowToast;onClearToasts;sessionData={};setSessionData;pluginComponentId;onShowModal;onShowCreateRecordModal;onShowCreateRelatedRecordModal;onReleaseBlockingScript;pluginApiName;onNetworkError;onNetworkRequest;invalidateCache;getPendingCacheCount;createFileId;performFileUpload;pushHistory;appPath;constructor(e){this.scriptUIRef=e.scriptUIRef,this.onStateChange=e.onStateChange,this.done=e.done,this.onError=e.onError,this.onReleaseBlockingScript=e.onReleaseBlockingScript,this.worker=e.worker,this.worker.onmessage=this.handleMessage,this.plugin=e.plugin,this.executionPlugin=e.executionPlugin,this.onShowToast=e.onShowToast,this.onClearToasts=e.onClearToasts,this.pluginComponentId=e.pluginComponentId,this.onShowModal=e.onShowModal,this.onShowCreateRecordModal=e.onShowCreateRecordModal,this.onShowCreateRelatedRecordModal=e.onShowCreateRelatedRecordModal,this.onNetworkError=e.onNetworkError,this.onNetworkRequest=e.onNetworkRequest,this.invalidateCache=e.invalidateCache,this.getPendingCacheCount=e.getPendingCacheCount,this.createFileId=e.createFileId,this.performFileUpload=e.performFileUpload,this.pushHistory=e.pushHistory,this.appPath=e.appPath,this.plugin&&(this.frameId=`${s}-${this.plugin.plugin_api_name}-${this.plugin.api_name}`),this.pluginApiName=this.executionPlugin?.plugin_api_name??this.plugin?.plugin_api_name??``,this.pluginApiName?(this.sessionData=e.sessionData[this.pluginApiName],this.setSessionData=t=>{e.setSessionData?.(this.pluginApiName,t)}):this.setSessionData=()=>{this.onError?.({message:`Script must be associated with a plugin to use session data`})}}handleMessage=async e=>{let t=JSON.parse(e.data),{action:i}=t;switch(i){case n.QUERY_REQUEST:{let e=t;await this.handleQueryRequest(e.id,e.method,e.url,e.payload,e.options);return}case n.UI_OUTPUT:{let e=t;this.handleUIOutput(e.markup);return}case n.IFRAME_OUTPUT:{let e=t;this.handleIframeOutput(e.url,e.allow,e.sandbox,e.preserve);return}case n.POSTFORMDATA_REQUEST:{let e=t;this.handleFormPostRequest(e.id,e.url,e.payload,e.createNewTab);return}case n.UPLOADFILE_REQUEST:{let e=t;await this.handleUploadFileRequest(e.id,e.payload);return}case n.SETSTATE:{let e=t;this.onStateChange?.(e.state);return}case n.DONE:{let e=t;this.handleDone(e.preserve,e.result);return}case r.ERROR:{let e=t;this.onError?.({message:e.error});return}case n.OPEN_WINDOW:{let e=t;this.handleOpenWindow(e.url,e.target,e.features);return}case n.COMMUNICATE:{let e=t;this.handleCommunication(e.type,e.recipient,e.args,e.params);return}case n.HIDE:{let{config:e}=t,n=!1;e.hideTrigger&&(n=!0),this.onStateChange?.({hidden:!0,triggerHidden:n});return}case n.SHOW:{let{config:e}=t,n=!1;e.showTrigger===!1&&(n=!0),this.onStateChange?.({hidden:!1,triggerHidden:n});return}case n.EXPAND:this.onStateChange?.({minimized:!1});return;case n.COLLAPSE:this.onStateChange?.({minimized:!0});return;case n.HIDE_HEADER:this.onStateChange?.({hideHeader:!0});return;case n.SHOW_HEADER:this.onStateChange?.({hideHeader:!1});return;case n.COPY_TO_CLIPBOARD:{let e=t;await this.copyToClipboard(e.text);return}case n.OPEN_CREATE_RECORD_MODAL_REQUEST:{let e=t;this.handleCreateRecordRequest(e.id,e.entityId);return}case n.OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST:{let e=t;this.handleCreateRelatedRecordRequest(e.id,e.objectId,e.relatedEntityId);return}case n.SHOW_TOAST:{let e=t;this.showToast(e.message,e.toastOptions);return}case n.CLEAR_TOASTS:this.clearToasts();return;case n.REFRESH_TIMELINE:{let e=t;this.handleRefreshTimeline(e.entityId);return}case n.REFRESH_ENTITY:{let e=t;await this.handleRefreshEntity(e.entityId,e.id);return}case n.UPDATE_SESSION_DATA:{let e=t;this.handleSetSessionData(e.update);return}case n.INSTALL_THIRD_PARTY_SCRIPT_REQUEST:{let e=t;this.handleInstallThirdPartyScriptRequest(e.id,e.url,e.args);return}case n.PROMPT_REQUEST:{let e=t;this.handlePromptRequest(e.id,e.config,!1);return}case n.DYNAMIC_PROMPT_REQUEST:{let e=t;this.handlePromptRequest(e.id,e.config,!0);return}case n.RELEASE_BLOCKING_SCRIPT:this.handleReleaseBlockingScript();return;case n.AUTHORIZE:{let e=t;this.handleAuthorize(e.serviceName,e.config);return}default:return}};handleCommunication=(e,t,n,r)=>{if(e===i.SEND_MESSAGE_TO_FRAME){if(this.frameId){let e=document.getElementById(this.frameId);e&&e.contentWindow?.postMessage({...n?.payload??{},__kizen:{recipient:t,frameId:this.frameId}},n?.path??`*`)}}else if(e===i.CALL_THIRD_PARTY_SCRIPT)this.handleCallThirdPartyScript(t.type,r);else{let r=this.executionPlugin?.plugin_api_name??this.plugin?.plugin_api_name,i=new CustomEvent(`integration:${e}`,{detail:{recipient:{...t,plugin:r},args:n}});window.dispatchEvent(i)}};handleDone=(e,t)=>{this.waitForFrame||this.done(e,t)};postMessage=(e,t)=>{this.worker.postMessage(JSON.stringify({action:e,...t}))};handleSetSessionData=e=>{this.setSessionData(e)};handleQueryRequest=async(e,t,n,i,a)=>{try{let o=await this.onNetworkRequest?.(t,n,i,a);this.postMessage(r.QUERY_RESPONSE,{data:o,id:e})}catch(t){this.onNetworkError?.(t);let n=t instanceof b?{__kizenError:!0,proxyStatus:t.proxyStatus,upstreamStatus:t.upstreamStatus,upstreamResponse:t.upstreamResponse,message:t.message}:(()=>{if(t instanceof Error)return{message:t.message,name:t.name};try{let e=JSON.parse(JSON.stringify(t));if(typeof e==`object`&&e&&!Array.isArray(e))return e}catch{}return{message:String(t)}})();this.postMessage(r.QUERY_RESPONSE,{error:n,id:e})}};handleUIOutput=e=>{if(this.scriptUIRef?.current){let t=We.sanitize(e);this.scriptUIRef.current.innerHTML=t}};onLoad=e=>{e.iframe&&(this.waitForFrame=!1,this.handleDone(e.preserve))};handleIframeOutput=(e,t=[],n=[],r=!1)=>{if(this.scriptUIRef?.current){let i=t.filter(e=>Mt.includes(e)),a=n.filter(e=>Nt.includes(e));this.waitForFrame=!0;let o=document.createElement(`iframe`);o.src=e,o.allow=i.join(`; `),a.forEach(e=>{o.sandbox.add(e)}),o.style.border=`none`,o.style.width=`100%`,o.style.height=`100%`,o.onload=this.onLoad.bind(this,{iframe:o,preserve:r}),this.frameId&&(o.id=this.frameId),this.scriptUIRef.current.replaceChildren(o)}};handleCreateRecordRequest=(e,t)=>{this.onShowCreateRecordModal?.(t,t=>{this.postMessage(r.CREATE_RECORD_RESPONSE,{id:e,data:t})})};handleCreateRelatedRecordRequest=(e,t,n)=>{this.onShowCreateRelatedRecordModal?.(t,n,t=>{this.postMessage(r.CREATE_RELATED_RECORD_RESPONSE,{id:e,data:t})})};showToast=(e,t)=>{this.onShowToast?.({message:e,variant:t?.variant??`success`,autohide:t?.autohide??!0})};clearToasts=()=>{this.onClearToasts?.()};copyToClipboard=async e=>{try{await navigator.clipboard.writeText(e)}catch(e){this.onError?.({message:e.message})}};handleRefreshTimeline=e=>{this.invalidateCache?.(`timeline`,e)};waitForIdleState=e=>new Promise(t=>{let n=0,r=setInterval(()=>{(this.getPendingCacheCount?.(e)??0)===0?(clearInterval(r),t(!0)):(n+=1,n>Math.floor(Pt/Ft)&&(clearInterval(r),t(!1)))},Ft)});handleRefreshEntity=async(e,t)=>{this.invalidateCache?.(`entity`,e);let n=await this.waitForIdleState(e);this.postMessage(r.REFRESH_ENTITY_RESPONSE,{id:t,data:{success:n}})};handleFormPostRequest=(e,t,n,i)=>{let a=document.createElement(`form`);a.method=`POST`,a.action=t,i&&(a.target=`_blank`);for(let e in n){let t=document.createElement(`input`);t.type=`hidden`,t.name=e,t.value=n[e],a.appendChild(t)}document.body.appendChild(a),a.submit(),i&&document.body.removeChild(a),this.postMessage(r.POSTFORMDATA_RESPONSE,{success:!0,id:e})};handleUploadFileRequest=async(e,t)=>{if(!this.performFileUpload){this.postMessage(r.UPLOADFILE_RESPONSE,{error:`File upload not supported`,id:e});return}let{file:n,isPublic:i=!1,fileName:a}=t,o=await(await fetch(n)).blob(),s=new File([o],a??`upload-${new Date().toISOString()}`,{type:o.type});s.$id=this.createFileId?.()??v();let c=await this.performFileUpload({file:s,id:s.$id,publicFile:i,source:`field_value`,handleProgress:e=>{this.postMessage(r.UPLOADFILE_PROGRESS,{fileId:e.id,progress:e.progress})},businessId:void 0});this.postMessage(r.UPLOADFILE_RESPONSE,{data:c,id:e})};waitForReadyState=(e,t,n=0)=>{e||t?.(!0),e?.()?t?.(!0):n<20?setTimeout(()=>{this.waitForReadyState(e,t,n+1)},n*50):t?.(!1)};handleCallThirdPartyScript=(e,t=[])=>{if(e&&m[e]){let n=m[e],r=window[n];r?.(...t)}};handleReleaseBlockingScript=()=>this.onReleaseBlockingScript?.(this.executionPlugin);handlePromptRequest=(e,t,n=!1)=>{this.onShowModal?this.onShowModal({...t,pluginApiName:this.pluginApiName??``,dynamic:n},(t={})=>{this.postMessage(r.PROMPT_RESPONSE,{id:e,data:t})}):this.postMessage(r.PROMPT_RESPONSE,{id:e,data:{canceled:!0}})};handleInstallThirdPartyScriptRequest=(e,t,n={})=>{let i=p(t);if(!i){this.postMessage(r.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE,{data:{success:!1,url:t},id:e});return}let a=h[i];a(n);let o=document.createElement(`script`);o.onload=()=>{this.waitForReadyState(g[i],n=>{this.postMessage(r.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE,{data:{success:!0,url:t,matched:n},id:e})})},o.onerror=()=>{this.postMessage(r.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE,{data:{success:!1,url:t},id:e})},o.src=t,o.setAttribute(`data-script-url`,t),document.querySelectorAll(`[data-script-url="`+t+`"]`).length>0?this.waitForReadyState(g[i],n=>{this.postMessage(r.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE,{data:{success:!0,url:t,reused:!0,matched:n},id:e})}):document.documentElement.firstChild?.appendChild(o)};handleOpenWindow=(e,t,n)=>{!jt(e)||t===`_blank`||!this.pushHistory?window.open(e,t,n):this.pushHistory(e)};handleAuthorize=(e,t={})=>{let n=new URLSearchParams;if(t.successRedirectPath&&n.append(`success_redirect_path`,t.successRedirectPath),t.errorRedirectPath&&n.append(`error_redirect_path`,t.errorRedirectPath),!this.appPath){this.onError?.({message:`App path is not defined.`});return}if(!this.pluginApiName){this.onError?.({message:`Plugin API name is not defined.`});return}let r=n.toString();this.handleOpenWindow(`${this.appPath}/external-integrations/business-plugin-apps/${this.pluginApiName}/services/${encodeURIComponent(e)}/authorize${r?`?${r}`:``}`,`_blank`,``)};run=(e,t,r)=>{let i=_();this.postMessage(n.RUN,{script:e,setup:t,args:r,sessionData:this.sessionData,pluginComponentId:this.pluginComponentId,pluginApiName:this.pluginApiName,location:i})}},Lt=async({scriptBody:e,user:t,teamMember:n,business:r,onError:i,onReleaseBlockingScript:a,setLoadingState:o,clientObject:s,scriptUIRef:c,onStateChange:l,workerName:u,context:d,args:f=``,plugin:p,onShowToast:m,onClearToasts:h,terminators:g,executionPlugin:_,sessionData:v,setSessionData:y,onShowModal:b,onShowCreateRecordModal:x,onShowCreateRelatedRecordModal:S,onNetworkError:C,onNetworkRequest:w,appPath:T,pushHistory:ee,createFileId:E,performFileUpload:te,getPendingCacheCount:D,invalidateCache:O})=>{let k=Ot(`script-runner-logging`),A;return A=u===`recordDetail`?new Worker(new URL(`/assets/recordDetail.worker-B-1qFS5m.js`,``+import.meta.url),{type:`module`}):u===`genericPlugin`?new Worker(new URL(`/assets/generic.worker-Bzr3c9PO.js`,``+import.meta.url),{type:`module`}):u===`floatingFramePlugin`?new Worker(new URL(`/assets/floatingFrame.worker-CKAMagoG.js`,``+import.meta.url),{type:`module`}):new Worker(new URL(`/assets/calendarSource.worker-DGRTJYHs.js`,``+import.meta.url),{type:`module`}),new Promise(u=>{let j=kt(e),ne=kt(f),M=`${p?.plugin_api_name??``}-${p?.api_name??``}-${String(j)}-${String(ne)}`,N=`${p?.plugin_api_name??``}-${p?.api_name??``}`;_?.field_type?(M=`${_.plugin_api_name??``}-${_.field_type}-${String(j)}-${String(ne)}`,N=`${_.plugin_api_name??``}-${_.field_type??_.script_id}`):_&&(M=`${_.plugin_api_name??``}-${_.api_name}-${String(j)}-${String(ne)}`,N=`${_.plugin_api_name??``}-${_.api_name}`),g.current[M]&&(g.current[M]?.forEach(e=>{e()}),g.current[M]=[]),g.current[M]??=[],g.current[M]?.push(()=>{A.terminate()});let P=new It({worker:A,done:(e,t)=>{o(!1),e||(g.current[M]?.forEach(e=>{e()}),g.current[M]=[]),u(t)},onError:i,onReleaseBlockingScript:a,scriptUIRef:c,onStateChange:l,plugin:p,executionPlugin:_,onShowToast:m,onClearToasts:h,sessionData:v,setSessionData:y,pluginComponentId:N,onShowModal:b,onShowCreateRecordModal:x,onShowCreateRelatedRecordModal:S,onNetworkError:C,pushHistory:ee,onNetworkRequest:w,appPath:T,createFileId:E,performFileUpload:te,getPendingCacheCount:D,invalidateCache:O});o(!0),P.run(e,{...d,user:t,teamMember:n,business:r,clientObject:s,appPath:T,isDebug:k},f)})},Rt=(e,t)=>{let n=new Worker(new URL(`/assets/expression.worker-Cin-WNVB.js`,``+import.meta.url),{type:`module`});return new Promise(r=>{n.onmessage=e=>{let t=JSON.parse(e.data);n.terminate(),r(t.result)};let i=Ot(`script-runner-logging`);n.postMessage(JSON.stringify({expression:e,args:t,isDebug:i}))})},zt=async(e,t)=>await Rt(e,t),Bt=async(e,t)=>await Rt(e,t),Vt=async(e,t)=>await Rt(e,t),Ht=async(e,t)=>await Rt(e,t),Ut=e=>({key:`action__${e.api_name}`,type:`custom_object`,label:e.name,allow_multiple:!0}),Wt=(e,t)=>{let n=(e.fields??[]).filter(e=>e.type!==`container`&&e.type!==`description`).map(e=>({...e,when:t?`(${t}) && (${e.when??`true`})`:e.when})),r=(e.fields??[]).filter(e=>e.type===`container`).flatMap(e=>Wt(e,e.when)),i=e.actions?.filter(e=>e.hint_object_name)??[];return[...n,...r,...i.map(e=>({...Ut(e),match_hint:e.hint_object_name??``}))]},Gt=(e,t)=>{let n=Wt(e).reduce((e,t)=>({...e,[t.key]:t}),{}),r=Object.keys(t),i={};return r.forEach(e=>{let r=t[e],a=n[e];if(a?.type){switch(a.type){case`boolean`:let t=r;if(!t)return;i[e]=t.value;return;case`custom_object`:{let t=r;if(!t)return;i[e]={objectId:t.value?.id,objectName:t.value?.objectName};return}case`field`:{let t=r;if(!t?.value)return;Array.isArray(t.value)?i[e]=t.value.map(e=>({fieldId:e.value,fieldName:e.label,objectId:t.associatedObject?.id,objectName:t.associatedObject?.name})):typeof t.value==`object`&&typeof t.associatedObject==`object`&&(i[e]={fieldId:t.value.value,fieldName:t.value.label,objectId:t.associatedObject.id,objectName:t.associatedObject.name});return}case`number`:{let t=r;if(!t)return;try{let n=Number(t.value);if(!n&&n!==0)return;i[e]=n}catch{i[e]=NaN}return}case`select`:{let t=r;if(!t)return;i[e]=t.value;return}case`text`:{let t=r?.value;if(t){i[e]=t;return}let n=a.default;n&&(i[e]=n);return}case`description`:case`container`:return}return r?.value}}),i},Kt=e=>{if(e===`boolean`)return!1},qt=(e,t,n,r)=>{let i=Object.keys(e),a={};return i.forEach(r=>{t.includes(r)?a[r]={value:Kt(n[r]?.type),type:n[r]?.type}:a[r]={value:e[r],type:n[r]?.type}}),Wt({fields:r??[]}).forEach(e=>{a[e.key]===void 0&&(t.includes(e.key)?a[e.key]={value:Kt(e.type),type:e.type}:a[e.key]={value:e.default,type:e.type})}),a},Jt=e=>e?e.replaceAll(`{{config.`,`{{config__`).replaceAll(`{{userConfig.`,`{{userConfig__`):``,Yt=async(e,t)=>await zt(Jt(e),t),Xt=e=>{let t={...e,data:e.data.body??e.data,status:e.data.status_code??e.status};return{response:t,upstreamStatus:t.status,upstreamResponse:e.data.body}},Zt=(e,t,n)=>new b(e,t,n),Qt=(e,t)=>new b(e??500,void 0,void 0,t??`An unknown error occurred in the proxy`),$t=e=>{let{response:t,upstreamStatus:n,upstreamResponse:r}=Xt(e);if(n>=400)throw Zt(200,n,r);return t};function en(e){function t(t){try{let n=localStorage.getItem(e(t));return n?JSON.parse(n):null}catch{return null}}function n(t,n,r){let i={__kizen_setup_assistant_values:n,__kizen_clean_config:Gt(r,n)};localStorage.setItem(e(t),JSON.stringify(i))}function r(t,n){let r={__kizen_setup_assistant_values:{},__kizen_clean_config:n};localStorage.setItem(e(t),JSON.stringify(r))}function i(t){localStorage.removeItem(e(t))}return{load:t,save:n,saveRaw:r,clear:i}}var tn=en(t),nn=en(e),rn=tn.load,an=tn.save,on=tn.saveRaw,sn=tn.clear,cn=nn.load,ln=nn.save,un=nn.clear;function dn(e,t){return tn.load(e)?.__kizen_clean_config||(t??null)}export{b as C,l as D,s as E,o as O,We as S,i as T,zt as _,dn as a,Lt as b,ln as c,$t as d,qt as f,Ot as g,At as h,cn as i,a as k,Qt as l,Ut as m,un as n,an as o,Wt as p,rn as r,on as s,sn as t,Yt as u,Ht as v,y as w,Bt as x,Vt as y};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(function(){var e=class e extends Error{proxyStatus;upstreamStatus;upstreamResponse;constructor(t,n,r,i){super(i??r?.error?.message??(n?`Request failed with status code ${String(n)}`:`Request failed with proxy status code ${String(t)}`)),this.name=`KizenRequestError`,this.proxyStatus=t,this.upstreamStatus=n,this.upstreamResponse=r,Object.setPrototypeOf(this,e.prototype)}},t={QUERY_REQUEST:`query:request`,UI_OUTPUT:`outputui`,IFRAME_OUTPUT:`iframeoutput`,POSTFORMDATA_REQUEST:`postformdata:request`,SETSTATE:`setstate`,DONE:`done`,RUN:`run`,OPEN_WINDOW:`openwindow`,COMMUNICATE:`communicate`,HIDE:`hide`,SHOW:`show`,EXPAND:`expand`,COLLAPSE:`collapse`,HIDE_HEADER:`hideheader`,SHOW_HEADER:`showheader`,OPEN_CREATE_RECORD_MODAL_REQUEST:`opencreaterecordmodal:request`,OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST:`opencreaterelatedrecordmodal:request`,SHOW_TOAST:`showtoast`,CLEAR_TOASTS:`cleartoasts`,REFRESH_TIMELINE:`refreshtimeline`,REFRESH_ENTITY:`refreshentity`,UPLOADFILE_REQUEST:`uploadfile:request`,UPDATE_SESSION_DATA:`updatesessiondata`,INSTALL_THIRD_PARTY_SCRIPT_REQUEST:`installthirdpartyscript:request`,PROMPT_REQUEST:`prompt:request`,DYNAMIC_PROMPT_REQUEST:`dynamicprompt:request`,RELEASE_BLOCKING_SCRIPT:`releaseblockingscript`,AUTHORIZE:`authorize`,COPY_TO_CLIPBOARD:`copytoclipboard`},n={QUERY_RESPONSE:`query:response`,POSTFORMDATA_RESPONSE:`postformdata:response`,ERROR:`error`,UPLOADFILE_RESPONSE:`uploadfile:response`,UPLOADFILE_PROGRESS:`uploadfile:progress`,INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:`installthirdpartyscript:response`,PROMPT_RESPONSE:`prompt:response`,REFRESH_ENTITY_RESPONSE:`refreshentity:response`,CREATE_RECORD_RESPONSE:`createrecord:response`,CREATE_RELATED_RECORD_RESPONSE:`createrelatedrecord:response`},r={RUN_FRAME_SCRIPT:`runframescript`,SEND_MESSAGE_TO_FRAME:`sendmessagetoframe`,CALL_THIRD_PARTY_SCRIPT:`callthirdpartyscript`},i=/https:\/\/.*widget\.freshworks\.com\/.*\.js/,a=/https:\/\/widget\.intercom\.io\/widget\/[a-z0-9]+/,o={FRESHWORKS:`freshworks`,INTERCOM:`intercom`},s=e=>{if(i.test(e))return o.FRESHWORKS;if(a.test(e))return o.INTERCOM};o.FRESHWORKS,o.INTERCOM,o.FRESHWORKS,o.INTERCOM,o.FRESHWORKS,o.INTERCOM;var c=class{instance;scriptUrl;integration;constructor(e,t){this.instance=e,this.scriptUrl=t;let n=s(t);if(n)this.integration=n;else throw Error(`Error: Disallowed script url: ${t}`)}get type(){return this.integration}call(...e){this.instance.postMessage(JSON.stringify({action:t.COMMUNICATE,type:r.CALL_THIRD_PARTY_SCRIPT,eventName:`thirdParty:${r.CALL_THIRD_PARTY_SCRIPT}`,recipient:{script:this.scriptUrl,type:this.type},params:e}))}},l=e=>({key:`action__${e.api_name}`,type:`custom_object`,label:e.name,allow_multiple:!0}),u=(e,t)=>{let n=(e.fields??[]).filter(e=>e.type!==`container`&&e.type!==`description`).map(e=>({...e,when:t?`(${t}) && (${e.when??`true`})`:e.when})),r=(e.fields??[]).filter(e=>e.type===`container`).flatMap(e=>u(e,e.when)),i=e.actions?.filter(e=>e.hint_object_name)??[];return[...n,...r,...i.map(e=>({...l(e),match_hint:e.hint_object_name??``}))]},d=(e,t)=>{let n=u(e).reduce((e,t)=>({...e,[t.key]:t}),{}),r=Object.keys(t),i={};return r.forEach(e=>{let r=t[e],a=n[e];if(a?.type){switch(a.type){case`boolean`:let t=r;if(!t)return;i[e]=t.value;return;case`custom_object`:{let t=r;if(!t)return;i[e]={objectId:t.value?.id,objectName:t.value?.objectName};return}case`field`:{let t=r;if(!t?.value)return;Array.isArray(t.value)?i[e]=t.value.map(e=>({fieldId:e.value,fieldName:e.label,objectId:t.associatedObject?.id,objectName:t.associatedObject?.name})):typeof t.value==`object`&&typeof t.associatedObject==`object`&&(i[e]={fieldId:t.value.value,fieldName:t.value.label,objectId:t.associatedObject.id,objectName:t.associatedObject.name});return}case`number`:{let t=r;if(!t)return;try{let n=Number(t.value);if(!n&&n!==0)return;i[e]=n}catch{i[e]=NaN}return}case`select`:{let t=r;if(!t)return;i[e]=t.value;return}case`text`:{let t=r?.value;if(t){i[e]=t;return}let n=a.default;n&&(i[e]=n);return}case`description`:case`container`:return}return r?.value}}),i},f=(e,n)=>r=>async(i,a,o)=>new Promise((s,c)=>{let l=n.register(s,c);e.postMessage(JSON.stringify({action:t.QUERY_REQUEST,id:l,method:r,url:i,payload:a,options:o}))}),p=(e,n)=>(r,i,a=!0)=>new Promise((o,s)=>{let c=n.register(o,s);e.postMessage(JSON.stringify({action:t.POSTFORMDATA_REQUEST,url:r,id:c,payload:i,createNewTab:a}))}),m=(e,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);e.postMessage(JSON.stringify({action:t.PROMPT_REQUEST,id:o,config:r}))}),h=(e,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);e.postMessage(JSON.stringify({action:t.DYNAMIC_PROMPT_REQUEST,id:o,config:r}))}),g=(e,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);e.postMessage(JSON.stringify({action:t.UPLOADFILE_REQUEST,id:o,payload:r}))}),_=(e,n)=>(r,i)=>new Promise((a,o)=>{let s=n.register(a,o);e.postMessage(JSON.stringify({action:t.INSTALL_THIRD_PARTY_SCRIPT_REQUEST,url:r,id:s,args:i}))}),v=(e,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);e.postMessage(JSON.stringify({action:t.REFRESH_ENTITY,id:o,entityId:r}))}),y=(e,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);e.postMessage(JSON.stringify({action:t.OPEN_CREATE_RECORD_MODAL_REQUEST,id:o,entityId:r}))}),b=(e,n)=>(r,i)=>new Promise((a,o)=>{let s=n.register(a,o);e.postMessage(JSON.stringify({action:t.OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST,id:s,objectId:r,relatedEntityId:i}))}),x=(t,r,i)=>{switch(t){case n.QUERY_RESPONSE:{let{id:t,data:n,error:a}=JSON.parse(r.data);if(a){let n=typeof a==`object`&&`__kizenError`in a?new e(a.proxyStatus,a.upstreamStatus,a.upstreamResponse,a.message):a;i.reject(t,n)}else i.resolve(t,n);break}case n.POSTFORMDATA_RESPONSE:{let{id:e,success:t}=JSON.parse(r.data);t?i.resolve(e):i.reject(e);break}case n.UPLOADFILE_RESPONSE:{let{id:e,data:t,error:n}=JSON.parse(r.data);t?i.resolve(e,t):i.reject(e,n);break}case n.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:{let{id:e,data:t}=JSON.parse(r.data);t.success?i.resolve(e,t):i.reject(e);break}case n.PROMPT_RESPONSE:{let{id:e,data:t}=JSON.parse(r.data);i.resolve(e,t);break}case n.CREATE_RECORD_RESPONSE:{let{id:e,data:t}=JSON.parse(r.data);i.resolve(e,t);break}case n.CREATE_RELATED_RECORD_RESPONSE:{let{id:e,data:t}=JSON.parse(r.data);i.resolve(e,t);break}case n.REFRESH_ENTITY_RESPONSE:{let{id:e,data:t}=JSON.parse(r.data);t.success?i.resolve(e,!0):i.reject(e);break}}},S=`integration:${r.RUN_FRAME_SCRIPT}`,C=class{instance;constructor(e){this.instance=e}runFrameScript(e,n,i){this.instance.postMessage(JSON.stringify({action:t.COMMUNICATE,type:r.RUN_FRAME_SCRIPT,eventName:S,recipient:{frame:e,script:n},args:i}))}sendMessageToOwnFrame(e,n){this.instance.postMessage(JSON.stringify({action:t.COMMUNICATE,type:r.SEND_MESSAGE_TO_FRAME,args:{payload:e,path:n}}))}},w=async e=>{let t=null;try{t=await e.json()}catch{}return{status:e.status,statusText:e.statusText,body:t}},T=(e,t,n={},r=``)=>`(function() { ${r}
|
|
2
|
+
return ${`(${e.toString()})({ state: {{${t}}}, args: ${JSON.stringify(n)}, utils: __kizen_utils })`}; })()`,E=class{user;teamMember;business;clientObject;appPath;dataCache=new Map;queryOptions={};api;postFormData;executionTimer=0;setupExecutions=0;cleanupExecutions=0;isDebug=!1;scriptBody;internalState={indicator:`none`};console=console;instance;breakOnException=!1;args;communicate;shouldPreserve=!1;uploadFileHandler;internalSessionData;pluginComponentId;installThirdPartyScriptHandler;promptHandler;dynamicPromptHandler;refreshEntityHandler;openCreateRecordHandler;openCreateRelatedRecordHandler;runnerType;pluginApiName;tempPromptState={};partialLocation;constructor({user:e,teamMember:t,business:n,clientObject:r,appPath:i,isDebug:a,kizenRequest:o,postFormData:s,scriptBody:c,instance:l,args:u,uploadFile:d,sessionData:f,pluginComponentId:p,installThirdPartyScript:m,prompt:h,refreshEntity:g,openCreateRecord:_,openCreateRelatedRecord:v,pluginApiName:y,dynamicPrompt:b,location:x}){this.user=e,this.teamMember=t,this.business=n,this.clientObject=r,this.partialLocation=x,this.appPath=i,this.isDebug=a??!1,this.api={get:o(`get`),post:o(`post`),put:o(`put`),delete:o(`delete`),patch:o(`patch`)},this.postFormData=s,this.scriptBody=c,this.instance=l,this.communicate=new C(l),this.uploadFileHandler=d,this.internalSessionData=f??{},this.pluginComponentId=p,this.installThirdPartyScriptHandler=m,this.promptHandler=h,this.refreshEntityHandler=g,this.openCreateRecordHandler=_,this.openCreateRelatedRecordHandler=v,this.runnerType=`base`,this.pluginApiName=y,this.dynamicPromptHandler=b;try{this.args=JSON.parse(u??`{}`)}catch{this.args={}}}onError(e){if(this.breakOnException)debugger;this.instance.postMessage(JSON.stringify({action:n.ERROR,error:e?.message}))}set debug(e){this.isDebug=e,this.breakOnException=e}set preserve(e){this.shouldPreserve=e}get preserve(){return this.shouldPreserve}parseDate(e){return e.split(`-`)}parsePhone(e){return e.replace(/\+/g,``)}openWindow(e,n=`_blank`){this.instance.postMessage(JSON.stringify({action:t.OPEN_WINDOW,url:e,target:n,features:`noopener noreferrer`}))}authorize(e,n={}){if(!e)throw Error(`Service name is required to authorize`);this.instance.postMessage(JSON.stringify({action:t.AUTHORIZE,serviceName:e,config:{successRedirectPath:n.successRedirectPath??`/marketplace/${this.pluginApiName}/auth`,errorRedirectPath:n.errorRedirectPath??`/marketplace/${this.pluginApiName}/auth`}}))}getServiceUrl(e,t){if(!e)throw Error(`Service name is required to get a service url`);let n=`/external-integrations/proxy/${this.pluginApiName}/${e}`;return t.startsWith(`/`)?`${n}${t}`:`${n}/${t}`}get currentBusiness(){return this.business}get applicationPath(){return this.appPath}get currentUser(){return{profile:{id:this.teamMember?.id??``,full_name:this.teamMember?.full_name??``,first_name:this.teamMember?.first_name??``,last_name:this.teamMember?.last_name??``,email:this.teamMember?.email??``,phone:this.teamMember?.phone??``,created:this.teamMember?.created??``,crm_client_id:this.user?.crm_client_id??``}}}get sessionData(){return this.internalSessionData}get config(){return this.args.__kizen_clean_config?new Proxy(this.args.__kizen_clean_config??{},{get:(e,t)=>{if(Reflect.has(e,t))return Reflect.get(e,t)}}):{}}get location(){return new Proxy(this.partialLocation,{get:(e,t)=>{if(t===`toJSON`)return()=>this.partialLocation;if(Reflect.has(e,t))return Reflect.get(e,t);throw Error(`Property ${String(t)} is not available on location object for plugin apps`)}})}get userConfig(){let e=this.args.__kizen_user_config?.__kizen_clean_config;return e?new Proxy(e,{get:(e,t)=>{if(Reflect.has(e,t))return Reflect.get(e,t)}}):{}}setSessionData(e){if(typeof e!=`object`)throw Error(`Invalid session update with type ${typeof e}`);if(Array.isArray(e))throw Error(`Invalid session update with type array`);this.internalSessionData={...this.internalSessionData,...e},this.instance.postMessage(JSON.stringify({action:t.UPDATE_SESSION_DATA,update:e}))}async get(e,t){try{if(this.isRelativeUrl(e)){let n=this.dataCache.get(e);if(n&&!t?.ignoreCache)return t?.returnErrors?[n.data,null]:n.data;let{data:r}=await this.api.get(e,{...this.queryOptions,headers:this.buildHeaders(t?.headers)});return this.dataCache.set(e,{ts:Date.now(),data:r}),t?.returnErrors?[r,null]:r}else{let n=await fetch(e,{method:`GET`,headers:new Headers(t?.headers),credentials:t?.credentials??`same-origin`});if(!n.ok)throw await w(n);let r=await n.json();return t?.returnErrors?[r,null]:r}}catch(e){if(t?.returnErrors)return[null,e];this.onError(e)}}async getWithErrors(e,t){return this.get(e,{...t,returnErrors:!0})}async getUserConfig(){if(!this.args.pluginId||!this.pluginComponentId)throw Error(`User config is not available for scripts not associated to a plugin or plugin component`);return(await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0})).config?.[this.pluginComponentId]??{}}async setUserConfig(e){if(!this.args.pluginId||!this.pluginComponentId)throw Error(`User config is not available for scripts not associated to a plugin or plugin component`);let t=await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0});return await this.post(`/employee/mine/configs/plugins/${this.args.pluginId}`,{config:{...t?.config,[this.pluginComponentId]:{...t?.config?.[this.pluginComponentId],...e}}})}async patch(e,t,n){try{if(this.isRelativeUrl(e)){let{data:r}=await this.api.patch(e,t,{...this.queryOptions,headers:n?.headers});return n?.returnErrors?[r,null]:r}else{let r=await fetch(e,{method:`PATCH`,body:t?JSON.stringify(t):null,headers:new Headers(n?.headers),credentials:n?.credentials??`same-origin`});if(!r.ok)throw await w(r);let i=await r.json();return n?.returnErrors?[i,null]:i}}catch(e){if(n?.returnErrors)return[null,e];this.onError(e)}}async patchWithErrors(e,t,n){return this.patch(e,t,{...n,returnErrors:!0})}async post(e,t,n){try{if(this.isRelativeUrl(e)){let{data:r}=await this.api.post(e,t,{...this.queryOptions,headers:this.buildHeaders(n?.headers)});return n?.returnErrors?[r,null]:r}else{let r=await fetch(e,{method:`POST`,body:t?JSON.stringify(t):null,headers:new Headers(n?.headers),credentials:n?.credentials??`same-origin`});if(!r.ok)throw await w(r);let i=await r.json();return n?.returnErrors?[i,null]:i}}catch(e){if(n?.returnErrors)return[null,e];this.onError(e)}}async postWithErrors(e,t,n){return this.post(e,t,{...n,returnErrors:!0})}async delete(e,t){try{if(this.isRelativeUrl(e)){let{data:n}=await this.api.delete(e,{...this.queryOptions,headers:this.buildHeaders(t?.headers)});return t?.returnErrors?[n,null]:n}else{let n=await fetch(e,{method:`DELETE`,headers:new Headers(t?.headers),credentials:t?.credentials??`same-origin`});if(!n.ok)throw await w(n);let r=null;return n.status!==204&&(r=await n.json()),t?.returnErrors?[r,null]:r}}catch(e){if(t?.returnErrors)return[null,e];this.onError(e)}}async deleteWithErrors(e,t){return this.delete(e,{...t,returnErrors:!0})}async openCreateRecordModal(e){return this.openCreateRecordHandler(e)}async openCreateRelatedRecordModal(e,t){return this.openCreateRelatedRecordHandler(e,t)}showToast(e,n){this.instance.postMessage(JSON.stringify({action:t.SHOW_TOAST,message:e,toastOptions:n}))}clearToasts(){this.instance.postMessage(JSON.stringify({action:t.CLEAR_TOASTS}))}outputUI(e){this.instance.postMessage(JSON.stringify({action:t.UI_OUTPUT,markup:e}))}prompt(e){return this.promptHandler(e)}async dynamicPrompt(e){let t=`__kizen_state`,n=`const __kizen_utils = {};
|
|
3
|
+
`;if(e.registerUtils){let t=Object.keys(e.registerUtils);n+=t.map(t=>{let n=e.registerUtils?.[t];if(typeof n!=`function`)throw Error(`Registered util ${t} is not a function, got ${typeof n}`);return`__kizen_utils["${t}"] = (${n.toString()});`}).join(`
|
|
4
|
+
`)}let r=e.content?.map(e=>{let r=``;`optionMapper`in e&&(r=T(e.optionMapper,t,e.args,n));let i=``;`getFetchUrl`in e&&(i=T(e.getFetchUrl,t,e.args,n));let a=``;`getHeaders`in e&&(a=T(e.getHeaders,t,e.args,n));let o=``;return`getBody`in e&&(o=T(e.getBody,t,e.args,n)),{...e,optionMapper:r,getFetchUrl:i,getHeaders:a,getBody:o}}),i={...e,content:r},a={fields:i.content},o=await this.dynamicPromptHandler(i),s=d(a,o.values);return{...o,values:s}}outputIframe(e,n,r){this.instance.postMessage(JSON.stringify({action:t.IFRAME_OUTPUT,url:e,allow:n,sandbox:r,preserve:this.preserve}))}getBase64EncodedBlob(e){return new Promise((t,n)=>{let r=new FileReader;r.readAsDataURL(e),r.onload=()=>{t(r.result)},r.onerror=e=>{n(e)}})}async uploadFile(e,t,n=!1){let r=await this.getBase64EncodedBlob(e);return await this.uploadFileHandler({file:r,fileName:t??`file_`+String(Date.now()),isPublic:n})}afterSetup(){}__setup(){if(this.setupExecutions!==0)throw Error(`Setup must be called exactly once, and should never be called by a script directly.`);if(this.cleanupExecutions!==0)throw Error(`Setup was called after cleanup`);this.isDebug&&this.console.log(`Running script:
|
|
5
|
+
|
|
6
|
+
${this.scriptBody}`),this.setupExecutions++,this.executionTimer=performance.now(),this.afterSetup()}__cleanup(e){if(this.cleanupExecutions!==0)throw Error(`Cleanup must be called exactly once, and should never be called by a script directly.`);if(this.setupExecutions!==1)throw Error(`Cleanup was called before setup`);this.cleanupExecutions++,this.setIndicator(`none`);let t=performance.now();this.isDebug&&this.console.log(`Script execution took ${String(t-this.executionTimer)}ms`),this.done(this.preserve,e)}setIndicator(e=`none`){this.internalState.indicator=e,this.setState({indicator:e})}wait(e){return new Promise(t=>setTimeout(t,e))}done(e,n){this.instance.postMessage(JSON.stringify({action:t.DONE,result:n,preserve:e}))}setState(e){this.instance.postMessage(JSON.stringify({action:t.SETSTATE,state:e}))}isRelativeUrl(e){return e.startsWith(`/`)}buildHeaders(e={}){return{...e,"X-Request-Type":`kizen-ui-scripting-api`}}refreshTimelineForId(e){e&&this.instance.postMessage(JSON.stringify({action:t.REFRESH_TIMELINE,entityId:e}))}refreshEntityForId(e){if(e)return this.refreshEntityHandler(e)}async installThirdPartyScript(e){try{let t=await this.installThirdPartyScriptHandler(e,this.args);return new c(this.instance,t.url)}catch{this.onError(Error(`Third party script ${e} could not be installed.`))}}releaseBlockingScript(){this.instance.postMessage(JSON.stringify({action:t.RELEASE_BLOCKING_SCRIPT}))}copyToClipboard(e){this.instance.postMessage(JSON.stringify({action:t.COPY_TO_CLIPBOARD,text:e}))}createDateObject(e){if(typeof e!=`string`)throw Error(`Invalid date string ${String(e)}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw Error(`Date string ${e} is not in the format YYYY-MM-DD`);let t=e.split(`-`).map(e=>parseInt(e,10));if(t.length<3)throw Error(`Date string ${e} could not be parsed into valid date parts`);return new Date(t[0],t[1]-1,t[2])}formatDateForResponse(e){return e.getTime()}},D=class extends E{constructor(e){super(e),this.runnerType=`floatingFrame`}hide(e={}){this.instance.postMessage(JSON.stringify({action:t.HIDE,config:e}))}hideHeader(){this.instance.postMessage(JSON.stringify({action:t.HIDE_HEADER}))}showHeader(){this.instance.postMessage(JSON.stringify({action:t.SHOW_HEADER}))}show(e={}){this.instance.postMessage(JSON.stringify({action:t.SHOW,config:e}))}expand(){this.instance.postMessage(JSON.stringify({action:t.EXPAND}))}collapse(){this.instance.postMessage(JSON.stringify({action:t.COLLAPSE}))}afterSetup(){this.show()}},O=()=>{let e=new Date().getTime();return typeof performance<`u`&&typeof performance.now==`function`&&(e+=performance.now()),`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let n=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t===`x`?n:n&3|8).toString(16)})},k=Object.getPrototypeOf(async function(){}).constructor,A=e=>{let t=`
|
|
7
|
+
const __cleanup = this.__cleanup.bind(this);
|
|
8
|
+
const __error = this.onError.bind(this);
|
|
9
|
+
{
|
|
10
|
+
this.__setup();
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
${e}
|
|
14
|
+
} catch (ex) {
|
|
15
|
+
__error(ex);
|
|
16
|
+
} finally {
|
|
17
|
+
__cleanup();
|
|
18
|
+
}
|
|
19
|
+
`;try{return{fn:new k(t),functionBody:t}}catch{let e=`
|
|
20
|
+
this.__setup();
|
|
21
|
+
this.onError({ message: "The script has a syntax error and could not be parsed" });
|
|
22
|
+
this.__cleanup();
|
|
23
|
+
`;return{fn:new k(e),functionBody:e}}},j=new class{promises;isDebug;constructor({isDebug:e=!1}){this.promises=new Map,this.isDebug=e}delete(e){this.isDebug&&console.log(`Deleting promise ${e}`),this.promises.delete(e)}get(e){return this.isDebug&&console.log(`Getting promise ${e}`),this.promises.get(e)}set(e,t,n){this.promises.set(e,{resolve:t,reject:n})}id(){return O()}register(e,t){let n=this.id();return this.set(n,e,t),n}resolve(e,t){this.get(e)?.resolve(t),this.delete(e)}reject(e,t){this.get(e)?.reject(t),this.delete(e)}}({isDebug:!1});self.onmessage=async e=>{let{action:n,script:r,setup:i,args:a,sessionData:o={},pluginComponentId:s,pluginApiName:c,location:l}=JSON.parse(e.data);if(n===t.RUN&&i&&r){let{fn:e,functionBody:t}=A(r),n=new D({user:i.user,teamMember:i.teamMember,business:i.business,clientObject:i.clientObject,appPath:i.appPath,isDebug:i.isDebug,scriptBody:r,functionBody:t,instance:self,kizenRequest:f(self,j),postFormData:p(self,j),uploadFile:g(self,j),installThirdPartyScript:_(self,j),args:a??``,sessionData:o,pluginComponentId:s,prompt:m(self,j),dynamicPrompt:h(self,j),refreshEntity:v(self,j),openCreateRecord:y(self,j),openCreateRelatedRecord:b(self,j),pluginApiName:c,location:l});await e.bind(n)()}else x(n,e,j)}})();
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
this.__setup();
|
|
16
16
|
this.onError({ message: "The script has a syntax error and could not be parsed" });
|
|
17
17
|
this.__cleanup();
|
|
18
|
-
`;return{fn:new l(e),functionBody:e}}},d=class{promises;isDebug;constructor({isDebug:e=!1}){this.promises=new Map,this.isDebug=e}delete(e){this.isDebug&&console.log(`Deleting promise ${e}`),this.promises.delete(e)}get(e){return this.isDebug&&console.log(`Getting promise ${e}`),this.promises.get(e)}set(e,t,n){this.promises.set(e,{resolve:t,reject:n})}id(){return c()}register(e,t){let n=this.id();return this.set(n,e,t),n}resolve(e,t){this.get(e)?.resolve(t),this.delete(e)}reject(e,t){this.get(e)?.reject(t),this.delete(e)}},f=e=>({key:`action__${e.api_name}`,type:`custom_object`,label:e.name,allow_multiple:!0}),
|
|
19
|
-
return ${`(${e.toString()})({ state: {{${t}}}, args: ${JSON.stringify(n)}, utils: __kizen_utils })`}; })()`,
|
|
18
|
+
`;return{fn:new l(e),functionBody:e}}},d=class{promises;isDebug;constructor({isDebug:e=!1}){this.promises=new Map,this.isDebug=e}delete(e){this.isDebug&&console.log(`Deleting promise ${e}`),this.promises.delete(e)}get(e){return this.isDebug&&console.log(`Getting promise ${e}`),this.promises.get(e)}set(e,t,n){this.promises.set(e,{resolve:t,reject:n})}id(){return c()}register(e,t){let n=this.id();return this.set(n,e,t),n}resolve(e,t){this.get(e)?.resolve(t),this.delete(e)}reject(e,t){this.get(e)?.reject(t),this.delete(e)}},f=class e extends Error{proxyStatus;upstreamStatus;upstreamResponse;constructor(t,n,r,i){super(i??r?.error?.message??(n?`Request failed with status code ${String(n)}`:`Request failed with proxy status code ${String(t)}`)),this.name=`KizenRequestError`,this.proxyStatus=t,this.upstreamStatus=n,this.upstreamResponse=r,Object.setPrototypeOf(this,e.prototype)}},p=e=>({key:`action__${e.api_name}`,type:`custom_object`,label:e.name,allow_multiple:!0}),m=(e,t)=>{let n=(e.fields??[]).filter(e=>e.type!==`container`&&e.type!==`description`).map(e=>({...e,when:t?`(${t}) && (${e.when??`true`})`:e.when})),r=(e.fields??[]).filter(e=>e.type===`container`).flatMap(e=>m(e,e.when)),i=e.actions?.filter(e=>e.hint_object_name)??[];return[...n,...r,...i.map(e=>({...p(e),match_hint:e.hint_object_name??``}))]},h=(e,t)=>{let n=m(e).reduce((e,t)=>({...e,[t.key]:t}),{}),r=Object.keys(t),i={};return r.forEach(e=>{let r=t[e],a=n[e];if(a?.type){switch(a.type){case`boolean`:let t=r;if(!t)return;i[e]=t.value;return;case`custom_object`:{let t=r;if(!t)return;i[e]={objectId:t.value?.id,objectName:t.value?.objectName};return}case`field`:{let t=r;if(!t?.value)return;Array.isArray(t.value)?i[e]=t.value.map(e=>({fieldId:e.value,fieldName:e.label,objectId:t.associatedObject?.id,objectName:t.associatedObject?.name})):typeof t.value==`object`&&typeof t.associatedObject==`object`&&(i[e]={fieldId:t.value.value,fieldName:t.value.label,objectId:t.associatedObject.id,objectName:t.associatedObject.name});return}case`number`:{let t=r;if(!t)return;try{let n=Number(t.value);if(!n&&n!==0)return;i[e]=n}catch{i[e]=NaN}return}case`select`:{let t=r;if(!t)return;i[e]=t.value;return}case`text`:{let t=r?.value;if(t){i[e]=t;return}let n=a.default;n&&(i[e]=n);return}case`description`:case`container`:return}return r?.value}}),i},g=(t,n)=>r=>async(i,a,o)=>new Promise((s,c)=>{let l=n.register(s,c);t.postMessage(JSON.stringify({action:e.QUERY_REQUEST,id:l,method:r,url:i,payload:a,options:o}))}),_=(t,n)=>(r,i,a=!0)=>new Promise((o,s)=>{let c=n.register(o,s);t.postMessage(JSON.stringify({action:e.POSTFORMDATA_REQUEST,url:r,id:c,payload:i,createNewTab:a}))}),v=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.PROMPT_REQUEST,id:o,config:r}))}),y=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.DYNAMIC_PROMPT_REQUEST,id:o,config:r}))}),b=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.UPLOADFILE_REQUEST,id:o,payload:r}))}),x=(t,n)=>(r,i)=>new Promise((a,o)=>{let s=n.register(a,o);t.postMessage(JSON.stringify({action:e.INSTALL_THIRD_PARTY_SCRIPT_REQUEST,url:r,id:s,args:i}))}),S=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.REFRESH_ENTITY,id:o,entityId:r}))}),C=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.OPEN_CREATE_RECORD_MODAL_REQUEST,id:o,entityId:r}))}),w=(t,n)=>(r,i)=>new Promise((a,o)=>{let s=n.register(a,o);t.postMessage(JSON.stringify({action:e.OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST,id:s,objectId:r,relatedEntityId:i}))}),T=(e,n,r)=>{switch(e){case t.QUERY_RESPONSE:{let{id:e,data:t,error:i}=JSON.parse(n.data);if(i){let t=typeof i==`object`&&`__kizenError`in i?new f(i.proxyStatus,i.upstreamStatus,i.upstreamResponse,i.message):i;r.reject(e,t)}else r.resolve(e,t);break}case t.POSTFORMDATA_RESPONSE:{let{id:e,success:t}=JSON.parse(n.data);t?r.resolve(e):r.reject(e);break}case t.UPLOADFILE_RESPONSE:{let{id:e,data:t,error:i}=JSON.parse(n.data);t?r.resolve(e,t):r.reject(e,i);break}case t.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);t.success?r.resolve(e,t):r.reject(e);break}case t.PROMPT_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);r.resolve(e,t);break}case t.CREATE_RECORD_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);r.resolve(e,t);break}case t.CREATE_RELATED_RECORD_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);r.resolve(e,t);break}case t.REFRESH_ENTITY_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);t.success?r.resolve(e,!0):r.reject(e);break}}},E=`integration:${n.RUN_FRAME_SCRIPT}`,D=class{instance;constructor(e){this.instance=e}runFrameScript(t,r,i){this.instance.postMessage(JSON.stringify({action:e.COMMUNICATE,type:n.RUN_FRAME_SCRIPT,eventName:E,recipient:{frame:t,script:r},args:i}))}sendMessageToOwnFrame(t,r){this.instance.postMessage(JSON.stringify({action:e.COMMUNICATE,type:n.SEND_MESSAGE_TO_FRAME,args:{payload:t,path:r}}))}},O=async e=>{let t=null;try{t=await e.json()}catch{}return{status:e.status,statusText:e.statusText,body:t}},k=(e,t,n={},r=``)=>`(function() { ${r}
|
|
19
|
+
return ${`(${e.toString()})({ state: {{${t}}}, args: ${JSON.stringify(n)}, utils: __kizen_utils })`}; })()`,A=class{user;teamMember;business;clientObject;appPath;dataCache=new Map;queryOptions={};api;postFormData;executionTimer=0;setupExecutions=0;cleanupExecutions=0;isDebug=!1;scriptBody;internalState={indicator:`none`};console=console;instance;breakOnException=!1;args;communicate;shouldPreserve=!1;uploadFileHandler;internalSessionData;pluginComponentId;installThirdPartyScriptHandler;promptHandler;dynamicPromptHandler;refreshEntityHandler;openCreateRecordHandler;openCreateRelatedRecordHandler;runnerType;pluginApiName;tempPromptState={};partialLocation;constructor({user:e,teamMember:t,business:n,clientObject:r,appPath:i,isDebug:a,kizenRequest:o,postFormData:s,scriptBody:c,instance:l,args:u,uploadFile:d,sessionData:f,pluginComponentId:p,installThirdPartyScript:m,prompt:h,refreshEntity:g,openCreateRecord:_,openCreateRelatedRecord:v,pluginApiName:y,dynamicPrompt:b,location:x}){this.user=e,this.teamMember=t,this.business=n,this.clientObject=r,this.partialLocation=x,this.appPath=i,this.isDebug=a??!1,this.api={get:o(`get`),post:o(`post`),put:o(`put`),delete:o(`delete`),patch:o(`patch`)},this.postFormData=s,this.scriptBody=c,this.instance=l,this.communicate=new D(l),this.uploadFileHandler=d,this.internalSessionData=f??{},this.pluginComponentId=p,this.installThirdPartyScriptHandler=m,this.promptHandler=h,this.refreshEntityHandler=g,this.openCreateRecordHandler=_,this.openCreateRelatedRecordHandler=v,this.runnerType=`base`,this.pluginApiName=y,this.dynamicPromptHandler=b;try{this.args=JSON.parse(u??`{}`)}catch{this.args={}}}onError(e){if(this.breakOnException)debugger;this.instance.postMessage(JSON.stringify({action:t.ERROR,error:e?.message}))}set debug(e){this.isDebug=e,this.breakOnException=e}set preserve(e){this.shouldPreserve=e}get preserve(){return this.shouldPreserve}parseDate(e){return e.split(`-`)}parsePhone(e){return e.replace(/\+/g,``)}openWindow(t,n=`_blank`){this.instance.postMessage(JSON.stringify({action:e.OPEN_WINDOW,url:t,target:n,features:`noopener noreferrer`}))}authorize(t,n={}){if(!t)throw Error(`Service name is required to authorize`);this.instance.postMessage(JSON.stringify({action:e.AUTHORIZE,serviceName:t,config:{successRedirectPath:n.successRedirectPath??`/marketplace/${this.pluginApiName}/auth`,errorRedirectPath:n.errorRedirectPath??`/marketplace/${this.pluginApiName}/auth`}}))}getServiceUrl(e,t){if(!e)throw Error(`Service name is required to get a service url`);let n=`/external-integrations/proxy/${this.pluginApiName}/${e}`;return t.startsWith(`/`)?`${n}${t}`:`${n}/${t}`}get currentBusiness(){return this.business}get applicationPath(){return this.appPath}get currentUser(){return{profile:{id:this.teamMember?.id??``,full_name:this.teamMember?.full_name??``,first_name:this.teamMember?.first_name??``,last_name:this.teamMember?.last_name??``,email:this.teamMember?.email??``,phone:this.teamMember?.phone??``,created:this.teamMember?.created??``,crm_client_id:this.user?.crm_client_id??``}}}get sessionData(){return this.internalSessionData}get config(){return this.args.__kizen_clean_config?new Proxy(this.args.__kizen_clean_config??{},{get:(e,t)=>{if(Reflect.has(e,t))return Reflect.get(e,t)}}):{}}get location(){return new Proxy(this.partialLocation,{get:(e,t)=>{if(t===`toJSON`)return()=>this.partialLocation;if(Reflect.has(e,t))return Reflect.get(e,t);throw Error(`Property ${String(t)} is not available on location object for plugin apps`)}})}get userConfig(){let e=this.args.__kizen_user_config?.__kizen_clean_config;return e?new Proxy(e,{get:(e,t)=>{if(Reflect.has(e,t))return Reflect.get(e,t)}}):{}}setSessionData(t){if(typeof t!=`object`)throw Error(`Invalid session update with type ${typeof t}`);if(Array.isArray(t))throw Error(`Invalid session update with type array`);this.internalSessionData={...this.internalSessionData,...t},this.instance.postMessage(JSON.stringify({action:e.UPDATE_SESSION_DATA,update:t}))}async get(e,t){try{if(this.isRelativeUrl(e)){let n=this.dataCache.get(e);if(n&&!t?.ignoreCache)return t?.returnErrors?[n.data,null]:n.data;let{data:r}=await this.api.get(e,{...this.queryOptions,headers:this.buildHeaders(t?.headers)});return this.dataCache.set(e,{ts:Date.now(),data:r}),t?.returnErrors?[r,null]:r}else{let n=await fetch(e,{method:`GET`,headers:new Headers(t?.headers),credentials:t?.credentials??`same-origin`});if(!n.ok)throw await O(n);let r=await n.json();return t?.returnErrors?[r,null]:r}}catch(e){if(t?.returnErrors)return[null,e];this.onError(e)}}async getWithErrors(e,t){return this.get(e,{...t,returnErrors:!0})}async getUserConfig(){if(!this.args.pluginId||!this.pluginComponentId)throw Error(`User config is not available for scripts not associated to a plugin or plugin component`);return(await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0})).config?.[this.pluginComponentId]??{}}async setUserConfig(e){if(!this.args.pluginId||!this.pluginComponentId)throw Error(`User config is not available for scripts not associated to a plugin or plugin component`);let t=await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0});return await this.post(`/employee/mine/configs/plugins/${this.args.pluginId}`,{config:{...t?.config,[this.pluginComponentId]:{...t?.config?.[this.pluginComponentId],...e}}})}async patch(e,t,n){try{if(this.isRelativeUrl(e)){let{data:r}=await this.api.patch(e,t,{...this.queryOptions,headers:n?.headers});return n?.returnErrors?[r,null]:r}else{let r=await fetch(e,{method:`PATCH`,body:t?JSON.stringify(t):null,headers:new Headers(n?.headers),credentials:n?.credentials??`same-origin`});if(!r.ok)throw await O(r);let i=await r.json();return n?.returnErrors?[i,null]:i}}catch(e){if(n?.returnErrors)return[null,e];this.onError(e)}}async patchWithErrors(e,t,n){return this.patch(e,t,{...n,returnErrors:!0})}async post(e,t,n){try{if(this.isRelativeUrl(e)){let{data:r}=await this.api.post(e,t,{...this.queryOptions,headers:this.buildHeaders(n?.headers)});return n?.returnErrors?[r,null]:r}else{let r=await fetch(e,{method:`POST`,body:t?JSON.stringify(t):null,headers:new Headers(n?.headers),credentials:n?.credentials??`same-origin`});if(!r.ok)throw await O(r);let i=await r.json();return n?.returnErrors?[i,null]:i}}catch(e){if(n?.returnErrors)return[null,e];this.onError(e)}}async postWithErrors(e,t,n){return this.post(e,t,{...n,returnErrors:!0})}async delete(e,t){try{if(this.isRelativeUrl(e)){let{data:n}=await this.api.delete(e,{...this.queryOptions,headers:this.buildHeaders(t?.headers)});return t?.returnErrors?[n,null]:n}else{let n=await fetch(e,{method:`DELETE`,headers:new Headers(t?.headers),credentials:t?.credentials??`same-origin`});if(!n.ok)throw await O(n);let r=null;return n.status!==204&&(r=await n.json()),t?.returnErrors?[r,null]:r}}catch(e){if(t?.returnErrors)return[null,e];this.onError(e)}}async deleteWithErrors(e,t){return this.delete(e,{...t,returnErrors:!0})}async openCreateRecordModal(e){return this.openCreateRecordHandler(e)}async openCreateRelatedRecordModal(e,t){return this.openCreateRelatedRecordHandler(e,t)}showToast(t,n){this.instance.postMessage(JSON.stringify({action:e.SHOW_TOAST,message:t,toastOptions:n}))}clearToasts(){this.instance.postMessage(JSON.stringify({action:e.CLEAR_TOASTS}))}outputUI(t){this.instance.postMessage(JSON.stringify({action:e.UI_OUTPUT,markup:t}))}prompt(e){return this.promptHandler(e)}async dynamicPrompt(e){let t=`__kizen_state`,n=`const __kizen_utils = {};
|
|
20
20
|
`;if(e.registerUtils){let t=Object.keys(e.registerUtils);n+=t.map(t=>{let n=e.registerUtils?.[t];if(typeof n!=`function`)throw Error(`Registered util ${t} is not a function, got ${typeof n}`);return`__kizen_utils["${t}"] = (${n.toString()});`}).join(`
|
|
21
|
-
`)}let r=e.content?.map(e=>{let r=``;`optionMapper`in e&&(r=
|
|
21
|
+
`)}let r=e.content?.map(e=>{let r=``;`optionMapper`in e&&(r=k(e.optionMapper,t,e.args,n));let i=``;`getFetchUrl`in e&&(i=k(e.getFetchUrl,t,e.args,n));let a=``;`getHeaders`in e&&(a=k(e.getHeaders,t,e.args,n));let o=``;return`getBody`in e&&(o=k(e.getBody,t,e.args,n)),{...e,optionMapper:r,getFetchUrl:i,getHeaders:a,getBody:o}}),i={...e,content:r},a={fields:i.content},o=await this.dynamicPromptHandler(i),s=h(a,o.values);return{...o,values:s}}outputIframe(t,n,r){this.instance.postMessage(JSON.stringify({action:e.IFRAME_OUTPUT,url:t,allow:n,sandbox:r,preserve:this.preserve}))}getBase64EncodedBlob(e){return new Promise((t,n)=>{let r=new FileReader;r.readAsDataURL(e),r.onload=()=>{t(r.result)},r.onerror=e=>{n(e)}})}async uploadFile(e,t,n=!1){let r=await this.getBase64EncodedBlob(e);return await this.uploadFileHandler({file:r,fileName:t??`file_`+String(Date.now()),isPublic:n})}afterSetup(){}__setup(){if(this.setupExecutions!==0)throw Error(`Setup must be called exactly once, and should never be called by a script directly.`);if(this.cleanupExecutions!==0)throw Error(`Setup was called after cleanup`);this.isDebug&&this.console.log(`Running script:
|
|
22
22
|
|
|
23
|
-
${this.scriptBody}`),this.setupExecutions++,this.executionTimer=performance.now(),this.afterSetup()}__cleanup(e){if(this.cleanupExecutions!==0)throw Error(`Cleanup must be called exactly once, and should never be called by a script directly.`);if(this.setupExecutions!==1)throw Error(`Cleanup was called before setup`);this.cleanupExecutions++,this.setIndicator(`none`);let t=performance.now();this.isDebug&&this.console.log(`Script execution took ${String(t-this.executionTimer)}ms`),this.done(this.preserve,e)}setIndicator(e=`none`){this.internalState.indicator=e,this.setState({indicator:e})}wait(e){return new Promise(t=>setTimeout(t,e))}done(t,n){this.instance.postMessage(JSON.stringify({action:e.DONE,result:n,preserve:t}))}setState(t){this.instance.postMessage(JSON.stringify({action:e.SETSTATE,state:t}))}isRelativeUrl(e){return e.startsWith(`/`)}buildHeaders(e={}){return{...e,"X-Request-Type":`kizen-ui-scripting-api`}}refreshTimelineForId(t){t&&this.instance.postMessage(JSON.stringify({action:e.REFRESH_TIMELINE,entityId:t}))}refreshEntityForId(e){if(e)return this.refreshEntityHandler(e)}async installThirdPartyScript(e){try{let t=await this.installThirdPartyScriptHandler(e,this.args);return new s(this.instance,t.url)}catch{this.onError(Error(`Third party script ${e} could not be installed.`))}}releaseBlockingScript(){this.instance.postMessage(JSON.stringify({action:e.RELEASE_BLOCKING_SCRIPT}))}copyToClipboard(t){this.instance.postMessage(JSON.stringify({action:e.COPY_TO_CLIPBOARD,text:t}))}createDateObject(e){if(typeof e!=`string`)throw Error(`Invalid date string ${String(e)}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw Error(`Date string ${e} is not in the format YYYY-MM-DD`);let t=e.split(`-`).map(e=>parseInt(e,10));if(t.length<3)throw Error(`Date string ${e} could not be parsed into valid date parts`);return new Date(t[0],t[1]-1,t[2])}formatDateForResponse(e){return e.getTime()}},
|
|
23
|
+
${this.scriptBody}`),this.setupExecutions++,this.executionTimer=performance.now(),this.afterSetup()}__cleanup(e){if(this.cleanupExecutions!==0)throw Error(`Cleanup must be called exactly once, and should never be called by a script directly.`);if(this.setupExecutions!==1)throw Error(`Cleanup was called before setup`);this.cleanupExecutions++,this.setIndicator(`none`);let t=performance.now();this.isDebug&&this.console.log(`Script execution took ${String(t-this.executionTimer)}ms`),this.done(this.preserve,e)}setIndicator(e=`none`){this.internalState.indicator=e,this.setState({indicator:e})}wait(e){return new Promise(t=>setTimeout(t,e))}done(t,n){this.instance.postMessage(JSON.stringify({action:e.DONE,result:n,preserve:t}))}setState(t){this.instance.postMessage(JSON.stringify({action:e.SETSTATE,state:t}))}isRelativeUrl(e){return e.startsWith(`/`)}buildHeaders(e={}){return{...e,"X-Request-Type":`kizen-ui-scripting-api`}}refreshTimelineForId(t){t&&this.instance.postMessage(JSON.stringify({action:e.REFRESH_TIMELINE,entityId:t}))}refreshEntityForId(e){if(e)return this.refreshEntityHandler(e)}async installThirdPartyScript(e){try{let t=await this.installThirdPartyScriptHandler(e,this.args);return new s(this.instance,t.url)}catch{this.onError(Error(`Third party script ${e} could not be installed.`))}}releaseBlockingScript(){this.instance.postMessage(JSON.stringify({action:e.RELEASE_BLOCKING_SCRIPT}))}copyToClipboard(t){this.instance.postMessage(JSON.stringify({action:e.COPY_TO_CLIPBOARD,text:t}))}createDateObject(e){if(typeof e!=`string`)throw Error(`Invalid date string ${String(e)}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw Error(`Date string ${e} is not in the format YYYY-MM-DD`);let t=e.split(`-`).map(e=>parseInt(e,10));if(t.length<3)throw Error(`Date string ${e} could not be parsed into valid date parts`);return new Date(t[0],t[1]-1,t[2])}formatDateForResponse(e){return e.getTime()}},j=new d({isDebug:!1}),M=null;self.onmessage=async t=>{let{action:n,script:r,setup:i,args:a,sessionData:o={},pluginComponentId:s,pluginApiName:c,location:l}=JSON.parse(t.data);if(n===e.RUN&&i&&r){let{fn:e,functionBody:t}=u(r);M=new A({user:i.user,teamMember:i.teamMember,business:i.business,clientObject:i.clientObject,isDebug:i.isDebug,appPath:i.appPath,scriptBody:r,functionBody:t,instance:self,kizenRequest:g(self,j),postFormData:_(self,j),uploadFile:b(self,j),installThirdPartyScript:x(self,j),args:a??``,sessionData:o,pluginComponentId:s,prompt:v(self,j),dynamicPrompt:y(self,j),refreshEntity:S(self,j),openCreateRecord:C(self,j),openCreateRelatedRecord:w(self,j),pluginApiName:c,location:l}),await e.bind(M)()}else T(n,t,j)}})();
|