import{G as e,J as t,K as n,Q as r,U as i,W as a,X as o,bt as s,gt as c,ht as l,it as u,mt as d,pt as f,q as p,tt as m,vt as h,wt as g,xt as _}from"./lz-string-CMojKG3P.js";import{_ as v}from"./dist-rbQIUfXp.js";import{t as y}from"./chunk-pbuEa-1d-DjY3kn7w.js";var b={id:`powerhouse/app`,name:`App Module`,extension:`.phdm`,description:``,author:{name:`Powerhouse`,website:`https://powerhouse.inc`},specifications:[{version:1,changeLog:[],state:{global:{schema:`type AppModuleState {
  name: String!
  status: StatusType!
  allowedDocumentTypes: [String!]
  isDragAndDropEnabled: Boolean!
}

enum StatusType {
  DRAFT
  CONFIRMED
}`,initialValue:`{
  "name": "",
  "status": "DRAFT",
  "allowedDocumentTypes": null,
  "isDragAndDropEnabled": true
}`,examples:[]},local:{schema:``,initialValue:``,examples:[]}},modules:[{id:`d274599a-ceb5-4f2b-8651-b25787306734`,name:`base_operations`,description:``,operations:[{id:`f2ba2ddc-8527-4162-93bd-e045e9932013`,name:`SET_APP_NAME`,description:``,schema:`input SetAppNameInput {
  name: String!
}`,template:``,reducer:``,errors:[],examples:[],scope:`global`},{id:`c842efa4-154c-4fd9-9d12-42bec51af4e9`,name:`SET_APP_STATUS`,description:``,schema:`input SetAppStatusInput {
  status: StatusType!
}`,template:``,reducer:``,errors:[],examples:[],scope:`global`},{id:`7376f168-695f-4aef-94d0-6e381666358c`,name:`ADD_DOCUMENT_TYPE`,description:``,schema:`input AddDocumentTypeInput {
  documentType: String!
}`,template:``,reducer:``,errors:[],examples:[],scope:`global`},{id:`310e4e5b-3f14-4e9a-8e09-5583c7698a65`,name:`REMOVE_DOCUMENT_TYPE`,description:``,schema:`input RemoveDocumentTypeInput {
  documentType: String!
}`,template:``,reducer:``,errors:[],examples:[],scope:`global`},{id:`b365727a-7df3-48f0-a4f8-02362f02ad1d`,name:`SET_DOCUMENT_TYPES`,description:``,schema:`input SetDocumentTypesInput {
  documentTypes: [String!]!
}`,template:``,reducer:``,errors:[],examples:[],scope:`global`}]},{id:`270faa10-92e9-40d0-b128-2de32704bcb5`,name:`dnd_operations`,description:``,operations:[{id:`077b1ab8-cb32-4b4e-a1fa-76178188c6a1`,name:`SET_DRAG_AND_DROP_ENABLED`,description:``,schema:`input SetDragAndDropEnabledInput {
  enabled: Boolean!
}`,template:``,reducer:``,errors:[],examples:[],scope:`global`}]}]}]},x=e=>e!=null;d().refine(e=>x(e));var S=f([`CONFIRMED`,`DRAFT`]);function C(){return s({documentType:_()})}function w(){return s({__typename:h(`AppModuleState`).optional(),allowedDocumentTypes:l(_()).nullish(),isDragAndDropEnabled:c(),name:_(),status:S})}function T(){return s({documentType:_()})}function E(){return s({name:_()})}function D(){return s({status:S})}function O(){return s({documentTypes:l(_())})}function k(){return s({enabled:c()})}var A=y({addDocumentType:()=>N,removeDocumentType:()=>P,setAppName:()=>j,setAppStatus:()=>M,setDocumentTypes:()=>F}),j=e=>o(`SET_APP_NAME`,{...e},void 0,E,`global`),M=e=>o(`SET_APP_STATUS`,{...e},void 0,D,`global`),N=e=>o(`ADD_DOCUMENT_TYPE`,{...e},void 0,C,`global`),P=e=>o(`REMOVE_DOCUMENT_TYPE`,{...e},void 0,T,`global`),F=e=>o(`SET_DOCUMENT_TYPES`,{...e},void 0,O,`global`),I=y({setDragAndDropEnabled:()=>L}),L=e=>o(`SET_DRAG_AND_DROP_ENABLED`,{...e},void 0,k,`global`),R=`powerhouse/app`,z=i.extend({documentType:h(R)}),B=a.extend({global:w()}),V=s({header:z,state:B,initialState:B});function H(e){return B.safeParse(e).success}function U(e){B.parse(e)}function W(e){return V.safeParse(e).success}function G(e){V.parse(e)}var K={setAppNameOperation(e,t,n){let r=t.input.name.trim();if(r===``)throw Error(`App name cannot be empty`);e.name=r},setAppStatusOperation(e,t,n){e.status=t.input.status},addDocumentTypeOperation(e,t,n){let r=e.allowedDocumentTypes??[],i=t.input.documentType;e.allowedDocumentTypes=[...new Set(r).add(i)]},removeDocumentTypeOperation(e,t,n){let r=e.allowedDocumentTypes,i=t.input.documentType;e.allowedDocumentTypes=r?.filter(e=>e!==i)??[]},setDocumentTypesOperation(e,t,n){e.allowedDocumentTypes=t.input.documentTypes}},q={setDragAndDropEnabledOperation(e,t,n){e.isDragAndDropEnabled=t.input.enabled}},J=r((e,t,n)=>{if(u(t))return e;switch(t.type){case`SET_APP_NAME`:E().parse(t.input),K.setAppNameOperation(e[t.scope],t,n);break;case`SET_APP_STATUS`:D().parse(t.input),K.setAppStatusOperation(e[t.scope],t,n);break;case`ADD_DOCUMENT_TYPE`:C().parse(t.input),K.addDocumentTypeOperation(e[t.scope],t,n);break;case`REMOVE_DOCUMENT_TYPE`:T().parse(t.input),K.removeDocumentTypeOperation(e[t.scope],t,n);break;case`SET_DOCUMENT_TYPES`:O().parse(t.input),K.setDocumentTypesOperation(e[t.scope],t,n);break;case`SET_DRAG_AND_DROP_ENABLED`:k().parse(t.input),q.setDragAndDropEnabledOperation(e[t.scope],t,n);break;default:return e}}),Y={name:``,status:`DRAFT`,allowedDocumentTypes:null,isDragAndDropEnabled:!0},X={},Z={fileExtension:`.phdm`,createState(e){return{...m(),global:{...Y,...e?.global},local:{...X,...e?.local}}},createDocument(e){let t=n(Z.createState,e);return t.header.documentType=R,t.header.id=g(),t},saveToFileHandle(e,n){return t(e,n)},loadFromInput(e){return p(e,J)},isStateOfType(e){return H(e)},assertIsStateOfType(e){return U(e)},isDocumentOfType(e){return W(e)},assertIsDocumentOfType(e){return G(e)}},Q=y({});function $(){let[e,t]=v();return G(e),[e,t]}var ee={...e,...A,...I},te={...Z,...Q};export{P as a,F as c,te as d,J as i,L as l,N as n,j as o,b as r,M as s,ee as t,$ as u};
//# sourceMappingURL=app-module-BbhoykB5-Bxf5AUcc.js.map